diff options
author | Greg Woolsey <gwoolsey@apache.org> | 2017-08-29 17:14:52 +0000 |
---|---|---|
committer | Greg Woolsey <gwoolsey@apache.org> | 2017-08-29 17:14:52 +0000 |
commit | d68912db25e9b9d74dea87418615c2c7b695cc3c (patch) | |
tree | b696e47f0ea5751cec54efb89c7ef978cffed6a9 | |
parent | 8850fae08638d43539e21ae7981c1a911f012239 (diff) | |
download | poi-d68912db25e9b9d74dea87418615c2c7b695cc3c.tar.gz poi-d68912db25e9b9d74dea87418615c2c7b695cc3c.zip |
Fixes bug #61468, caused by a confusing OOXML spec design as noted in JavaDocs added in r1795648.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1806623 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/poi/ss/formula/FormulaParser.java | 8 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java | 11 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java | 2 | ||||
-rw-r--r-- | test-data/spreadsheet/simple-monthly-budget.xlsx | bin | 0 -> 18700 bytes |
4 files changed, 16 insertions, 5 deletions
diff --git a/src/java/org/apache/poi/ss/formula/FormulaParser.java b/src/java/org/apache/poi/ss/formula/FormulaParser.java index 8d0653b024..fd17aca184 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaParser.java +++ b/src/java/org/apache/poi/ss/formula/FormulaParser.java @@ -736,7 +736,7 @@ public final class FormulaParser { // Done reading from input stream // Ok to return now - if (isTotalsSpec && !tbl.isHasTotalsRow()) { + if (isTotalsSpec && tbl.getTotalsRowCount() == 0) { return new ParseNode(ErrPtg.REF_INVALID); } if ((isThisRow || isThisRowSpec) && (_rowIndex < startRow || endRow < _rowIndex)) { @@ -759,14 +759,14 @@ public final class FormulaParser { if (nSpecQuantifiers == 1 && isAllSpec) { //do nothing } else if (isDataSpec && isHeadersSpec) { - if (tbl.isHasTotalsRow()) { + if (tbl.getTotalsRowCount() > 0) { actualEndRow = endRow - 1; } } else if (isDataSpec && isTotalsSpec) { actualStartRow = startRow + 1; } else if (nSpecQuantifiers == 1 && isDataSpec) { actualStartRow = startRow + 1; - if (tbl.isHasTotalsRow()) { + if (tbl.getTotalsRowCount() > 0) { actualEndRow = endRow - 1; } } else if (nSpecQuantifiers == 1 && isHeadersSpec) { @@ -785,7 +785,7 @@ public final class FormulaParser { actualEndRow = _rowIndex; } else { // Really no special quantifiers actualStartRow++; - if (tbl.isHasTotalsRow()) actualEndRow--; + if (tbl.getTotalsRowCount() > 0) actualEndRow--; } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java index 3b1fdd3cad..5afad20672 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java @@ -694,4 +694,15 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { assertSame(cell, same); wb.close(); } + + @Test + public void testBug61468() { + Workbook wb = XSSFTestDataSamples.openSampleWorkbook("simple-monthly-budget.xlsx"); + FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); + Cell cell = wb.getSheetAt(0).getRow(8).getCell(4); + assertEquals(3750, cell.getNumericCellValue(), 0.001); + + CellValue value = evaluator.evaluate(cell); + assertEquals(3750, value.getNumberValue(), 0.001); + } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java index 6b916b1e6f..06ef68a549 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java @@ -163,7 +163,7 @@ public final class TestXSSFTable { public void isHasTotalsRow() throws IOException { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx"); XSSFTable table = wb.getTable("\\_Prime.1"); - assertFalse(table.isHasTotalsRow()); + assertFalse(table.getTotalsRowCount() > 0); wb.close(); } diff --git a/test-data/spreadsheet/simple-monthly-budget.xlsx b/test-data/spreadsheet/simple-monthly-budget.xlsx Binary files differnew file mode 100644 index 0000000000..b8613cd0f9 --- /dev/null +++ b/test-data/spreadsheet/simple-monthly-budget.xlsx |