Bug 27005

Summary: java.lang.IndexOutOfBoundsException during Workbook.cloneSheet()
Product: POI Reporter: Sergey Skalchihin <skalchihin>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Windows XP   

Description Sergey Skalchihin 2004-02-17 12:52:20 UTC
code:
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("blank.xls"));
Workbook wb = new HSSFWorkbook(fs);
System.out.println(wb.getSheetName(0)); // result Ok -> Sheet1
HSSFSheet cc = wb.cloneSheet(0);
FileOutputStream fileOut = new FileOutputStream(n);
wb.write(fileOut);
// EXCEPTION :
//java.lang.IndexOutOfBoundsException: Index: 9, Size: 9
//        at java.util.ArrayList.RangeCheck(ArrayList.java:507)
//        at java.util.ArrayList.get(ArrayList.java:324)
//        at org.apache.poi.hssf.record.MergeCellsRecord.getAreaAt
//(MergeCellsRecord.java:201)
//        at org.apache.poi.hssf.record.MergeCellsRecord.serialize
//(MergeCellsRecord.java:227)
//        at org.apache.poi.hssf.model.Sheet.serialize(Sheet.java:787)
//        at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes
//(HSSFWorkbook.java:797)
//        at org.apache.poi.hssf.usermodel.HSSFWorkbook.write
//(HSSFWorkbook.java:742)
//        at ExcelReportMaker.close(ExcelReportMaker.java:43)
fileOut.close();
Comment 1 Danny Mui 2004-02-17 16:03:39 UTC
We're going to need more detail...like the blank.xls file you used.  I just
tried this code with version 2.0 FINAL and it worked ok. 
Comment 2 Sergey Skalchihin 2004-02-18 06:44:36 UTC
java.lang.IndexOutOfBoundsException is throws if "blank.xls" file consist 
merged cells.
Comment 3 Danny Mui 2004-02-18 16:49:09 UTC
Removed variable that stores the number of merged regions in 
its record since the array should be the basis for this number.  Less
manual index tracking, the better.

Thanks for problem report!

Should be released shortly in a development/production release but is now
available in CVS.