Reputation: 149
Here I am trying to provide the datasource from my Java program to jasper file.
Here is my code:
InputStream reportStream = new FileInputStream("C:/Documents and Settings/report2.jrxml");
JRDataSource datasource = new JRBeanCollectionDataSource(allEnergy_Caliberation, true);
JasperReport report = JasperCompileManager.compileReport(reportStream);
System.out.println("above error");
JasperPrint print = JasperFillManager.fillReport(report, parameters, datasource);
I need to pass the datasource in report and wanna print its values.
Similarly in the same jrxml file in Summary section I have added the subreport and I also need to provide values for this subreport also.
Please help me out by providing the steps.
Upvotes: 1
Views: 3975
Reputation: 149
Finally I have done it..
Actually datasourse was not going in subreport.. so I have changed the property of when no data to all sections,no data...
Then I have passed the collection variable where I have fetched the subreport records...by using parameters.put("shape_data_all",allShape_Caliberation);
Then I have created a parameter in main report.. and changed its class to java.Util.Collection
..
Then in subreport property, connection type= Use a datasource expression
Data Source Expression new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{shape_data_all})
Then added the fields in the subreport same as I have in the bean properties..
Upvotes: 2