poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dola Woolfe <dolac...@yahoo.com>
Subject getReference() exception
Date Mon, 09 Jan 2006 13:14:18 GMT
Hi,

We have the following code that attempts to get the
value of a named cell:

  public static Object getNamedValue(String name,
HSSFWorkbook wb, int sheetIndex) {
    HSSFSheet s = wb.getSheetAt(sheetIndex);

    for (int x = 0; x < wb.getNumberOfNames(); x++) {
      HSSFName n = wb.getNameAt(x);
      if (n.getNameName().equals(name) &&
n.getSheetName().equals(wb.getSheetName(sheetIndex)))
        return getValue(s, n.getReference());
    }
    return null;
  }

Is there a reason why the "n.getReference()" command
would throw the following exception:

java.lang.IndexOutOfBoundsException: Index: 8, Size: 2
at java.util.ArrayList.RangeCheck(ArrayList.java:546)
at java.util.ArrayList.get(ArrayList.java:321)
at
org.apache.poi.hssf.model.Workbook.getSheetName(Workbook.java:503)
at
org.apache.poi.hssf.model.Workbook.findSheetNameFromExternSheet(Workbook.java:1778)
at
org.apache.poi.hssf.model.Workbook.getSheetReferences(Workbook.java:1761)
at
org.apache.poi.hssf.record.formula.Ref3DPtg.toFormulaString(Ref3DPtg.java:160)
at
org.apache.poi.hssf.record.NameRecord.getAreaReference(NameRecord.java:677)
at
org.apache.poi.hssf.usermodel.HSSFName.getReference(HSSFName.java:87)
at
contrib.justin.OpenAndReadPA.jgbGetNamedValue(OpenAndReadPA.java:233)


Many thanks in advance!

Dola



		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Mime
View raw message