iReport table with additional record repeating for each row

匿名 (未验证) 提交于 2019-12-03 02:31:01

问题:

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 could give me a hint?

回答1:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!