Bugzilla 53950 - fixed setForceFormulaRecalculation to reset workbook-level manual flag<
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1394059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
57bbac29fe
commit
141294063d
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.9-beta1" date="2012-??-??">
|
<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">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="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>
|
<action dev="poi-developers" type="add">HSSFOptimiser will now also tidy away un-used cell styles, in addition to duplicate styles</action>
|
||||||
|
@ -1502,6 +1502,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
|
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
|
||||||
*/
|
*/
|
||||||
public void setForceFormulaRecalculation(boolean value) {
|
public void setForceFormulaRecalculation(boolean value) {
|
||||||
|
CTCalcPr calcPr = getWorkbook().getCTWorkbook().getCalcPr();
|
||||||
|
|
||||||
if(worksheet.isSetSheetCalcPr()) {
|
if(worksheet.isSetSheetCalcPr()) {
|
||||||
// Change the current setting
|
// Change the current setting
|
||||||
CTSheetCalcPr calc = worksheet.getSheetCalcPr();
|
CTSheetCalcPr calc = worksheet.getSheetCalcPr();
|
||||||
@ -1512,9 +1514,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
CTSheetCalcPr calc = worksheet.addNewSheetCalcPr();
|
CTSheetCalcPr calc = worksheet.addNewSheetCalcPr();
|
||||||
calc.setFullCalcOnLoad(value);
|
calc.setFullCalcOnLoad(value);
|
||||||
}
|
}
|
||||||
else {
|
if(value && calcPr != null && calcPr.getCalcMode() == STCalcMode.MANUAL) {
|
||||||
// Not set, requested not, nothing to do
|
calcPr.setCalcMode(STCalcMode.AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1672,6 +1672,10 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
// when set to 0, will tell Excel that it needs to recalculate all formulas
|
// when set to 0, 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.setCalcId(0);
|
||||||
|
|
||||||
|
if(value && calcPr.getCalcMode() == STCalcMode.MANUAL) {
|
||||||
|
calcPr.setCalcMode(STCalcMode.AUTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1075,10 +1075,17 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
sheet.setForceFormulaRecalculation(true);
|
sheet.setForceFormulaRecalculation(true);
|
||||||
assertEquals(true, sheet.getForceFormulaRecalculation());
|
assertEquals(true, sheet.getForceFormulaRecalculation());
|
||||||
|
|
||||||
|
// 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
|
// Check
|
||||||
sheet.setForceFormulaRecalculation(false);
|
sheet.setForceFormulaRecalculation(false);
|
||||||
assertEquals(false, sheet.getForceFormulaRecalculation());
|
assertEquals(false, sheet.getForceFormulaRecalculation());
|
||||||
|
|
||||||
|
|
||||||
// Save, re-load, and re-check
|
// Save, re-load, and re-check
|
||||||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||||
sheet = workbook.getSheet("Sheet 1");
|
sheet = workbook.getSheet("Sheet 1");
|
||||||
|
@ -35,6 +35,7 @@ import org.apache.poi.xssf.model.StylesTable;
|
|||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
|
||||||
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
|
||||||
|
|
||||||
public final class TestXSSFWorkbook extends BaseTestWorkbook {
|
public final class TestXSSFWorkbook extends BaseTestWorkbook {
|
||||||
|
|
||||||
@ -426,6 +427,12 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
|
|||||||
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
|
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
|
||||||
assertEquals(0, (int) calcPr.getCalcId());
|
assertEquals(0, (int) calcPr.getCalcId());
|
||||||
assertFalse(wb.getForceFormulaRecalculation());
|
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() {
|
public void testChangeSheetNameWithSharedFormulas() {
|
||||||
|
Loading…
Reference in New Issue
Block a user