Combining two Jasper reports

前端 未结 5 1657
迷失自我
迷失自我 2020-11-30 07:15

I have a web application with a dropdown from where user could select the type of report viz. report1, report2, report3, etc.

Based on the report selected, a Jasper

5条回答
  •  春和景丽
    2020-11-30 07:48

    This answer is to help user using latest version of Jasper-Report. In @Sangram Jadhav accept answer the JRExporterParameter.JASPER_PRINT_LIST is deprecated

    The current code would be:

    Map paramMap = new HashMap();
    List jasperPrintList = new ArrayList();
    JasperPrint jasperPrint1 = JasperFillManager.fillReport(report1, paramMap);
    jasperPrintList.add(jasperPrint1);
    JasperPrint jasperPrint2 = JasperFillManager.fillReport(report2, paramMap);
    jasperPrintList.add(jasperPrint2);
    
    JRPdfExporter exporter = new JRPdfExporter();
    exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList)); //Set as export input my list with JasperPrint s
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("pdf/output.pdf")); //or any other out streaam
    SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
    configuration.setCreatingBatchModeBookmarks(true); //add this so your bookmarks work, you may set other parameters
    exporter.setConfiguration(configuration);
    exporter.exportReport();
    

提交回复
热议问题