Search in sources :

Example 6 with CTWorkbook

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>();
}
Also used : CTBookViews(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews) POIXMLProperties(org.apache.poi.POIXMLProperties) CTWorkbookPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr) CTBookView(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView)

Example 7 with CTWorkbook

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();
    }
}
Also used : CTCalcPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr) CTWorkbook(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook) Test(org.junit.Test)

Aggregations

CTWorkbook (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook)5 CTCalcPr (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr)3 Test (org.junit.Test)2 CTPivotCache (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache)2 POIXMLProperties (org.apache.poi.POIXMLProperties)1 Beta (org.apache.poi.util.Beta)1 CTBookView (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView)1 CTBookViews (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews)1 CTDefinedName (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName)1 CTDefinedNames (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedNames)1 CTPivotCaches (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCaches)1 CTWorkbookPr (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr)1