Bug 44167 - ArrayIndexOutOfBoundsException when using Named Ranges
Summary: ArrayIndexOutOfBoundsException when using Named Ranges
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-01-04 05:08 UTC by Martin Allerstorfer
Modified: 2008-01-08 03:42 UTC (History)
0 users

test file (14.00 KB, application/octet-stream)
2008-01-04 07:47 UTC, Martin Allerstorfer
Patch to fix the bug 44167 : named ranges (13.42 KB, patch)
2008-01-08 02:25 UTC, Paolo Mottadelli
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.<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

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 3 Martin Allerstorfer 2008-01-04 07:47:35 UTC
Created attachment 21344 [details]
test file
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
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
For how to work with your non-contiguous ranges