poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwool...@apache.org
Subject svn commit: r1806623 - in /poi/trunk: src/java/org/apache/poi/ss/formula/ src/ooxml/testcases/org/apache/poi/xssf/usermodel/ test-data/spreadsheet/
Date Tue, 29 Aug 2017 17:14:52 GMT
Author: gwoolsey
Date: Tue Aug 29 17:14:52 2017
New Revision: 1806623

URL: http://svn.apache.org/viewvc?rev=1806623&view=rev
Log:
Fixes bug #61468, caused by a confusing OOXML spec design as noted in JavaDocs added in r1795648.

Added:
    poi/trunk/test-data/spreadsheet/simple-monthly-budget.xlsx   (with props)
Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java?rev=1806623&r1=1806622&r2=1806623&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java Tue Aug 29 17:14:52 2017
@@ -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--;
             }
         }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java?rev=1806623&r1=1806622&r2=1806623&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
Tue Aug 29 17:14:52 2017
@@ -694,4 +694,15 @@ public final class TestXSSFFormulaEvalua
         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);
+    }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java?rev=1806623&r1=1806622&r2=1806623&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java Tue Aug
29 17:14:52 2017
@@ -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(); 
     }
 

Added: poi/trunk/test-data/spreadsheet/simple-monthly-budget.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/simple-monthly-budget.xlsx?rev=1806623&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/simple-monthly-budget.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message