Failed to display multiple row in report eventhough the <textField> is place in <Detail><band>. What is wrong with below?
xmlData.xml
--------------------
<?xml version="1.0" ?>
<Data>
<CustomerName>Peter</CustomerName>
<CustomerID>0001</CustomerID>
<AccountReport>
<Accounts>
<Account>
<Row>
<RowNo>1</RowNo>
<AccNumber>123456</AccNumber>
<AccName>Account1</AccName>
</Row>
<Row>
<RowNo>1</RowNo>
<AccNumber>345678</AccNumber>
<AccName>Account2</AccName>
</Row>
</Account>
<Account>
<Row>
<RowNo>2</RowNo>
<AccNumber>112233</AccNumber>
<AccName>MyAccount</AccName>
</Row>
<Row>
<RowNo>2</RowNo>
<AccNumber>223344</AccNumber>
<AccName>MyAccount2</AccName>
</Row>
</Account>
</Accounts>
</AccountReport>
</Data>
java file
-------------------
File file = new File("report.jrxml");
FileInputStream template = new FileInputStream(file);
JasperDesign design = JRXmlLoader.load(template);
JasperReport report = JasperCompileManager.compileReport(design);
File datafile = new File("xmlData.xml");
JRXmlDataSource ds = new JRXmlDataSource(datafile, "/Data");
JasperPrint print = JasperFillManager.fillReport(report, null, ds);
byte[] pdf = JasperExportManager.exportReportToPdf(print);
JRXml
-----------------
<queryString language="xPath">
<![CDATA[/Data]]>
</queryString>
<field name="RowNo" class="java.lang.String">
<fieldDescription><![CDATA[AccountReport/Accounts/Account/Row/RowNo]]></fieldDescription>
</field>
<field name="AccNumber" class="java.lang.String">
<fieldDescription><![CDATA[AccountReport/Accounts/Account/Row/AccNumber]]></fieldDescription>
</field>
<field name="AccName" class="java.lang.String">
<fieldDescription><![CDATA[AccountReport/Accounts/Account/Row/AccName]]></fieldDescription>
</field>
......
<detail>
<band height="80" splitType="Stretch">
<textField>
<reportElement x="1" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{RowNo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="101" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{AccNumber}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="201" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{AccName}]]></textFieldExpression>
</textField>
</band>
</detail>
Final Report
----------------------------------
1 123456 Account1
Final Report (Expected)
-----------------------------------
1 123456 Account1
1 345678 Account2
2 112233 MyAccount
2 223344 MyAccount2
Kindly help for this. Thank you.
0 Answers:
No answers yet