Search in sources :

Example 6 with SimpleExporterInput

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();
    }
}
Also used : SimpleXlsReportConfiguration(net.sf.jasperreports.export.SimpleXlsReportConfiguration) JRXlsExporter(net.sf.jasperreports.engine.export.JRXlsExporter) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) JRPdfExporter(net.sf.jasperreports.engine.export.JRPdfExporter)

Aggregations

SimpleExporterInput (net.sf.jasperreports.export.SimpleExporterInput)6 SimpleOutputStreamExporterOutput (net.sf.jasperreports.export.SimpleOutputStreamExporterOutput)4 JRException (net.sf.jasperreports.engine.JRException)3 JRCsvExporter (net.sf.jasperreports.engine.export.JRCsvExporter)3 JRXlsExporter (net.sf.jasperreports.engine.export.JRXlsExporter)3 SimpleWriterExporterOutput (net.sf.jasperreports.export.SimpleWriterExporterOutput)3 File (java.io.File)2 JRPdfExporter (net.sf.jasperreports.engine.export.JRPdfExporter)2 JRRtfExporter (net.sf.jasperreports.engine.export.JRRtfExporter)2 JROdtExporter (net.sf.jasperreports.engine.export.oasis.JROdtExporter)2 JRDocxExporter (net.sf.jasperreports.engine.export.ooxml.JRDocxExporter)2 SimpleXlsReportConfiguration (net.sf.jasperreports.export.SimpleXlsReportConfiguration)2 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 TbSysJreport (com.netsteadfast.greenstep.po.hbm.TbSysJreport)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Connection (java.sql.Connection)1 ParseException (java.text.ParseException)1 ExecutionException (java.util.concurrent.ExecutionException)1