Ejemplo n.º 1
0
  public void xlsx() throws JRException {
    long start = System.currentTimeMillis();
    File sourceFile = new File("build/reports/JRMDbReport.jrprint");

    JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile);

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");

    JRXlsxExporter exporter = new JRXlsxExporter();

    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
    SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
    configuration.setOnePagePerSheet(false);
    exporter.setConfiguration(configuration);

    exporter.exportReport();

    System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
  }
Ejemplo n.º 2
0
  public void xlsx() throws JRException {
    long start = System.currentTimeMillis();
    File sourceFile = new File(TMP_DIR + ALL_CHARTS_REPORT_JRPRINT);
    Map<String, String> dateFormats = new HashMap<String, String>();
    dateFormats.put("EEE, MMM d, yyyy", "ddd, mmm d, yyyy");
    JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(sourceFile);
    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");

    JRXlsxExporter exporter = new JRXlsxExporter();

    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
    SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
    configuration.setOnePagePerSheet(true);
    configuration.setDetectCellType(true);
    configuration.setFormatPatternsMap(dateFormats);
    exporter.setConfiguration(configuration);

    exporter.exportReport();

    System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
  }