]> source.dussan.org Git - poi.git/commitdiff
[bug-61700] getForceFormulaRecalculation() returns wrong value. Fix thanks to Kai G
authorPJ Fanning <fanningpj@apache.org>
Sat, 30 Mar 2019 23:59:19 +0000 (23:59 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 30 Mar 2019 23:59:19 +0000 (23:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1856650 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

index 14ca6c97ea58720292ffe289a195320b4a7296f6..f2c9635303eccb86c06793dce760d15342817b6f 100644 (file)
@@ -2239,7 +2239,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
     public boolean getForceFormulaRecalculation(){
         CTWorkbook ctWorkbook = getCTWorkbook();
         CTCalcPr calcPr = ctWorkbook.getCalcPr();
-        return calcPr != null && calcPr.getCalcId() != 0;
+        return calcPr != null && calcPr.getCalcId() != 1;
     }
 
 
index 3fa007ba3ea9abe6bf7695bee1cf98626a942984..0f394610025f67fea32ccba2d4ad3f2b06a49bd2 100644 (file)
@@ -500,7 +500,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
 
             wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
             assertEquals(0, (int) calcPr.getCalcId());
-            assertFalse(wb.getForceFormulaRecalculation());
+            assertTrue(wb.getForceFormulaRecalculation());
 
             // calcMode="manual" is unset when forceFormulaRecalculation=true
             calcPr.setCalcMode(STCalcMode.MANUAL);
@@ -1143,4 +1143,26 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
 
         wb.close();
     }
+    
+    /**
+     * See bug #61700 test data tables
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testWorkbookForceFormulaRecalculation() throws Exception {
+        Workbook workbook = _testDataProvider.createWorkbook();
+        workbook.createSheet().createRow(0).createCell(0).setCellFormula("B1+C1");
+        workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
+
+        assertFalse(workbook.getForceFormulaRecalculation());
+        workbook.setForceFormulaRecalculation(true);
+        assertTrue(workbook.getForceFormulaRecalculation());
+
+        Workbook wbBack = _testDataProvider.writeOutAndReadBack(workbook);
+        assertTrue(wbBack.getForceFormulaRecalculation());
+
+        workbook.close();
+        wbBack.close();
+    }
 }