Hi all,
I have two tables to be printed in same page. Data for those tables will be supplied from a map from a custom data source. I need to implement it. I Google for implementing this task.
At that time i came across sub-reports concept. but didnt get much tutorial for how to implement sub-reports.
I have a idea of how to create sub-reports. but i dont know how to fill sub reports with customdatasource. Thats my question. Pls help me in achieving.
Thanks in advance
Note: Hi guys, i tried to implement subreports. but i am getting error. here is the code i used for compiling subreports.
JasperPrint print=new JasperPrint();
JRPdfExporter exporter=new JRPdfExporter();
JasperDesign design,design1;
JasperReport report,report1;
JasperReport jasperReport;
JasperDesign jd1;
jd1 = JRXmlLoader.load("D:\\sub_report1.jrxml");
jasperReport = JasperCompileManager.compileReport(jd1);
Map parameters = new HashMap();
parameters.put("ReportTitle", "Table Report");
parameters.put("DataFile", "TableSource.java");
parameters.put("Subreport_1", jasperReport);
design= JRXmlLoader.load("D:\\sub_report2.jrxml");
report=JasperCompileManager.compileReport(design);
parameters.put("Subreport_2", report);
design1=JRXmlLoader.load("D:\\master_report.jrxml");
report1=JasperCompileManager.compileReport(design1);
JasperFillManager.fillReportToFile(report1,"D:\\master_report.jrprint",parameters, new TableDataSource());
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "D:K\\Report.pdf");
exporter.exportReport();
JasperViewer.viewReport(print);
Here i have compiled subreport1 & subreport2 individually and added them as a parameter in map. then i m getting error while filling it through masterreports. pls help me to compile the report
Stack trace of compiler error :
Exception in thread "main" net.sf.jasperreports.engine.JRRuntimeException: Unkown print order 0. at net.sf.jasperreports.engine.fill.JRFillSubreport.initSubreportFiller(Unknown Source) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(Unknown Source) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(Unknown Source) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(Unknown Source) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(Unknown Source) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(Unknown Source) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(Unknown Source) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(Unknown Source) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(Unknown Source) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(Unknown Source) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(Unknown Source) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(Unknown Source) at net.sf.jasperreports.engine.JasperFillManager.fillReport(Unknown Source) at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(Unknown Source) at ReportTableCompiler.main(ReportTableCompiler.java:53)