Search in sources :

Example 11 with SimpleExporterInput

use of net.sf.jasperreports.export.SimpleExporterInput in project java-examples by urvanov-ru.

the class App method generateReport.

public static void generateReport() throws JRException, IOException {
    JasperDesign jasperDesign = createDesign();
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
    JRDataSource jrDataSource = prepareDataSource();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("startDate", new Date());
    params.put("endDate", new Date());
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, jrDataSource);
    try (FileOutputStream baos = new FileOutputStream("dynamicReport.xls")) {
        JRXlsExporter xlsExporter = new JRXlsExporter();
        xlsExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
        xlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos));
        SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
        configuration.setOnePagePerSheet(false);
        xlsExporter.setConfiguration(configuration);
        xlsExporter.exportReport();
    }
}
Also used : SimpleXlsReportConfiguration(net.sf.jasperreports.export.SimpleXlsReportConfiguration) JasperDesign(net.sf.jasperreports.engine.design.JasperDesign) HashMap(java.util.HashMap) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JRDataSource(net.sf.jasperreports.engine.JRDataSource) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) JasperReport(net.sf.jasperreports.engine.JasperReport) Date(java.util.Date) JRXlsExporter(net.sf.jasperreports.engine.export.JRXlsExporter) FileOutputStream(java.io.FileOutputStream)

Example 12 with SimpleExporterInput

use of net.sf.jasperreports.export.SimpleExporterInput in project archi by archimatetool.

the class JasperReportsExporter method exportRTF.

void exportRTF(JasperPrint jasperPrint, File file) throws JRException {
    JRRtfExporter exporter = new JRRtfExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleWriterExporterOutput(file));
    exporter.exportReport();
}
Also used : SimpleWriterExporterOutput(net.sf.jasperreports.export.SimpleWriterExporterOutput) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) JRRtfExporter(net.sf.jasperreports.engine.export.JRRtfExporter)

Example 13 with SimpleExporterInput

use of net.sf.jasperreports.export.SimpleExporterInput in project archi by archimatetool.

the class JasperReportsExporter method exportPPT.

void exportPPT(JasperPrint jasperPrint, File file) throws JRException {
    JRPptxExporter exporter = new JRPptxExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
    exporter.exportReport();
}
Also used : JRPptxExporter(net.sf.jasperreports.engine.export.ooxml.JRPptxExporter) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput)

Example 14 with SimpleExporterInput

use of net.sf.jasperreports.export.SimpleExporterInput in project archi by archimatetool.

the class JasperReportsExporter method exportODT.

void exportODT(JasperPrint jasperPrint, File file) throws JRException {
    JROdtExporter exporter = new JROdtExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(file));
    exporter.exportReport();
}
Also used : JROdtExporter(net.sf.jasperreports.engine.export.oasis.JROdtExporter) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput)

Example 15 with SimpleExporterInput

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

the class SimpleReportExporter method exportToXlsx.

public void exportToXlsx(String fileName, String sheetName) {
    JRXlsxExporter exporter = new JRXlsxExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(fileName));
    SimpleXlsxReportConfiguration reportConfig = new SimpleXlsxReportConfiguration();
    reportConfig.setSheetNames(new String[] { sheetName });
    exporter.setConfiguration(reportConfig);
    try {
        exporter.exportReport();
    } catch (JRException ex) {
        Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : JRException(net.sf.jasperreports.engine.JRException) SimpleOutputStreamExporterOutput(net.sf.jasperreports.export.SimpleOutputStreamExporterOutput) SimpleExporterInput(net.sf.jasperreports.export.SimpleExporterInput) SimpleXlsxReportConfiguration(net.sf.jasperreports.export.SimpleXlsxReportConfiguration) JRXlsxExporter(net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter)

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