diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index b0a09088e7..d2a6d64e3b 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 53101 - fixed evaluation of SUM over cell range > 255 49529 - avoid exception when cloning sheets with no drawing records and initialized drawing patriarch diff --git a/src/java/org/apache/poi/ss/formula/LazyAreaEval.java b/src/java/org/apache/poi/ss/formula/LazyAreaEval.java index 76f926879f..2a9f94391a 100644 --- a/src/java/org/apache/poi/ss/formula/LazyAreaEval.java +++ b/src/java/org/apache/poi/ss/formula/LazyAreaEval.java @@ -45,8 +45,8 @@ final class LazyAreaEval extends AreaEvalBase { public ValueEval getRelativeValue(int relativeRowIndex, int relativeColumnIndex) { - int rowIx = (relativeRowIndex + getFirstRow() ) & 0xFFFF; - int colIx = (relativeColumnIndex + getFirstColumn() ) & 0x00FF; + int rowIx = (relativeRowIndex + getFirstRow() ) ; + int colIx = (relativeColumnIndex + getFirstColumn() ) ; return _evaluator.getEvalForCell(rowIx, colIx); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index df88b4a905..4c55cca900 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -1317,4 +1317,26 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { } } + /** + * Bug 53101: + */ + public void test5301(){ + Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("53101.xlsx"); + FormulaEvaluator evaluator = + workbook.getCreationHelper().createFormulaEvaluator(); + // A1: SUM(B1: IZ1) + double a1Value = + evaluator.evaluate(workbook.getSheetAt(0).getRow(0).getCell(0)).getNumberValue(); + + // Assert + assertEquals(259.0, a1Value, 0.0); + + // KY: SUM(B1: IZ1) + double ky1Value = + evaluator.evaluate(workbook.getSheetAt(0).getRow(0).getCell(310)).getNumberValue(); + + // Assert + assertEquals(259.0, a1Value, 0.0); + } + } diff --git a/test-data/spreadsheet/53101.xlsx b/test-data/spreadsheet/53101.xlsx new file mode 100644 index 0000000000..e52f424338 Binary files /dev/null and b/test-data/spreadsheet/53101.xlsx differ