@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; }
public ReportExportConfiguration getReportConfiguration() { reportConfiguration.setIgnoreGraphics(Boolean.FALSE); reportConfiguration.setCollapseRowSpan(Boolean.FALSE); reportConfiguration.setDetectCellType(Boolean.TRUE); reportConfiguration.setFontSizeFixEnabled(Boolean.TRUE); reportConfiguration.setRemoveEmptySpaceBetweenColumns(Boolean.FALSE); reportConfiguration.setRemoveEmptySpaceBetweenRows(Boolean.FALSE); reportConfiguration.setIgnoreCellBorder(Boolean.FALSE); reportConfiguration.setImageBorderFixEnabled(Boolean.FALSE); reportConfiguration.setShowGridLines(Boolean.FALSE); reportConfiguration.setIgnoreCellBackground(Boolean.FALSE); reportConfiguration.setWrapText(Boolean.FALSE); reportConfiguration.setOnePagePerSheet(Boolean.TRUE); reportConfiguration.setColumnWidthRatio(1.25f); return reportConfiguration; }
config.setRemoveEmptySpaceBetweenRows( true ); config.setRemoveEmptySpaceBetweenRows( true ); config.setCollapseRowSpan( true ); config.setWhitePageBackground( false );