I know how to generate jasper report without any subreport. But currently I have a subreport in my report and I would like to know how can I compile that subreport in java?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can compile the subreport like the simple report – with help of JasperCompileManager.compileReport(java.lang.String sourceFileName) method, for example.
After that you can pass the compiled subreport as parameter to the master report.
The sample:
The snippet from the master report’s jrxml file (sample):
Notes
I mentioned an old API for generating result:
JasperFillManager.fillReportToFile(JasperReport, String, Map,
java.sql.Connection)
In case using JasperReports 6.x it is better to use exporters (concrete implementation of net.sf.jasperreports.export.Exporter interface, for example JRPdfExporter) for generating output file
The example how to use Exporter right can be found here