public void xlsx() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/DataSourceReport.jrprint"); JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx"); JRXlsxExporter exporter = new JRXlsxExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.exportReport(); System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start)); }
public void xlsx() throws JRException { long start = System.currentTimeMillis(); File sourceFile = new File("build/reports/FirstJasper.jrprint"); JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx"); Map dateFormats = new HashMap(); dateFormats.put("EEE, MMM d, yyyy", "ddd, mmm d, yyyy"); JRXlsxExporter exporter = new JRXlsxExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE); exporter.setParameter(JRXlsExporterParameter.FORMAT_PATTERNS_MAP, dateFormats); exporter.exportReport(); System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start)); }