exporter.setExporterInput(exporterInput); exporter.setExporterOutput(exporterOutput); exporter.setConfiguration(exporterConfiguration); exporter.setConfiguration(reportConfiguration); exporter.exportReport(); Flushables.flushQuietly(output); return output.toByteArray();
@SuppressWarnings("unchecked") protected void printReport(JasperReport report) throws JRException { JRDataSource dataSource = new JRBandDataDataSource(rootBand); Map<String, Object> params = new HashMap<>(); params.put(CUBA_PARAM, new CubaJRFunction(dataSource)); JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, dataSource); Exporter exporter = createExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.exportReport(); }
if (ReportOutputType.pdf == outputType) { exporter = new JRPdfExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.setConfiguration(new SimplePdfExporterConfiguration()); } else if (ReportOutputType.html == outputType) { exporter = new HtmlExporter(); exporter.setExporterOutput(new SimpleHtmlExporterOutput(outputStream)); exporter.setConfiguration(new SimpleHtmlExporterConfiguration()); } else if (ReportOutputType.csv == outputType){ exporter = new JRCsvExporter(); exporter.setExporterOutput(new SimpleWriterExporterOutput(outputStream)); SimpleCsvExporterConfiguration config = new SimpleCsvExporterConfiguration(); config.setFieldDelimiter(CSV_DELIMETER); exporter.setConfiguration(config); } else if (ReportOutputType.doc == outputType ){ exporter = new JRRtfExporter(); exporter.setExporterOutput(new SimpleWriterExporterOutput(outputStream)); exporter.setConfiguration(new SimpleRtfExporterConfiguration()); } else if (ReportOutputType.docx == outputType){ exporter = new JRDocxExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.setConfiguration(new SimpleDocxExporterConfiguration()); } else if (ReportOutputType.xls == outputType){ exporter = new JRXlsExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.setConfiguration(new SimpleXlsExporterConfiguration()); } else if (ReportOutputType.xlsx == outputType){ exporter = new JRXlsxExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));
exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); ExporterOutput output = writerOutput ? new SimpleWriterExporterOutput(destinationFileName) : new SimpleOutputStreamExporterOutput(destinationFileName); exporter.setExporterOutput(output); return exporter;
Exporter exporter = createExporter(reportType.getExport(), jasperPrint, destinationFileName); if (exporter != null) { exporter.exportReport();
@SuppressWarnings("unchecked") protected void printReport(JasperReport report) throws JRException { JRDataSource dataSource = new JRBandDataDataSource(rootBand); Map<String, Object> params = new HashMap<>(); params.put(CUBA_PARAM, new CubaJRFunction(dataSource)); JasperPrint jasperPrint = JasperFillManager.fillReport(report, params, dataSource); Exporter exporter = createExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.exportReport(); }
if (ReportOutputType.pdf == outputType) { exporter = new JRPdfExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.setConfiguration(new SimplePdfExporterConfiguration()); } else if (ReportOutputType.html == outputType) { exporter = new HtmlExporter(); exporter.setExporterOutput(new SimpleHtmlExporterOutput(outputStream)); exporter.setConfiguration(new SimpleHtmlExporterConfiguration()); } else if (ReportOutputType.csv == outputType){ exporter = new JRCsvExporter(); exporter.setExporterOutput(new SimpleWriterExporterOutput(outputStream)); SimpleCsvExporterConfiguration config = new SimpleCsvExporterConfiguration(); config.setFieldDelimiter(CSV_DELIMETER); exporter.setConfiguration(config); } else if (ReportOutputType.doc == outputType ){ exporter = new JRRtfExporter(); exporter.setExporterOutput(new SimpleWriterExporterOutput(outputStream)); exporter.setConfiguration(new SimpleRtfExporterConfiguration()); } else if (ReportOutputType.docx == outputType){ exporter = new JRDocxExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.setConfiguration(new SimpleDocxExporterConfiguration()); } else if (ReportOutputType.xls == outputType){ exporter = new JRXlsExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); exporter.setConfiguration(new SimpleXlsExporterConfiguration()); } else if (ReportOutputType.xlsx == outputType){ exporter = new JRXlsxExporter(); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));
/** * <p>export.</p> * * @param exporterBuilder a {@link net.sf.dynamicreports.jasper.builder.export.AbstractJasperExporterBuilder} object. * @return a {@link net.sf.dynamicreports.jasper.builder.JasperReportBuilder} object. * @throws net.sf.dynamicreports.report.exception.DRException if any. */ public JasperReportBuilder export(AbstractJasperExporterBuilder<?, ? extends AbstractJasperExporter> exporterBuilder) throws DRException { Validate.notNull(exporterBuilder, "exporterBuilder must not be null"); try { ExporterTransform exporterTransform = new ExporterTransform(exporterBuilder.build()); @SuppressWarnings("unchecked") Exporter<ExporterInput, ?, ?, ?> exporter = (Exporter<ExporterInput, ?, ?, ?>) exporterTransform.transform(); exporter.setExporterInput(new SimpleExporterInput(toJasperPrint())); exporter.exportReport(); } catch (JRException e) { throw new DRException(e); } return this; }
/** * <p>export.</p> * * @param exporterBuilder a {@link net.sf.dynamicreports.jasper.builder.export.AbstractJasperExporterBuilder} object. * @return a {@link net.sf.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder} object. * @throws net.sf.dynamicreports.report.exception.DRException if any. */ public JasperConcatenatedReportBuilder export(AbstractJasperExporterBuilder<?, ? extends AbstractJasperExporter> exporterBuilder) throws DRException { Validate.notNull(exporterBuilder, "exporterBuilder must not be null"); try { ExporterTransform exporterTransform = new ExporterTransform(exporterBuilder.build()); @SuppressWarnings("unchecked") Exporter<ExporterInput, ?, ?, ?> exporter = (Exporter<ExporterInput, ?, ?, ?>) exporterTransform.transform(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperReportHandler.getPrintList())); exporter.exportReport(); } catch (JRException e) { throw new DRException(e); } return this; } }