JavaBean包含一個java.util.List。如何將此清單的資料顯示在 JasperReports 文件的 Detail 區域中?
// Java source to generate the report ... // DataSource using JRBeanCollectionDataSource private static JRDataSource getDataSource() { Collection<BeanWithList> coll = ...; return new JRBeanCollectionDataSource(coll); } // JavaBean public class BeanWithList { private List<String> cities; // ... // Ensure a public getter for field extraction public List<String> getCities() { return this.cities; } } // jrxml file ... // Subdataset for iterating through the list <subDataset name="dataset1"> <field name="city" class="java.lang.String"> <fieldDescription><![CDATA[_THIS]]></fieldDescription> </field> </subDataset> // Detail band with jr:list component <detail> ... <componentElement> <!-- jr:list component --> <jr:list ...> <datasetRun subDataset="dataset1"> <!-- DataSource expression using JRBeanCollectionDataSource --> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{cities})]]></dataSourceExpression> </datasetRun> <jr:listContents ...> <textField ...> <textFieldExpression><![CDATA[$F{city}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> ... </detail> ...
此設定會產生一個報告,顯示 詳細資料
範圍內的清單資料。 其他資訊以上是如何在 JasperReports 的詳細資料區域中顯示 JavaBean 清單?的詳細內容。更多資訊請關注PHP中文網其他相關文章!