<changes>
<release version="3.9-beta1" date="2012-??-??">
+ <action dev="poi-developers" type="fix">53950 - fixed setForceFormulaRecalculation to reset workbook-level "manual" flag</action>
<action dev="poi-developers" type="fix">52211 - avoid unnessary re-coverting content types to US-ASCII, it can cause exceptions on ibm mainframes</action>
<action dev="poi-developers" type="fix">53568 - Set shapes anchors in XSSF when reading from existing drawings</action>
<action dev="poi-developers" type="add">HSSFOptimiser will now also tidy away un-used cell styles, in addition to duplicate styles</action>
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
*/
public void setForceFormulaRecalculation(boolean value) {
- if(worksheet.isSetSheetCalcPr()) {
+ CTCalcPr calcPr = getWorkbook().getCTWorkbook().getCalcPr();
+
+ if(worksheet.isSetSheetCalcPr()) {
// Change the current setting
CTSheetCalcPr calc = worksheet.getSheetCalcPr();
calc.setFullCalcOnLoad(value);
CTSheetCalcPr calc = worksheet.addNewSheetCalcPr();
calc.setFullCalcOnLoad(value);
}
- else {
- // Not set, requested not, nothing to do
- }
+ if(value && calcPr != null && calcPr.getCalcMode() == STCalcMode.MANUAL) {
+ calcPr.setCalcMode(STCalcMode.AUTO);
+ }
+
}
/**
// when set to 0, will tell Excel that it needs to recalculate all formulas
// in the workbook the next time the file is opened.
calcPr.setCalcId(0);
+
+ if(value && calcPr.getCalcMode() == STCalcMode.MANUAL) {
+ calcPr.setCalcMode(STCalcMode.AUTO);
+ }
}
/**
// Set
sheet.setForceFormulaRecalculation(true);
assertEquals(true, sheet.getForceFormulaRecalculation());
-
- // Check
+
+ // calcMode="manual" is unset when forceFormulaRecalculation=true
+ CTCalcPr calcPr = workbook.getCTWorkbook().addNewCalcPr();
+ calcPr.setCalcMode(STCalcMode.MANUAL);
+ sheet.setForceFormulaRecalculation(true);
+ assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
+
+ // Check
sheet.setForceFormulaRecalculation(false);
assertEquals(false, sheet.getForceFormulaRecalculation());
-
+
+
// Save, re-load, and re-check
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
sheet = workbook.getSheet("Sheet 1");
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
public final class TestXSSFWorkbook extends BaseTestWorkbook {
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
assertEquals(0, (int) calcPr.getCalcId());
assertFalse(wb.getForceFormulaRecalculation());
+
+ // calcMode="manual" is unset when forceFormulaRecalculation=true
+ calcPr.setCalcMode(STCalcMode.MANUAL);
+ wb.setForceFormulaRecalculation(true);
+ assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
+
}
public void testChangeSheetNameWithSharedFormulas() {