mirror of https://github.com/apache/poi.git
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
This commit is contained in:
parent
8850fae086
commit
d68912db25
|
@ -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--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue