Summary: | Exception occurs when deleting merged cells from cloned sheet | ||
---|---|---|---|
Product: | POI | Reporter: | Harry <huri> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.0-pre3 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP |
Description
Harry
2003-08-26 03:20:05 UTC
will correct for 2.0 Danny, is this still valid? Tested the problem scenario with RC1, it's better than before, but now there's a different bug: HSSFSheet template = workBook.getSheetAt(templateSheetIndex); HSSFSheet clone = workBook.cloneSheet(templateSheetIndex); // remove merged regions from clone for (int i=sheet.getNumMergedRegions()-1; i>=0; i--) { clone.removeMergedRegion(i); } // check if template's merged regions are OK if (template.getNumMergedRegions()>0) { // fetch the first merged region...EXCEPTION OCCURS HERE template.getMergedRegionAt(0); } This results in: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:508) at java.util.ArrayList.get(ArrayList.java:320) at org.apache.poi.hssf.record.MergeCellsRecord.getAreaAt (MergeCellsRecord.java:200) at org.apache.poi.hssf.model.Sheet.getMergedRegionAt(Sheet.java:543) at org.apache.poi.hssf.usermodel.HSSFSheet.getMergedRegionAt (HSSFSheet.java:585) From this test, the delete of cloned merged regions works. However, it appears that the original sheet's merged regions are also deleted. The template.getNumMergedRegions() returns the correct value (in my test spreadsheet there are 4 merged regions), but throws an Exception when getMergedRegionAt() is called to retrieve the regions. Thanks for the bug report, committed November 17. Should be in RC2 or Release (minor fix). I'm fixing another bug to detect overlapping merged regions (not allowed by Microsoft Excel), which breaks this unit test. I'm assuming that two merged regions are overlapping is coincidental/unintentional and doesn't change the meaning of this test if the addresses are changed. //Original code[1] template.addMergedRegion(new Region(0, (short)0, 1, (short)2)); template.addMergedRegion(new Region(1, (short)0, 2, (short)2)); //Latest code template.addMergedRegion(new CellRangeAddress(0, 1, 0, 2)); template.addMergedRegion(new CellRangeAddress(1, 2, 0, 2)); [1] https://svn.apache.org/viewvc/jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?revision=353586&view=markup&pathrev=353586#l374 [2] https://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?revision=1704124&view=markup#l140 |