Bug 50298 - Exception in HSSFWorkbook.write()
Summary: Exception in HSSFWorkbook.write()
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC All
: P1 critical with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-11-19 02:56 UTC by akira yokoi
Modified: 2013-08-21 22:22 UTC (History)
0 users

normally output file (20.00 KB, application/vnd.ms-excel)
2010-11-19 03:02 UTC, akira yokoi
error java code (905 bytes, application/octet-stream)
2010-11-19 10:00 UTC, akira yokoi
error xls file (20.00 KB, application/vnd.ms-excel)
2010-11-19 10:01 UTC, akira yokoi

Note You need to log in before you can comment on or make changes to this bug.
Description akira yokoi 2010-11-19 02:56:00 UTC

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.

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.