use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook in project poi by apache.
the class XSSFWorkbook method onWorkbookCreate.
/**
* Create a new CTWorkbook with all values set to default
*/
private void onWorkbookCreate() {
workbook = CTWorkbook.Factory.newInstance();
// don't EVER use the 1904 date system
CTWorkbookPr workbookPr = workbook.addNewWorkbookPr();
workbookPr.setDate1904(false);
CTBookViews bvs = workbook.addNewBookViews();
CTBookView bv = bvs.addNewWorkbookView();
bv.setActiveTab(0);
workbook.addNewSheets();
POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
sharedStringSource = (SharedStringsTable) createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
stylesSource = (StylesTable) createRelationship(XSSFRelation.STYLES, XSSFFactory.getInstance());
stylesSource.setWorkbook(this);
namedRanges = new ArrayList<XSSFName>();
namedRangesByName = new ArrayListValuedHashMap<String, XSSFName>();
sheets = new ArrayList<XSSFSheet>();
pivotTables = new ArrayList<XSSFPivotTable>();
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook in project poi by apache.
the class TestXSSFWorkbook method recalcId.
@Test
public void recalcId() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
try {
assertFalse(wb.getForceFormulaRecalculation());
CTWorkbook ctWorkbook = wb.getCTWorkbook();
assertFalse(ctWorkbook.isSetCalcPr());
// resets the EngineId flag to zero
wb.setForceFormulaRecalculation(true);
CTCalcPr calcPr = ctWorkbook.getCalcPr();
assertNotNull(calcPr);
assertEquals(0, (int) calcPr.getCalcId());
calcPr.setCalcId(100);
assertTrue(wb.getForceFormulaRecalculation());
// resets the EngineId flag to zero
wb.setForceFormulaRecalculation(true);
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());
} finally {
wb.close();
}
}
Aggregations