Bug 50096

Summary: Wrong cell value in XSSF when evaluating formula in a cell with index > 255
Product: POI Reporter: Martin Studer <martin.studer>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.7-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Excel file for bug reproduction

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.

Yegor