简体   繁体   中英

Jasper API prints only first report other reports are printed as blank

We are using jasper API (JasperFillManager.fillReport,JasperExportManager.exportReportToPdfFile)

We want to execute that report in the loop with different parameters, so added following code

    JasperPrint jasperPrint = null;
            // Fill report
            Iterator i1 = l1.iterator();
            Iterator i2 = l2.iterator();
            int i = 1;
            while (i1.hasNext() && i2.hasNext()) {
                parameters.put("SUBJECTOID", (String) i1.next());
                parameters.put("HISTORYRECORD", (String) i2.next());
                try (ProfilePoint fillReport = ProfilePoint
                        .profileAction("ProfAction_ReportHelper_fillJasperReport")) {
                    jasperReport = JasperCompileManager.compileReport(jrxmlPath);

                    jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, emptyDataSource);
                    System.out.println("fillReport**********" + i);

                }

                // Export to PDF
                try (ProfilePoint exportReport = ProfilePoint
                        .profileAction("ProfAction_ReportHelper_exportJasperReport")) {
                    JasperExportManager.exportReportToPdfFile(jasperPrint,
                            "C:\\JASPER\\JASPEROUTPUT\\Report" + i + ".pdf");
                    System.out.println("exportReportToPdfFile**********" + i);
                }
                i++;
                jasperPrint = null;
                jasperReport = null;

So what happens we have 15 Parameteres , so 15 PDF files gets generated , but only first PDF file contains data, other 14 are blank.

We tried multiple things such as compiling once , compiling multiple times, extracted jasper code to method but still outcome is the same

Is there any cache or some kind of setting in jasper or similar something?

Thanks @ dada67 for suggestion it worked

I have passed new emptydatasource for each iteration and it worked.

Thanks a lot..!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM