|Summary:||ArrayIndexOutOfBoundsException when using Named Ranges|
|Product:||POI||Reporter:||Martin Allerstorfer <allerstorfer_martin>|
|Component:||HSSF||Assignee:||POI Developers List <dev>|
Patch to fix the bug 44167 : named ranges
Description Martin Allerstorfer 2008-01-04 05:08:16 UTC
Reading a named range consisting of one column (with for example rows from index 10 to 18) works fine if every row of this column is part of the named range. But if one or more rows of the column are not part of the named range (for example row index 15) then the following ArrayIndexOutOfBoundsException occurs: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at org.apache.poi.hssf.util.CellReference.separateRefParts(CellReference.java:116) at org.apache.poi.hssf.util.CellReference.<init>(CellReference.java:36) at org.apache.poi.hssf.util.AreaReference.<init>(AreaReference.java:34) at poitest.main(poitest.java:23)
Comment 1 Nick Burch 2008-01-04 05:27:24 UTC
Could you upload the problem file, and your java that triggers the problem (as a unit test if possible) Also, have you checked with poi 3.0.2 beta 1, as well as with 3.0.1 final?
Comment 2 Martin Allerstorfer 2008-01-04 07:46:04 UTC
I used the example of the Quick Guide http://poi.apache.org/hssf/quick-guide.html#NamedRanges I found out that the problem is the getReference() method of the class HSSFName which returns an empty string. This empty string results in the exception when used as parameter in the constructor of AreaReference. I used the attached file and the Named Range 'test'.
Comment 4 Martin Allerstorfer 2008-01-04 08:29:17 UTC
I tried it with version 8.0.2 beta 1 and 3.0.1 final without success.
Comment 5 Paolo Mottadelli 2008-01-08 02:25:42 UTC
Created attachment 21355 [details] Patch to fix the bug 44167 : named ranges References are read correctly and ranges are read as real stuff. attachment '21344' should be saved as src/testcases/org/apache/poi/hssf/data/44167.xls
Comment 6 Nick Burch 2008-01-08 02:37:06 UTC
Thanks for this patch Paolo. It does seem to have been quite a bit more tricky than it originally looked1 Patch applied
Comment 7 Nick Burch 2008-01-08 03:42:39 UTC
Martin - please see the updated docs at http://poi.apache.org/hssf/quick-guide.html#NamedRanges For how to work with your non-contiguous ranges