You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2003/02/24 08:17:33 UTC

DO NOT REPLY [Bug 17329] New: - removeMergedRegion() throws IndexOutOfBoundsException

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17329>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17329

removeMergedRegion() throws IndexOutOfBoundsException

           Summary: removeMergedRegion() throws IndexOutOfBoundsException
           Product: POI
           Version: 1.5.1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: stefan.proels@gmx.de


HSSFSheet.removeMergedRegion() throws an IndexOutOfBoundsException. The document
I'm testing contains 2 merged regions. The following code is supposed to remove
them all. However, when trying to remove the second region it throw the
exception. This is the test program:

-----------------------------------
import java.io.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.usermodel.*;

public class Test {

  public static void main(String[] args)
    throws Exception
  {
    FileInputStream in = new FileInputStream("example.xls");
    POIFSFileSystem fs = new POIFSFileSystem(in);
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    HSSFSheet sheet = wb.getSheetAt(0);
    int numRegions = sheet.getNumMergedRegions();
    for (int i = 0; i < numRegions; i++) {
      System.out.println("removing region " + sheet.getMergedRegionAt(0));
      sheet.removeMergedRegion(0);
    }
  }
}
-----------------------------------

and here is what happens:

-----------------------------------
removing region org.apache.poi.hssf.util.Region@3eca90
removing region org.apache.poi.hssf.util.Region@64dc11
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 95, Size: 36
        at java.util.ArrayList.RangeCheck(ArrayList.java:508)
        at java.util.ArrayList.remove(ArrayList.java:388)
        at org.apache.poi.hssf.model.Sheet.removeMergedRegion(Sheet.java:342)
        at
org.apache.poi.hssf.usermodel.HSSFSheet.removeMergedRegion(HSSFSheet.java:502)
        at Test.main(Test.java:17)
-----------------------------------

The problem occured to me with POI versions 1.5.1 and 1.9.0.