use of net.sf.jasperreports.export.Exporter in project midpoint by Evolveum.
the class ReportCreateTaskHandler method generateReport.
private String generateReport(ReportType reportType, JasperPrint jasperPrint) throws JRException {
String destinationFileName = getDestinationFileName(reportType);
switch(reportType.getExport()) {
case PDF:
JasperExportManager.exportReportToPdfFile(jasperPrint, destinationFileName);
break;
case XML:
JasperExportManager.exportReportToXmlFile(jasperPrint, destinationFileName, true);
break;
case XML_EMBED:
JasperExportManager.exportReportToXmlFile(jasperPrint, destinationFileName, true);
break;
case XHTML:
case HTML:
JasperExportManager.exportReportToHtmlFile(jasperPrint, destinationFileName);
break;
case CSV:
JRCsvExporter csvExporter = new JRCsvExporter();
csvExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
csvExporter.setExporterOutput(new SimpleWriterExporterOutput(destinationFileName));
csvExporter.exportReport();
break;
case RTF:
case XLS:
case ODT:
case ODS:
case DOCX:
case XLSX:
case PPTX:
case JXL:
ExporterInput input = new SimpleExporterInput(jasperPrint);
ExporterOutput output = new SimpleOutputStreamExporterOutput(destinationFileName);
Exporter exporter = createExporter(reportType.getExport());
if (exporter == null) {
break;
}
exporter.setExporterInput(input);
exporter.setExporterOutput(output);
exporter.exportReport();
break;
default:
break;
}
return destinationFileName;
}
Aggregations