Bug 50096 - Wrong cell value in XSSF when evaluating formula in a cell with index > 255
Summary: Wrong cell value in XSSF when evaluating formula in a cell with index > 255
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.7-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-10-15 02:49 UTC by Martin Studer
Modified: 2010-11-10 11:11 UTC (History)
0 users

Excel file for bug reproduction (12.10 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2010-10-15 02:50 UTC, Martin Studer

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Studer 2010-10-15 02:49:03 UTC
Cells in a row with an index > 255 that contain formulas may be evaluated wrongly.

The specific case can be seen in the attached Excel file (repro.xlsx). There are two rows. The first row simply contains the numbers 1 - 300. The second row simply refers to the cell value above in the first row by a simple formula.

When evaluating the cell values (using the FormulaEvaluator) you get wrong cell values for cells in the second row if they have an index > 255.

The following code demonstrates the problem:

Workbook wb = WorkbookFactory.create(new FileInputStream("repro.xlsx"));
        FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();

        for(int i = 245; i < 265; i++) {
            Cell cell_noformula = wb.getSheetAt(0).getRow(0).getCell(i);
            Cell cell_formula = wb.getSheetAt(0).getRow(1).getCell(i);

            CellValue cv_noformula = evaluator.evaluate(cell_noformula);
            CellValue cv_formula = evaluator.evaluate(cell_formula);
            System.out.println("Cell " + i + ": no formula = " + cv_noformula.getNumberValue() + ", formula = " + cv_formula.getNumberValue());

OS: Windows 7
POI: 3.7-beta3
Java: 1.6.0_20 64-bit
Comment 1 Martin Studer 2010-10-15 02:50:34 UTC
Created attachment 26177 [details]
Excel file for bug reproduction
Comment 2 Yegor Kozlov 2010-11-10 11:11:09 UTC
Fixed in r1033556, junit added.