poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44539] New: Formula cell and area references with rows >= 32768 do not work
Date Wed, 05 Mar 2008 14:01:21 GMT

           Summary: Formula cell and area references with rows >= 32768 do
                    not work
           Product: POI
           Version: 3.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: richard.evans@datanomic.com

This is for 3.0.2 FINAL.

AreaPtg and similar objects store row numbers as _shorts_ even though row
offsets may range from 0-65535.  Various things do not work for row offsets >=

For example:

1. When HSSFFormulaEvaluator handles a cell reference it does:

            else if (ptgs[i] instanceof ReferencePtg) {
                ReferencePtg ptg = (ReferencePtg) ptgs[i];
                short colnum = ptg.getColumn();
                short rownum = ptg.getRow();
                HSSFRow row = sheet.getRow(rownum);
                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                pushRef2DEval(ptg, stack, cell, row, sheet, workbook);

if the row is 32768 the short value is -32768 and you get:

java.lang.IndexOutOfBoundsException: Row number must be between 0 and 65535,
was <-32768>
        at org.apache.poi.hssf.usermodel.HSSFRow.setRowNum(HSSFRow.java:211)
        at org.apache.poi.hssf.usermodel.HSSFSheet.getRow(HSSFSheet.java:330)

2. An expression involving a range, such as SUM(A32769:A32770) fails because
AreaPtg passes the signed values into CellReference and you get an error like:

java.lang.RuntimeException: Cannot Parse, sorry : Found reference to named
range "A", but that named range wasn't defined! @ 6 [Formula String was:

HSSFFormulaEvaluator uses shorts in a number of places to represent row numbers
so there are a lot of things that would exhibit this problem.

Trivial XLS attached which demonstrates the second example.

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message