Search in sources :

Example 16 with SimpleExporterInput

use of net.sf.jasperreports.export.SimpleExporterInput in project tutorials by eugenp.

the class SimpleReportExporter method exportToHtml.

public void exportToHtml(String fileName) {
    HtmlExporter exporter = new HtmlExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleHtmlExporterOutput(fileName));
    try {
        exporter.exportReport();
    } catch (JRException ex) {
        Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : SimpleHtmlExporterOutput(net.sf.jasperreports.export.SimpleHtmlExporterOutput) HtmlExporter(net.sf.jasperreports.engine.export.HtmlExporter) JRException(net.sf.jasperreports.engine.JRException) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput)

Example 17 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)17 SimpleOutputStreamExporterOutput (net.sf.jasperreports.export.SimpleOutputStreamExporterOutput)12 JRException (net.sf.jasperreports.engine.JRException)7 JRXlsExporter (net.sf.jasperreports.engine.export.JRXlsExporter)6 SimpleWriterExporterOutput (net.sf.jasperreports.export.SimpleWriterExporterOutput)5 SimpleXlsReportConfiguration (net.sf.jasperreports.export.SimpleXlsReportConfiguration)5 JasperPrint (net.sf.jasperreports.engine.JasperPrint)4 JRCsvExporter (net.sf.jasperreports.engine.export.JRCsvExporter)4 FileOutputStream (java.io.FileOutputStream)3 HashMap (java.util.HashMap)3 JasperReport (net.sf.jasperreports.engine.JasperReport)3 JRPdfExporter (net.sf.jasperreports.engine.export.JRPdfExporter)3 JRRtfExporter (net.sf.jasperreports.engine.export.JRRtfExporter)3 JROdtExporter (net.sf.jasperreports.engine.export.oasis.JROdtExporter)3 JRDocxExporter (net.sf.jasperreports.engine.export.ooxml.JRDocxExporter)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 JRMapCollectionDataSource (net.sf.jasperreports.engine.data.JRMapCollectionDataSource)2 JRPptxExporter (net.sf.jasperreports.engine.export.ooxml.JRPptxExporter)2