如何使用 XML 数据源在列表组件内创建 jasper table 和文本字段?

How to create a jasper table and textfields inside the list component with XML datasource?

我正在尝试使用 Jasper iReport Designer 5.6.0 生成报告,其中有一个包含 table 和一些文本字段的列表。生成的报告应如下所示:

为此,我使用以下 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>

这就是我得到的结果报告(灰线是分页符):

这是报表检查器在我的 iReport Designer 中的样子

所以我只在这个子报表中使用详细信息带。

编辑: List是必需的,因为数据来自多个国家,这个jrxml表示嵌套在主报表中的子报表。

这就是关于在 subDataSource 中正确定义 subDataset(带有相关字段)和 XPath 查询的全部内容。一般指示是向下查询到节点,然后生成子数据源后退一个节点。

这种情况下的解决方案是先查询明细带(报告的主要 XPath 查询)

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

通过这种方式,您可以详细访问第一个字段 nameOfState

然后

详细来说,当我们在节点 subreport 上 "running" 时,我们添加 jr:list 组件 subDataSource 将是 /subreport/persons/person 以访问字段 dateOfBirth , 全名等

<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>

对于子数据集和字段定义,请参阅完整示例,它更直接,因为您正在创建数据源(子数据源),子数据集实际上不需要 XPath 查询(仅在主查询中需要),您只需需要具有与 xml 标签同名的正确字段声明。

完整的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>

结果