Hello All,
My Query returns two Objects
List query = session.createQuery("from Obj1, Obj2 <where clause>");
I have two objects Say: Object1 and Obectj2 (beans)
In JRXML
<field name = "field1" class = "java.lang.Integer"> <field name = "field2" class = "java.lang.Integer">
How to tell Jasper Reports that field1 belongs to the Object1 and field2 belongs to Object2.
Code:
Collection dataSource = new ArrayList(); dataSource.add(Obj1); dataSource.add(Obj2); JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(dataSource);
JasperReport jasperReport = JasperCompileManager.compileReport(new java.io.FileInputStream(new java.io.File("Reports/Report.xml"))); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,ds); JasperExportManager.exportReportToPdfStream(jasperPrint, new java.io.FileOutputStream(new java.io.File("Report.pdf"))); System.out.println("Report Generated");
|