Bug 50298

Summary: Exception in HSSFWorkbook.write()
Product: POI Reporter: akira yokoi <yokoi>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: critical    
Priority: P1    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: normally output file
error java code
error xls file

Description akira yokoi 2010-11-19 02:56:00 UTC
version:poi-3.7-20101029.jar

I made the book with five sheets.
The following error goes out when the first sheet remove and output. 

// remove first sheet
workbook.removeSheetAt( 0);

It is normally output if it doesn't remove sheet. (attached file). 


Exception in thread "main" org.bbreak.excella.core.exception.ExportException: java.lang.IllegalArgumentException: calculated end index (15392) is out of allowable range (15388..15390)
	at org.bbreak.excella.reports.exporter.XLSExporter.output(XLSExporter.java:77)
	at org.bbreak.excella.reports.exporter.ExcelExporter.output(ExcelExporter.java:79)
	at org.bbreak.excella.reports.exporter.ReportBookExporter.export(ReportBookExporter.java:96)
	at org.bbreak.excella.reports.processor.ReportProcessor.processBook(ReportProcessor.java:215)
	at org.bbreak.excella.reports.processor.ReportProcessor.process(ReportProcessor.java:110)
	at org.bbreak.excella.reports.samples.InvoiceReporter.main(InvoiceReporter.java:132)
Caused by: java.lang.IllegalArgumentException: calculated end index (15392) is out of allowable range (15388..15390)
	at org.apache.poi.util.LittleEndianByteArrayOutputStream.<init>(LittleEndianByteArrayOutputStream.java:41)
	at org.apache.poi.hssf.record.StandardRecord.serialize(StandardRecord.java:38)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook$SheetRecordCollector.serialize(HSSFWorkbook.java:1209)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1258)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1158)
	at org.bbreak.excella.core.util.PoiUtil.writeBook(PoiUtil.java:355)
	at org.bbreak.excella.reports.exporter.XLSExporter.output(XLSExporter.java:75)
	... 5 more
Comment 1 akira yokoi 2010-11-19 03:02:10 UTC
Created attachment 26315 [details]
normally output file
Comment 2 Yegor Kozlov 2010-11-19 08:36:39 UTC
Please post the complete Java code to reproduce the problem. If your code requires an .xls template then upload it too.

Yegor
Comment 3 akira yokoi 2010-11-19 10:00:41 UTC
Created attachment 26319 [details]
error java code
Comment 4 akira yokoi 2010-11-19 10:01:00 UTC
Created attachment 26320 [details]
error xls file
Comment 5 akira yokoi 2010-11-19 10:01:58 UTC
The error java code and xls file attached.
Comment 6 hier.sur.apres.demain 2011-04-13 23:17:47 UTC
This bug does not reproduce in version 3.6.
Comment 7 Dominik Stadler 2013-08-21 22:22:01 UTC
We finally found the culprit here in the way the setSheetOrder() was handled internally. It missed to update some internal structures thus confusing the calculation of the serialization-sizes. Should be fixed in 3.10 in r1516313.