use of net.sf.jasperreports.export.SimpleExporterInput in project dhis2-core by dhis2.
the class JRExportUtils method export.
/**
* Export the provided JasperPrint the format given by type.
*
* @param type the type to export to. XLS, PDF and HTML are supported.
* @param out the OutputStream to export to.
* @param jasperPrint the JasperPrint to export.
* @throws JRException on export failure.
*/
public static void export(String type, OutputStream out, JasperPrint jasperPrint) throws JRException {
if (TYPE_XLS.equals(type)) {
SimpleXlsReportConfiguration config = new SimpleXlsReportConfiguration();
config.setDetectCellType(true);
config.setRemoveEmptySpaceBetweenRows(true);
config.setRemoveEmptySpaceBetweenRows(true);
config.setCollapseRowSpan(true);
config.setWhitePageBackground(false);
JRXlsExporter exporter = new JRXlsExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out));
exporter.setConfiguration(config);
exporter.exportReport();
} else if (TYPE_PDF.equals(type)) {
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out));
exporter.exportReport();
}
}
Aggregations