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=24207>.
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=24207

Call HSSFName.getReference() throwing java.lang.IndexOutOfBoundsException

           Summary: Call HSSFName.getReference() throwing
                    java.lang.IndexOutOfBoundsException
           Product: POI
           Version: unspecified
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: HSSF
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I am using the poi-1.8.0-dev package.

The following is a part of my program.

POIFSFileSystem fs      =
                                        new POIFSFileSystem(new FileInputStream
("C:\\Projects\\KPM\\POI Test\\xls\\SimpleForm.xls"));
                        
                        HSSFWorkbook wb = new HSSFWorkbook(fs);
                        HSSFSheet sheet = wb.getSheet("DataCollectionForm");
                        HSSFRow row = null;
                        HSSFCell cell = null;
                        HSSFName name = null;
                        CellReference ref = null;
                        int index = 0;
                        
                        /* Read a locked cell */
                        index = wb.getNameIndex("Form_4.1_01");
                        System.out.println("index = " + index);
                        System.out.println("count = " + wb.getNumberOfNames());
                        name = wb.getNameAt(index);
                        System.out.println("name = " + name.toString());
                        System.out.println("name's name = " + name.getNameName
());
                        System.out.println("name's sheet = " + name.getSheetName
());
                        System.out.println("ref = " + name.getReference());
                        ref = new CellReference(name.getReference().substring
(name.getReference().indexOf("!")+1));
                        row = sheet.getRow(ref.getRow());
                        cell = row.getCell((short)ref.getCol());
                        System.out.println("The value of Form_4.1_01 is  " + 
cell.getStringCellValue());

When calling name.getReference() function, the IndexOutOfBoundsException was 
thrown as the following:
java.lang.IndexOutOfBoundsException: Index: 8, Size: 6
        at java.util.ArrayList.RangeCheck(Unknown Source)
        at java.util.ArrayList.get(Unknown Source)
        at org.apache.poi.hssf.model.Workbook.getSheetName(Workbook.java:460)
        at org.apache.poi.hssf.model.Workbook.findSheetNameFromExternSheet
(Workbook.java:1693)
        at org.apache.poi.hssf.model.Workbook.getSheetReferences
(Workbook.java:1678)
        at org.apache.poi.hssf.usermodel.HSSFName.getReference
(HSSFName.java:142)
        at TestSimpleForm.main(TestSimpleForm.java:49)

I also found the error caused by field_2_index_to_first_supbook_sheet, inside 
in ExternSheetSubRecord, which is larger than arraylist's size.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to