mirror of https://github.com/apache/poi.git
#61700 getForceFormulaRecalculation() returns wrong value
changed to use the proper OOXML attribute instead of a hack about calculation engine version ID. Reporter was right, the behavior was wrong in some cases, but it turns out the fix was a bit more. See issue for details. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1856652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b9101138bd
commit
6b76706ef7
|
@ -2221,9 +2221,9 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
public void setForceFormulaRecalculation(boolean value){
|
public void setForceFormulaRecalculation(boolean value){
|
||||||
CTWorkbook ctWorkbook = getCTWorkbook();
|
CTWorkbook ctWorkbook = getCTWorkbook();
|
||||||
CTCalcPr calcPr = ctWorkbook.isSetCalcPr() ? ctWorkbook.getCalcPr() : ctWorkbook.addNewCalcPr();
|
CTCalcPr calcPr = ctWorkbook.isSetCalcPr() ? ctWorkbook.getCalcPr() : ctWorkbook.addNewCalcPr();
|
||||||
// when set to 0, will tell Excel that it needs to recalculate all formulas
|
// when set to true, will tell Excel that it needs to recalculate all formulas
|
||||||
// in the workbook the next time the file is opened.
|
// in the workbook the next time the file is opened.
|
||||||
calcPr.setCalcId(0);
|
calcPr.setFullCalcOnLoad(value);
|
||||||
|
|
||||||
if(value && calcPr.getCalcMode() == STCalcMode.MANUAL) {
|
if(value && calcPr.getCalcMode() == STCalcMode.MANUAL) {
|
||||||
calcPr.setCalcMode(STCalcMode.AUTO);
|
calcPr.setCalcMode(STCalcMode.AUTO);
|
||||||
|
@ -2239,7 +2239,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
public boolean getForceFormulaRecalculation(){
|
public boolean getForceFormulaRecalculation(){
|
||||||
CTWorkbook ctWorkbook = getCTWorkbook();
|
CTWorkbook ctWorkbook = getCTWorkbook();
|
||||||
CTCalcPr calcPr = ctWorkbook.getCalcPr();
|
CTCalcPr calcPr = ctWorkbook.getCalcPr();
|
||||||
return calcPr != null && calcPr.getCalcId() != 1;
|
return calcPr != null && calcPr.isSetFullCalcOnLoad() && calcPr.getFullCalcOnLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
|
||||||
CTWorkbook ctWorkbook = wb.getCTWorkbook();
|
CTWorkbook ctWorkbook = wb.getCTWorkbook();
|
||||||
assertFalse(ctWorkbook.isSetCalcPr());
|
assertFalse(ctWorkbook.isSetCalcPr());
|
||||||
|
|
||||||
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
|
wb.setForceFormulaRecalculation(true);
|
||||||
|
|
||||||
CTCalcPr calcPr = ctWorkbook.getCalcPr();
|
CTCalcPr calcPr = ctWorkbook.getCalcPr();
|
||||||
assertNotNull(calcPr);
|
assertNotNull(calcPr);
|
||||||
|
@ -498,8 +498,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
|
||||||
calcPr.setCalcId(100);
|
calcPr.setCalcId(100);
|
||||||
assertTrue(wb.getForceFormulaRecalculation());
|
assertTrue(wb.getForceFormulaRecalculation());
|
||||||
|
|
||||||
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
|
wb.setForceFormulaRecalculation(false);
|
||||||
assertEquals(0, (int) calcPr.getCalcId());
|
|
||||||
assertTrue(wb.getForceFormulaRecalculation());
|
assertTrue(wb.getForceFormulaRecalculation());
|
||||||
|
|
||||||
// calcMode="manual" is unset when forceFormulaRecalculation=true
|
// calcMode="manual" is unset when forceFormulaRecalculation=true
|
||||||
|
@ -1145,8 +1144,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See bug #61700 test data tables
|
* See bug #61700
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue