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 new file mode 100644 index 0000000000..b8613cd0f9 Binary files /dev/null and b/test-data/spreadsheet/simple-monthly-budget.xlsx differ