Как создать таблицу jasper и текстовые поля внутри компонента списка с источником данных XML? - PullRequest
3 голосов
/ 08 октября 2019

Я пытаюсь сгенерировать отчет, используя Jasper iReport Designer 5.6.0, где есть список с таблицей и некоторыми текстовыми полями. Сгенерированный отчет должен выглядеть следующим образом:

enter image description here

Для этого я использую следующий XML-файл в качестве источника данных:

<report>
    <subreport>
        <nameOfState>USA</nameOfState>
        <persons>
            <person>
                <dateOfBirth>1989-02-01T00:00:00.000Z</dateOfBirth>
                <fullName>Skyler White</fullName>
                <address>Albuquerque 87107</address>
            </person>
            <person>
                <dateOfBirth>1962-02-01T00:00:00.000Z</dateOfBirth>
                <fullName>Jesse Pinkman</fullName>
                <address>Santa Fé 28</address>
                <companies>
                    <company>
                        <nameOfCompany>Company 124</nameOfCompany>
                        <addressOfCompany>Santa Fé 158</addressOfCompany>
                    </company>
                </companies>
            </person>
        </persons>
    </subreport>
    <subreport>
        <nameOfState>Germany</nameOfState>
            <person>
                <dateOfBirth>1970-02-01T00:00:00.000Z</dateOfBirth>
                <fullName>Hank Schrader</fullName>
                <address>El Paso 17</address>
                <companies>
                    <company>
                        <nameOfCompany>El Paso Company</nameOfCompany>
                        <addressOfCompany>El Paso 28</addressOfCompany>
                    </company>
                    <company>
                        <nameOfCompany>COMPANY EPC</nameOfCompany>
                        <addressOfCompany>Santa Fé 18</addressOfCompany>
                    </company>
                </companies>
            </person>
        </persons>
    </subreport>
</report>

И шаблон jrxml:

   <?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1_subreport1" pageWidth="756" pageHeight="140" whenNoDataType="BlankPage" columnWidth="756" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Error" isIgnorePagination="true" uuid="0a5fd60a-c7ea-46b7-a1e6-484cdedee54a">
    <property name="ireport.zoom" value="1.7715610000000022"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table 3">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_TH" mode="Opaque">
        <box>
            <pen lineWidth="0.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_CH" mode="Opaque" backcolor="#FFD0BF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="PersonsDataset" uuid="cf4c2515-8d53-4c2a-a6ca-d33257aa8e74">
        <queryString language="xPath">
            <![CDATA[/subreport/persons/person]]>
        </queryString>
        <field name="dateOfBirth" class="java.lang.String">
            <fieldDescription><![CDATA[dateOfBirth]]></fieldDescription>
        </field>
        <field name="fullName" class="java.lang.String">
            <fieldDescription><![CDATA[fullName]]></fieldDescription>
        </field>
        <field name="address" class="java.lang.String">
            <fieldDescription><![CDATA[address]]></fieldDescription>
        </field>
    </subDataset>
    <subDataset name="CompanyDataset" uuid="80440d3f-8de3-4fe7-8d02-62734435d23d">
        <queryString language="xPath">
            <![CDATA[/company]]>
        </queryString>
        <field name="nameOfCompany" class="java.lang.String">
            <fieldDescription><![CDATA[child::text()]]></fieldDescription>
        </field>
        <field name="addressOfCompany" class="java.lang.String">
            <fieldDescription><![CDATA[child::text()]]></fieldDescription>
        </field>
    </subDataset>
    <queryString language="xPath">
        <![CDATA[/subreport/persons/person]]>
    </queryString>
    <field name="nameOfState" class="java.lang.String">
        <fieldDescription><![CDATA[nameOfState]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="140" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="36" width="753" height="104" uuid="e417d0a1-9945-42e9-b12b-8bf0573c93ba"/>
                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                    <datasetRun subDataset="PersonsDataset" uuid="c0d23173-9df2-452c-9d97-78dee6f766ef">
                        <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/subreport/persons/person")]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="104" width="753">
                        <staticText>
                            <reportElement mode="Opaque" x="11" y="11" width="100" height="13" backcolor="#C0C0C0" uuid="21b820ed-d7eb-4c92-a1c7-8b60880bb3b6"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <text><![CDATA[Full name]]></text>
                        </staticText>
                        <staticText>
                            <reportElement mode="Opaque" x="11" y="24" width="100" height="13" backcolor="#C0C0C0" uuid="1b637cc8-c654-4734-9ee8-debc404931a2"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <text><![CDATA[Address:]]></text>
                        </staticText>
                        <staticText>
                            <reportElement mode="Opaque" x="11" y="37" width="100" height="13" backcolor="#C0C0C0" uuid="08dc2de1-652a-4cd5-b572-344dbadb3b91"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <text><![CDATA[Date of birth:]]></text>
                        </staticText>
                        <textField>
                            <reportElement x="112" y="11" width="239" height="13" uuid="d18bd33c-028a-4cae-8748-e0f5b12faff5"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{fullName}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="112" y="24" width="239" height="13" uuid="242e9491-3e9b-450c-bbb8-bf7565e67fa6"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="112" y="37" width="239" height="13" uuid="efe7b9b3-7573-411a-bada-620939ada8dc"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{dateOfBirth}]]></textFieldExpression>
                        </textField>
                        <componentElement>
                            <reportElement key="NajdenaOsobaTable1" style="table 3" stretchType="RelativeToBandHeight" mode="Transparent" x="96" y="66" width="645" height="25" isPrintWhenDetailOverflows="true" uuid="99480409-009b-4f75-b435-ad99403ddb56"/>
                            <jr:table whenNoDataType="AllSectionsNoDetail">
                                <datasetRun subDataset="CompanyDataset" uuid="cc9ac018-67f1-4011-995c-d95cd30b8ce3">
                                    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/subreport/person/companies/company")]]></dataSourceExpression>
                                </datasetRun>
                                <jr:column width="125" uuid="db854a2c-d49e-46ae-a57b-38be7cd8e7f8">
                                    <jr:tableHeader style="table 3_TH" height="17" rowSpan="1">
                                        <staticText>
                                            <reportElement mode="Opaque" x="0" y="0" width="125" height="17" backcolor="#C0C0C0" uuid="8ef76d08-af87-4e3b-9436-2f9863275e50"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" isBold="false" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <text><![CDATA[Name of Company]]></text>
                                        </staticText>
                                    </jr:tableHeader>
                                    <jr:detailCell style="table 3_TD" height="16" rowSpan="1">
                                        <textField isBlankWhenNull="true">
                                            <reportElement x="0" y="0" width="125" height="16" isPrintWhenDetailOverflows="true" uuid="d1bcdf70-4494-4552-9c84-2c1acf29d5fa"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <textFieldExpression><![CDATA[$F{nameOfCompany}]]></textFieldExpression>
                                        </textField>
                                    </jr:detailCell>
                                </jr:column>
                                <jr:column width="160" uuid="db2c69c2-67ce-4de0-b8fc-4f24b969127f">
                                    <jr:tableHeader style="table 3_TH" height="17" rowSpan="1">
                                        <staticText>
                                            <reportElement mode="Opaque" x="0" y="0" width="160" height="17" backcolor="#C0C0C0" uuid="80f738f8-58c1-4959-b441-b1a3424e6bd6"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <text><![CDATA[Address of Company]]></text>
                                        </staticText>
                                    </jr:tableHeader>
                                    <jr:detailCell style="table 3_TD" height="16" rowSpan="1">
                                        <textField isBlankWhenNull="true">
                                            <reportElement x="0" y="0" width="160" height="16" isPrintWhenDetailOverflows="true" uuid="6351ecdf-eb49-4738-bb51-dee451c5761b"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <textFieldExpression><![CDATA[$F{addressOfCompany}]]></textFieldExpression>
                                        </textField>
                                    </jr:detailCell>
                                </jr:column>
                            </jr:table>
                        </componentElement>
                    </jr:listContents>
                </jr:list>
            </componentElement>
            <textField>
                <reportElement x="12" y="10" width="100" height="20" uuid="a8753122-9817-4500-81f2-99d703df00b8"/>
                <textFieldExpression><![CDATA[$F{nameOfState}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

И вот что я получаю в качестве итогового отчета (серая линия - разрыв страницы):

enter image description here

Это изображение, как выглядит инспектор отчетов в моем iReport Designer

enter image description here

Так что я использую только полосу детализации в этомвложенный отчет.

РЕДАКТИРОВАТЬ: Список необходим, потому что данные из разных стран, и этот jrxml представляет вложенный отчет, который вложен в основной отчет.

1 Ответ

2 голосов
/ 08 октября 2019

Это все о правильном определении вашего subDataset (со связанными полями) и запроса XPath в subDataSource. Общей индикацией будет запрос вниз к узлу, а затем генерирование subDatasource с возвратом на один узел.

Решение в этом случае состоит в том, чтобы сначала запросить детальный диапазон (основной запрос XPath отчета)

<queryString language="XPath">
    <![CDATA[/report/subreport]]>
</queryString>

Таким образом, в детальной полосе вы получаете доступ к первым полям nameOfState.

Тогда

В детальной полосе, пока мы "работаем"«на узле subreport мы добавляем jr:list компонент, subDataSource будет /subreport/persons/person для доступа к полям dateOfBirth, fullName и т. д.

<datasetRun subDataset="PersonsDataset" uuid="c0d23173-9df2-452c-9d97-78dee6f766ef">
    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/subreport/persons/person")]]></dataSourceExpression>
</datasetRun>

, а затем мына узле, так что для jr:table ваш запрос /person/companies/company

<datasetRun subDataset="CompanyDataset" uuid="cc9ac018-67f1-4011-995c-d95cd30b8ce3">
    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/person/companies/company")]]></dataSourceExpression>
</datasetRun>

Для определения subDataset и поля смотрите полный пример, это более просто, так как вы создаете источник данных (subDatasource)Запрос XPath на самом деле не нужен для набора данных subDataset (он необходим только для основного запроса), вам нужно только правильно указать поле с такими же именами, что и у тегов xml.

Full jrxml

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1_subreport1" pageWidth="756" pageHeight="140" whenNoDataType="BlankPage" columnWidth="756" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Error" isIgnorePagination="true" uuid="0a5fd60a-c7ea-46b7-a1e6-484cdedee54a">
    <style name="table 3">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_TH" mode="Opaque">
        <box>
            <pen lineWidth="0.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_CH" mode="Opaque" backcolor="#FFD0BF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="PersonsDataset" uuid="cf4c2515-8d53-4c2a-a6ca-d33257aa8e74">
        <field name="dateOfBirth" class="java.lang.String">
            <fieldDescription><![CDATA[dateOfBirth]]></fieldDescription>
        </field>
        <field name="fullName" class="java.lang.String">
            <fieldDescription><![CDATA[fullName]]></fieldDescription>
        </field>
        <field name="address" class="java.lang.String">
            <fieldDescription><![CDATA[address]]></fieldDescription>
        </field>
    </subDataset>
    <subDataset name="CompanyDataset" uuid="80440d3f-8de3-4fe7-8d02-62734435d23d">
        <field name="nameOfCompany" class="java.lang.String">
            <fieldDescription><![CDATA[nameOfCompany]]></fieldDescription>
        </field>
        <field name="addressOfCompany" class="java.lang.String">
            <fieldDescription><![CDATA[addressOfCompany]]></fieldDescription>
        </field>
    </subDataset>
    <queryString language="xPath">
        <![CDATA[/report/subreport]]>
    </queryString>
    <field name="nameOfState" class="java.lang.String">
        <property name="net.sf.jasperreports.xpath.field.expression" value="nameOfState"/>
        <fieldDescription><![CDATA[nameOfState]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="140" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="36" width="753" height="104" uuid="e417d0a1-9945-42e9-b12b-8bf0573c93ba"/>
                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                    <datasetRun subDataset="PersonsDataset" uuid="c0d23173-9df2-452c-9d97-78dee6f766ef">
                        <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/subreport/persons/person")]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="104" width="753">
                        <staticText>
                            <reportElement mode="Opaque" x="11" y="11" width="100" height="13" backcolor="#C0C0C0" uuid="21b820ed-d7eb-4c92-a1c7-8b60880bb3b6"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <text><![CDATA[Full name]]></text>
                        </staticText>
                        <staticText>
                            <reportElement mode="Opaque" x="11" y="24" width="100" height="13" backcolor="#C0C0C0" uuid="1b637cc8-c654-4734-9ee8-debc404931a2"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <text><![CDATA[Address:]]></text>
                        </staticText>
                        <staticText>
                            <reportElement mode="Opaque" x="11" y="37" width="100" height="13" backcolor="#C0C0C0" uuid="08dc2de1-652a-4cd5-b572-344dbadb3b91"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <text><![CDATA[Date of birth:]]></text>
                        </staticText>
                        <textField>
                            <reportElement x="112" y="11" width="239" height="13" uuid="d18bd33c-028a-4cae-8748-e0f5b12faff5"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{fullName}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="112" y="24" width="239" height="13" uuid="242e9491-3e9b-450c-bbb8-bf7565e67fa6"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="112" y="37" width="239" height="13" uuid="efe7b9b3-7573-411a-bada-620939ada8dc"/>
                            <box leftPadding="2">
                                <topPen lineWidth="0.75"/>
                                <leftPen lineWidth="0.75"/>
                                <bottomPen lineWidth="0.75"/>
                                <rightPen lineWidth="0.75"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font size="8" pdfEncoding="Cp1250"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{dateOfBirth}]]></textFieldExpression>
                        </textField>
                        <componentElement>
                            <reportElement key="NajdenaOsobaTable1" style="table 3" stretchType="RelativeToBandHeight" mode="Transparent" x="96" y="66" width="645" height="25" isPrintWhenDetailOverflows="true" uuid="99480409-009b-4f75-b435-ad99403ddb56"/>
                            <jr:table whenNoDataType="AllSectionsNoDetail">
                                <datasetRun subDataset="CompanyDataset" uuid="cc9ac018-67f1-4011-995c-d95cd30b8ce3">
                                    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/person/companies/company")]]></dataSourceExpression>
                                </datasetRun>
                                <jr:column width="125" uuid="db854a2c-d49e-46ae-a57b-38be7cd8e7f8">
                                    <jr:tableHeader style="table 3_TH" height="17" rowSpan="1">
                                        <staticText>
                                            <reportElement mode="Opaque" x="0" y="0" width="125" height="17" backcolor="#C0C0C0" uuid="8ef76d08-af87-4e3b-9436-2f9863275e50"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" isBold="false" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <text><![CDATA[Name of Company]]></text>
                                        </staticText>
                                    </jr:tableHeader>
                                    <jr:detailCell style="table 3_TD" height="16" rowSpan="1">
                                        <textField isBlankWhenNull="true">
                                            <reportElement x="0" y="0" width="125" height="16" isPrintWhenDetailOverflows="true" uuid="d1bcdf70-4494-4552-9c84-2c1acf29d5fa"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <textFieldExpression><![CDATA[$F{nameOfCompany}]]></textFieldExpression>
                                        </textField>
                                    </jr:detailCell>
                                </jr:column>
                                <jr:column width="160" uuid="db2c69c2-67ce-4de0-b8fc-4f24b969127f">
                                    <jr:tableHeader style="table 3_TH" height="17" rowSpan="1">
                                        <staticText>
                                            <reportElement mode="Opaque" x="0" y="0" width="160" height="17" backcolor="#C0C0C0" uuid="80f738f8-58c1-4959-b441-b1a3424e6bd6"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <text><![CDATA[Address of Company]]></text>
                                        </staticText>
                                    </jr:tableHeader>
                                    <jr:detailCell style="table 3_TD" height="16" rowSpan="1">
                                        <textField isBlankWhenNull="true">
                                            <reportElement x="0" y="0" width="160" height="16" isPrintWhenDetailOverflows="true" uuid="6351ecdf-eb49-4738-bb51-dee451c5761b"/>
                                            <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                                <pen lineWidth="0.75"/>
                                                <topPen lineWidth="0.75"/>
                                                <leftPen lineWidth="0.75"/>
                                                <bottomPen lineWidth="0.75"/>
                                                <rightPen lineWidth="0.75"/>
                                            </box>
                                            <textElement textAlignment="Center" verticalAlignment="Middle">
                                                <font fontName="Arial" size="8" pdfEncoding="Cp1250"/>
                                            </textElement>
                                            <textFieldExpression><![CDATA[$F{addressOfCompany}]]></textFieldExpression>
                                        </textField>
                                    </jr:detailCell>
                                </jr:column>
                            </jr:table>
                        </componentElement>
                    </jr:listContents>
                </jr:list>
            </componentElement>
            <textField>
                <reportElement x="12" y="10" width="100" height="20" uuid="a8753122-9817-4500-81f2-99d703df00b8"/>
                <textFieldExpression><![CDATA[$F{nameOfState}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

Результат

output

...