user3633580
user3633580

Reputation: 93

Exporting a XLS with +80.000 records

I'm trying to export a XLS file with +80.000 and I'm getting "net.sf.jasperreports.engine.JRException: The cell cannot be added".

I tried to upper the "MAXIMUM_ROWS_PER_SHEET" but it didn't worked.

This is my code:

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;

Can anybody help me?

Upvotes: 2

Views: 386

Answers (1)

sanluck
sanluck

Reputation: 1554

I think trouble is not in the export. MAXIMUM_ROWS_PER_SHEET can't help you too.
XLS can't contain more than 65,536 rows. Try to use XLSX.
See this answer from Superuser.

Upvotes: 2

Related Questions