Browse Source

[bug-61700] getForceFormulaRecalculation() returns wrong value. Fix thanks to Kai G

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1856650 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_4_1_0
PJ Fanning 5 years ago
parent
commit
b9101138bd

+ 1
- 1
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java View 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;
}



+ 23
- 1
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java View 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();
}
}

Loading…
Cancel
Save