JasperReports 5.6: JRXlsExporter.setParameter is deprecated

前端 未结 3 821
無奈伤痛
無奈伤痛 2020-12-07 18:31

I have this code to export a JasperReprot to XLS:

        JasperPrint jprint=JasperFillManager.fillReport(expRpg, null, new JRBeanCollectionDataSource(datali         


        
3条回答
  •  粉色の甜心
    2020-12-07 19:20

    Here is my CODE:

    String sourceFileName = "./jasper_report_template.jasper";
    Map parameters = new HashMap();
    String printFileName = null;
    try {
          printFileName = JasperFillManager.fillReportToFile(sourceFileName, parameters, beanArrayDataSource);
          if(printFileName != null){
               //JasperPrintManager.printReport( printFileName, true);
                /** 1- export to PDF*/
                JasperExportManager.exportReportToPdfFile(printFileName,
                          "C://Users/zanderkong/Desktop/sample_report.pdf");
                /**3- export to Excel sheet*/
                RXlsExporter xlsExporter = new JRXlsExporter();
                xlsExporter.setExporterInput(new SimpleExporterInput(printFileName));
                xlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput("C://Users/zanderkong/Desktop/sample_report.xls"));
                SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
                configuration.setOnePagePerSheet(true);
                configuration.setDetectCellType(true);
                configuration.setCollapseRowSpan(false);
                xlsExporter.setConfiguration(configuration);
                xlsExporter.exportReport();
             }
            } catch (JRException e) {
                 e.printStackTrace();
              }      
    

提交回复
热议问题