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)
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?
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'.
Created attachment 21344 [details] test file
I tried it with version 8.0.2 beta 1 and 3.0.1 final without success.
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
Thanks for this patch Paolo. It does seem to have been quite a bit more tricky than it originally looked1 Patch applied
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