2016-08-15 36 views
2

我试图用+80.000导出一个XLS文件,我得到了“net.sf.jasperreports.engine.JRException:单元格无法添加”。导出带有+80.000记录的XLS

我试图超出“MAXIMUM_ROWS_PER_SHEET”,但它没有奏效。

这是我的代码:

ByteArrayOutputStream out = new ByteArrayOutputStream(); 
try { 
    JasperReport relatorioJasper = (JasperReport) JRLoader.loadObjectFromFile(parametros.get("REPORT_JASPER")+""); 

    JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(listaReport); 
    JasperPrint jasperPrint = JasperFillManager.fillReport(relatorioJasper, parametros, dataSource); 

    JRXlsExporter exporter = new JRXlsExporter(); 
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); 
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out)); 
    SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); 
    configuration.setOnePagePerSheet(false); 
    configuration.setDetectCellType(true); 
    configuration.setCollapseRowSpan(false); 
    configuration.setRemoveEmptySpaceBetweenColumns(true); 
    // exporter.setParameter(JRXlsExporterParameter.MAXIMUM_ROWS_PER_SHEET, 10000); 

    exporter.setConfiguration(configuration); 
    exporter.exportReport(); 


    InputStream relatorios = new ByteArrayInputStream(out.toByteArray()); 
    return stream2file(relatorios, parametros.get("REPORT_NAME")+"" ,Constantes.XLS); 
}catch(Exception e){ 
    e.printStackTrace(); 
} 
return null; 

任何人可以帮助我吗?

+2

你可以发布完整的堆栈跟踪文章 –

+0

@ user3633580你可以尝试使用附加的* JasperReports *库源代码来调试代码。您可以在新JRException(EXCEPTION_MESSAGE_KEY_CANNOT_ADD_CELL)引发的地方设置断点,例如在* JExcelApiExporter *类中,在这种情况下,您可以捕获异常的第三方库(POI或JExcelApi)的原因 –

+0

感谢您的提示,但它只是改变XLS到XLSX – user3633580

回答

1

我觉得麻烦不在出口。 MAXIMUM_ROWS_PER_SHEET也无法帮助您。
XLS不能包含超过65,536行。尝试使用XLSX
this answer from Superuser

+0

这是不同版本的poi限制https://poi.apache.org/apidocs/org/apache/poi/ss/SpreadsheetVersion.html –

+0

谢谢!它的工作。 – user3633580

+0

你是欢迎!) – sanluck