iReport table with additional record repeating for each row

前端 未结 1 1119
一生所求
一生所求 2021-01-20 00:05

I searched all over the Internet and also on this forum but i can\'t find a way to achieve something like the table below. I\'m using iReport 4.7.1.

Please

相关标签:
1条回答
  • 2021-01-20 01:02

    It is quite easy. You should add the textField element to the Detail band below the textFields with fields.

    Here is a sample.

    The report design in iReport:

    The report's design in iReport

    The jrxml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport ..>
        <queryString>
            <![CDATA[SELECT id, street, city FROM ADDRESS]]>
        </queryString>
        <field name="ID" class="java.lang.Integer"/>
        <field name="STREET" class="java.lang.String"/>
        <field name="CITY" class="java.lang.String"/>
        <columnHeader>
            <band height="20" splitType="Stretch">
                <staticText>
                    <reportElement x="0" y="0" width="100" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font isBold="true" isItalic="true"/>
                    </textElement>
                    <text><![CDATA[Id]]></text>
                </staticText>
                <staticText>
                    <reportElement x="100" y="0" width="100" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font isBold="true" isItalic="true"/>
                    </textElement>
                    <text><![CDATA[City]]></text>
                </staticText>
                <staticText>
                    <reportElement x="200" y="0" width="100" height="20"/>
                    <box>
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font isBold="true" isItalic="true"/>
                    </textElement>
                    <text><![CDATA[Street]]></text>
                </staticText>
            </band>
        </columnHeader>
        <detail>
            <band height="40" splitType="Stretch">
                <textField>
                    <reportElement x="0" y="0" width="100" height="20"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="100" y="0" width="100" height="20"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{CITY}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="200" y="0" width="100" height="20"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{STREET}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="0" y="20" width="300" height="20"/>
                    <box leftPadding="10">
                        <topPen lineWidth="1.0"/>
                        <leftPen lineWidth="1.0"/>
                        <bottomPen lineWidth="1.0"/>
                        <rightPen lineWidth="1.0"/>
                    </box>
                    <textElement/>
                    <textFieldExpression><![CDATA["Details about row " + $V{REPORT_COUNT}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
    </jasperReport>
    

    The result will be:

    The result in iReport via preview

    0 讨论(0)
提交回复
热议问题