]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 53101: fixed evaluation of SUM over cell range > 255
authorYegor Kozlov <yegor@apache.org>
Sat, 21 Apr 2012 12:48:42 +0000 (12:48 +0000)
committerYegor Kozlov <yegor@apache.org>
Sat, 21 Apr 2012 12:48:42 +0000 (12:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1328647 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/ss/formula/LazyAreaEval.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/53101.xlsx [new file with mode: 0644]

index b0a09088e703af66ccebe82b1e063d59de517088..d2a6d64e3b62a57fc86c8e165007c47b685f78d5 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.9-beta1" date="2012-??-??">
+          <action dev="poi-developers" type="fix">53101 - fixed evaluation of SUM over cell range &gt; 255</action>
           <action dev="poi-developers" type="fix">49529 - avoid exception when cloning sheets with no drawing records and initialized drawing patriarch</action>
         </release>
         <release version="3.8-FINAL" date="2012-03-26">
index 76f926879fa277861939f4c284417c7e74c11dd7..2a9f94391a209b49120e4f3a9f195e9d44aae885 100644 (file)
@@ -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);
        }
index df88b4a905ffdde9fa7764e86d383d599b2b39f2..4c55cca900e7bfcab3840d72e79cd85781ac8830 100644 (file)
@@ -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 (file)
index 0000000..e52f424
Binary files /dev/null and b/test-data/spreadsheet/53101.xlsx differ