0
我正在與JasperReports並試圖做一個報告Excel。重疊和垃圾單元格在我的報告與JasperReports
當我試圖讓報告出色,我看到一個可怕的報告,單元格不在正確的位置,有很多拆分單元格。
我想這個問題是在一個列表領域,具有以下屬性:
Position Type: Fix Relative to Top
Stretch Type: Relative to band height
而且現場的鄰居有以下特性:
Position Type: Fix Relative to Top
Stretch Type: Relative to Tallest object
我得到以下外觀:
釷是沒錯,但是當我拿到的Excel報告中,我得到如下:
我不知道如何解決它。
這是在Excel格式中生成報告的代碼。
public boolean exportarAExcel(){
ServletOutputStream servletOutputStream = null;
try {
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
ServletContext servletContext = (ServletContext) externalContext.getContext();
String reportPath = servletContext.getRealPath("/rpt/" +this.nombreReporteJasper);
JasperPrint jasperPrint= JasperFillManager.fillReport(reportPath,this.parametros,
new JRBeanCollectionDataSource(this.dataSource));
HttpServletResponse httpServletResponse =
(HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
httpServletResponse.setContentType("application/xlsx");
httpServletResponse.addHeader("Content-disposition", "attachment; filename=\""+this.nombreSalida+".xlsx\"");
servletOutputStream = httpServletResponse.getOutputStream();
JRXlsxExporter excelExporter=new JRXlsxExporter();
excelExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
excelExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, servletOutputStream);
excelExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
excelExporter.setParameter(JRXlsExporterParameter.IS_FONT_SIZE_FIX_ENABLED, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
excelExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
excelExporter.exportReport();
servletOutputStream.flush();
servletOutputStream.close();
FacesContext.getCurrentInstance().responseComplete();
return true;
} catch (JRException ex) {
Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex);
return false;
} catch (IOException ex) {
Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
任何人都可以幫助我嗎?