From 8ae072fc85dcbc61e4ccaabc68b841da2e609514 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Sat, 21 Apr 2012 12:48:42 +0000 Subject: [PATCH] Bugzilla 53101: fixed evaluation of SUM over cell range > 255 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1328647 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../apache/poi/ss/formula/LazyAreaEval.java | 4 ++-- .../poi/xssf/usermodel/TestXSSFBugs.java | 22 ++++++++++++++++++ test-data/spreadsheet/53101.xlsx | Bin 0 -> 9448 bytes 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/53101.xlsx 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 0000000000000000000000000000000000000000..e52f424338ab157de1247d8df951c7bce0bebf02 GIT binary patch literal 9448 zcmeHNby!quw;w{frKE-ihlU}fQ*xBx+wzjv*zu8M|E3cvth0RR97z+=_6V0#n* zApHgaa1(%qY9#04>ox~0FK(zu@#IAFT3m})_)i@n5|0z-S#lRuaF5w?UP(BG(ED|+{;>rOuv zRdD#exqYE~E^%Ve>nwi;3QK~3kuMUi>o9cc{TYYq(cN318Ze)~!T7%ow6Yc{!nz*Am~lp0ZWA4Q?EXHe9Gm(xLVD6EKnPDo;L?n5Zk)@9OexFp6^ zSMLSzThzg2aPiJg6?0!!3m}#n&39$qSz$P#kk?&vT&sis{F#5u{X+r#AttXRKpOQ- zQ;d+Q6G{^8MMlZNlT=EdvTQEHc4KHG3s!pbddQ&VbV(58FI zybWx4oX;$Md=!QjqGB~SdbBnyWwfxpYOf8XvE;e;x|Lm~M!?d4+QGLXN0;!KC8Mo9 zX)jeAjfLL)0?f>}ASKgs`mCfD4yS5OIcKs2)7~e=-P?38Oyt$*x3C*czEu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