/** * Export to RTF * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toRtf() throws JRException { JRRtfExporter jrRtfExporter = new JRRtfExporter(); jrRtfExporter.setExporterInput(new SimpleExporterInput(this.report)); jrRtfExporter.setExporterOutput(new SimpleWriterExporterOutput(new File(getTemplatePath().replace(extensionPattern, "rtf")))); jrRtfExporter.exportReport(); return this; }
ExporterInput exporterInput = SimpleExporterInput.getInstance(printList); exporter.setExporterInput(exporterInput);
/** * <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; } }
/** * Export to XHTML * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toXhtml() throws JRException { HtmlExporter htmlExporter = new HtmlExporter(); htmlExporter.setExporterInput(new SimpleExporterInput(this.report)); htmlExporter.setExporterOutput(new SimpleHtmlExporterOutput(new File(getTemplatePath().replace(extensionPattern, "html")))); htmlExporter.exportReport(); return this; }
/** * Export to EXCEL * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toExcel() throws JRException { JRXlsxExporter jrXlsxExporter = new JRXlsxExporter(); jrXlsxExporter.setExporterInput(new SimpleExporterInput(this.report)); jrXlsxExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new File(getTemplatePath().replace(extensionPattern, "xlsx")))); jrXlsxExporter.exportReport(); return this; }
/** * Export to TXT * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toText() throws JRException { JRTextExporter jrTextExporter = new JRTextExporter(); jrTextExporter.setExporterInput(new SimpleExporterInput(this.report)); jrTextExporter.setExporterOutput(new SimpleWriterExporterOutput(new File(getTemplatePath().replace(extensionPattern, "txt")))); jrTextExporter.exportReport(); return this; }
/** * Export to XLS * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toXls() throws JRException { JRXlsExporter jrXlsExporter = new JRXlsExporter(); jrXlsExporter.setExporterInput(new SimpleExporterInput(this.report)); jrXlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new File(getTemplatePath().replace(extensionPattern, "xls")))); jrXlsExporter.exportReport(); return this; }
/** * Export to XLSX * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toXlsx() throws JRException { JRXlsxExporter jrXlsxExporter = new JRXlsxExporter(); jrXlsxExporter.setExporterInput(new SimpleExporterInput(this.report)); jrXlsxExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new File(getTemplatePath().replace(extensionPattern, "xls")))); jrXlsxExporter.exportReport(); return this; }
/** * Export to CSV * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toCsv() throws JRException { JRCsvExporter jasperCsvExporter = new JRCsvExporter(); jasperCsvExporter.setExporterInput(new SimpleExporterInput(this.report)); jasperCsvExporter.setExporterOutput(new SimpleWriterExporterOutput(new File(getTemplatePath().replace(extensionPattern, "csv")))); jasperCsvExporter.exportReport(); return this; }
/** * Export to DOCX * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toDocx() throws JRException { JRDocxExporter jrDocxExporter = new JRDocxExporter(); jrDocxExporter.setExporterInput(new SimpleExporterInput(this.report)); jrDocxExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new File(getTemplatePath().replace(extensionPattern, "docx")))); jrDocxExporter.exportReport(); return this; }
/** * Export to ODS * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toOds() throws JRException { JROdsExporter jrOdsExporter = new JROdsExporter(); jrOdsExporter.setExporterInput(new SimpleExporterInput(this.report)); jrOdsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new File(getTemplatePath().replace(extensionPattern, "ods")))); jrOdsExporter.exportReport(); return this; }
@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(); }
@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(); }
/** * Export to PNG * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception * @throws IOException IOException exception */ public SpecificTemplateExporterBuilderService toPng() throws JRException, IOException { BufferedImage pageImage = new BufferedImage(this.report.getPageWidth() + 1, this.report.getPageHeight() + 1, BufferedImage.TYPE_INT_RGB); JRGraphics2DExporter exporter = new JRGraphics2DExporter(); exporter.setExporterInput(new SimpleExporterInput(this.report)); SimpleGraphics2DExporterOutput exporterOutput = new SimpleGraphics2DExporterOutput(); exporterOutput.setGraphics2D((Graphics2D) pageImage.getGraphics()); exporter.setExporterOutput(exporterOutput); exporter.exportReport(); ImageIO.write(pageImage, "png", new FileOutputStream(new File(getTemplatePath().replace(extensionPattern, "png")))); 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.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; }
public static void exportReportXls(JasperPrint jp, String path, SimpleXlsReportConfiguration configuration) throws JRException, FileNotFoundException { JRXlsExporter exporter = new JRXlsExporter(); File outputFile = new File(path); File parentFile = outputFile.getParentFile(); if (parentFile != null) parentFile.mkdirs(); FileOutputStream fos = new FileOutputStream(outputFile); exporter.setConfiguration(configuration); SimpleExporterInput simpleExporterInput = new SimpleExporterInput(jp); OutputStreamExporterOutput simpleOutputStreamExporterOutput = new SimpleOutputStreamExporterOutput(fos); exporter.setExporterInput(simpleExporterInput); exporter.setExporterOutput(simpleOutputStreamExporterOutput); exporter.exportReport(); logger.debug("Xlsx Report exported: " + path); }
/** * The path to the file must exist. * * @param jp * @param path * @throws JRException * @throws FileNotFoundException */ public static void exportReport(JasperPrint jp, String path) throws JRException, FileNotFoundException { logger.debug("Exporing report to: " + path); JRPdfExporter exporter = new JRPdfExporter(); File outputFile = new File(path); File parentFile = outputFile.getParentFile(); if (parentFile != null) parentFile.mkdirs(); FileOutputStream fos = new FileOutputStream(outputFile); SimpleExporterInput simpleExporterInput = new SimpleExporterInput(jp); OutputStreamExporterOutput simpleOutputStreamExporterOutput = new SimpleOutputStreamExporterOutput(fos); exporter.setExporterInput(simpleExporterInput); exporter.setExporterOutput(simpleOutputStreamExporterOutput); exporter.exportReport(); logger.debug("Report exported: " + path); }
public static void exportReportHtml(JasperPrint jp, String path) throws JRException, FileNotFoundException { HtmlExporter exporter = new HtmlExporter(); File outputFile = new File(path); File parentFile = outputFile.getParentFile(); if (parentFile != null) parentFile.mkdirs(); FileOutputStream fos = new FileOutputStream(outputFile); SimpleExporterInput simpleExporterInput = new SimpleExporterInput(jp); SimpleHtmlExporterOutput simpleOutputStreamExporterOutput = new SimpleHtmlExporterOutput(fos); exporter.setExporterInput(simpleExporterInput); exporter.setExporterOutput(simpleOutputStreamExporterOutput); SimpleHtmlExporterConfiguration configuration = new SimpleHtmlExporterConfiguration(); exporter.setConfiguration(configuration); exporter.exportReport(); logger.debug("HTML Report exported: " + path); }
@Override public StreamedContent processReport() throws Exception { beforeProcess(); JasperPrint jasperPrint = processaDadosJasper(); if (jasperPrint == null) { JavaScriptUtils.showMessageHeaderWarning(BundleUtils.messageBundle("message.naoExisteDadosImpressao")); return null; } if (typeReport() == FileType.PDF) { File arquivoPdfGeracao = File.createTempFile(fileName(), ".pdf"); InputStream pdfStream = new FileInputStream(arquivoPdfGeracao.getAbsolutePath()); JasperExportManager.exportReportToPdfFile(jasperPrint, arquivoPdfGeracao.getAbsolutePath()); return new DefaultStreamedContent(pdfStream, "application/pdf", fileName() + ".pdf"); } else if (typeReport() == FileType.EXCEL) { File arquivoPdfGeracao = File.createTempFile(fileName(), ".xlsx"); OutputStream outputStream = new FileOutputStream(arquivoPdfGeracao.getAbsolutePath()); JRXlsExporter exporter = new JRXlsExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream)); SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); configuration.setOnePagePerSheet(true); configuration.setDetectCellType(true); configuration.setCollapseRowSpan(false); exporter.setConfiguration(configuration); exporter.exportReport(); InputStream pdfStream = new FileInputStream(arquivoPdfGeracao.getAbsolutePath()); return new DefaultStreamedContent(pdfStream, FileType.EXCEL.getContentType(), fileName() + ".xlsx"); } return null; }
exporter.setExporterInput( new SimpleExporterInput( jasperPrint ) ); exporter.setExporterOutput( new SimpleOutputStreamExporterOutput( out ) ); exporter.setConfiguration( config ); exporter.setExporterInput( new SimpleExporterInput( jasperPrint ) ); exporter.setExporterOutput( new SimpleOutputStreamExporterOutput( out ) ); exporter.exportReport();