public void docx() 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() + ".docx");

    JRDocxExporter exporter = new JRDocxExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());

    exporter.exportReport();

    System.err.println("DOCX creation time : " + (System.currentTimeMillis() - start));
  }
コード例 #2
0
  public void docx() 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() + ".docx");

    JRDocxExporter exporter = new JRDocxExporter();

    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));

    exporter.exportReport();

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