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

http://issues.apache.org/bugzilla/show_bug.cgi?id=39970

           Summary: ArrayIndexOutOfBoundsException when opening EXCEL file
           Product: POI
           Version: 2.5
          Platform: All
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P5
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


ArrayIndexOutOfBoundsException Occured when opening EXCEL file that contains 
values in such a way that some values span to other columns but some doesn't 
span to other columns is display.

The error stacktrace is-

java.lang.reflect.InvocationTargetException: 
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at org.apache.poi.hssf.record.UnknownRecord.<init>
(UnknownRecord.java:62)
        at org.apache.poi.hssf.record.SubRecord.createSubRecord
(SubRecord.java:57)
        at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
        at org.apache.poi.hssf.record.Record.fillFields(Record.java(Compiled 
Code))
        at org.apache.poi.hssf.record.Record.<init>(Record.java(Compiled Code))
        at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java(Compiled Code))
        at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java(Compiled Code))
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:163)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:210)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:191)
        at com.mastercard.mcideas.atmdir.util.ExcelUtil.openWorkBook
(ExcelUtil.java:263)
        at com.mastercard.mcideas.atmdir.util.ExcelUtil.TestReadingWorkBook
(ExcelUtil.java:399)
        at com.mastercard.mcideas.atmdir.util.ExcelUtil.main
(ExcelUtil.java:318)

The problem is with System.arrayCopy() method call in UnknownRecord class. A 
fix can be applied to this problem as follows (By making sure the array 
doesn't go beyond limits)


 public UnknownRecord( short id, short size, byte[] data, int offset )
    {
        sid     = id;
        thedata = new byte[size];
        
        if((data.length - offset) < size)
                size = (short)(data.length - offset);
        
        
        System.arraycopy(data, offset, thedata, 0, size);
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to