poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dennis Doubleday" <den...@righthandmanager.com>
Subject Regression in HSSFName.getReference()?
Date Tue, 17 Dec 2002 15:16:42 GMT
I have a method in my code that begins:

    protected void setNamedCellValue(HSSFWorkbook book,
                                     HSSFSheet    sheet,
                                     String       name,
                                     Object       value,
                                     HSSFCellStyle cellStyle) {

        // Find the index of the name.
        int namedRefIndex = book.getNameIndex(name);

        if (namedRefIndex == -1) {
            // No such name.
            if (logger.isLoggable(Level.WARNING)) {
                logger.warning("No cell name '" + name +
                               "' found in workbook");
            }
            
        } else {
            // Get the name object and the associated cell reference.
            HSSFName namedRef = book.getNameAt(namedRefIndex);
            CellReference cellRef = new
CellReference(namedRef.getReference());

The method worked well for named cells when I was using a build that was
"jakarta-poi-1.9.0-dev-20021112 + 2 patches that I made" :-) Since those
patches got committed, I decided to upgrade to a new nightly (Dec.
12th.) However, then I got this exception from the last line above:

java.lang.IndexOutOfBoundsException: Index: -2, Size: 13 	
at java.util.ArrayList.RangeCheck ArrayList.java:508) 	
at java.util.ArrayList.get(ArrayList.java:320) 	
at org.apache.poi.hssf.model.Workbook.getSheetName(Workbook.java:460) 	
at
org.apache.poi.hssf.model.Workbook.findSheetNameFromExternSheet(Workbook
.java:1693) 	
at
org.apache.poi.hssf.model.Workbook.getSheetReferences(Workbook.java:1678
) 	
at
org.apache.poi.hssf.usermodel.HSSFName.getReference(HSSFName.java:142) 	
at
com.righthandmanager.marginmetrix.spendmetrix.io.ExcelAnalysisExporter.s
etNamedCellValue(ExcelAnalysisExporter.java:299)

Going back to my original jar file resolves the problem. Seems there has
been a regression, but I can't imagine where it is. HSSFName hasn't
changed and none of the recent changes to Workbook would seem to have
any effect on this (though I don't really understand the RecalcId
changes.)

Just thought I would see if it rang a bell with anyone before I try to
figure it out.


Mime
View raw message