Search in sources :

Example 16 with Beta

use of org.apache.poi.util.Beta in project poi by apache.

the class XSSFPivotCacheDefinition method readFrom.

@Beta
public void readFrom(InputStream is) throws IOException {
    try {
        XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
        //Removing root element
        options.setLoadReplaceDocumentElement(null);
        ctPivotCacheDefinition = CTPivotCacheDefinition.Factory.parse(is, options);
    } catch (XmlException e) {
        throw new IOException(e.getLocalizedMessage(), e);
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) IOException(java.io.IOException) Beta(org.apache.poi.util.Beta)

Example 17 with Beta

use of org.apache.poi.util.Beta in project poi by apache.

the class XSSFPivotCacheRecords method readFrom.

@Beta
protected void readFrom(InputStream is) throws IOException {
    try {
        XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
        //Removing root element
        options.setLoadReplaceDocumentElement(null);
        ctPivotCacheRecords = CTPivotCacheRecords.Factory.parse(is, options);
    } catch (XmlException e) {
        throw new IOException(e.getLocalizedMessage());
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) IOException(java.io.IOException) Beta(org.apache.poi.util.Beta)

Example 18 with Beta

use of org.apache.poi.util.Beta in project poi by apache.

the class XSSFPivotCacheRecords method commit.

@Beta
@Override
protected void commit() throws IOException {
    PackagePart part = getPackagePart();
    OutputStream out = part.getOutputStream();
    XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
    //Sets the pivotCacheDefinition tag
    xmlOptions.setSaveSyntheticDocumentElement(new QName(CTPivotCacheRecords.type.getName().getNamespaceURI(), "pivotCacheRecords"));
    ctPivotCacheRecords.save(out, xmlOptions);
    out.close();
}
Also used : QName(javax.xml.namespace.QName) OutputStream(java.io.OutputStream) XmlOptions(org.apache.xmlbeans.XmlOptions) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) Beta(org.apache.poi.util.Beta)

Example 19 with Beta

use of org.apache.poi.util.Beta in project poi by apache.

the class XSSFPivotTable method readFrom.

@Beta
public void readFrom(InputStream is) throws IOException {
    try {
        XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
        //Removing root element
        options.setLoadReplaceDocumentElement(null);
        pivotTableDefinition = CTPivotTableDefinition.Factory.parse(is, options);
    } catch (XmlException e) {
        throw new IOException(e.getLocalizedMessage());
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) IOException(java.io.IOException) Beta(org.apache.poi.util.Beta)

Example 20 with Beta

use of org.apache.poi.util.Beta in project poi by apache.

the class XSSFPivotTable method addReportFilter.

/**
     * Add filter for the column with the corresponding index and cell value
     * @param columnIndex index of column to filter on
     */
@Beta
public void addReportFilter(int columnIndex) {
    checkColumnIndex(columnIndex);
    AreaReference pivotArea = getPivotArea();
    int lastRowIndex = pivotArea.getLastCell().getRow() - pivotArea.getFirstCell().getRow();
    CTPivotFields pivotFields = pivotTableDefinition.getPivotFields();
    CTPivotField pivotField = CTPivotField.Factory.newInstance();
    CTItems items = pivotField.addNewItems();
    pivotField.setAxis(STAxis.AXIS_PAGE);
    pivotField.setShowAll(false);
    for (int i = 0; i <= lastRowIndex; i++) {
        items.addNewItem().setT(STItemType.DEFAULT);
    }
    items.setCount(items.sizeOfItemArray());
    pivotFields.setPivotFieldArray(columnIndex, pivotField);
    CTPageFields pageFields;
    if (pivotTableDefinition.getPageFields() != null) {
        pageFields = pivotTableDefinition.getPageFields();
        //Another filter has already been created
        pivotTableDefinition.setMultipleFieldFilters(true);
    } else {
        pageFields = pivotTableDefinition.addNewPageFields();
    }
    CTPageField pageField = pageFields.addNewPageField();
    pageField.setHier(-1);
    pageField.setFld(columnIndex);
    pageFields.setCount(pageFields.sizeOfPageFieldArray());
    pivotTableDefinition.getLocation().setColPageCount(pageFields.getCount());
}
Also used : AreaReference(org.apache.poi.ss.util.AreaReference) CTPivotField(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotField) CTPageField(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageField) CTPageFields(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageFields) CTItems(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTItems) CTPivotFields(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields) Beta(org.apache.poi.util.Beta)

Aggregations

Beta (org.apache.poi.util.Beta)21 AreaReference (org.apache.poi.ss.util.AreaReference)7 XmlOptions (org.apache.xmlbeans.XmlOptions)7 IOException (java.io.IOException)4 QName (javax.xml.namespace.QName)4 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)4 XmlException (org.apache.xmlbeans.XmlException)4 CTPivotField (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotField)4 CTPivotFields (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields)4 OutputStream (java.io.OutputStream)3 Cell (org.apache.poi.ss.usermodel.Cell)3 Row (org.apache.poi.ss.usermodel.Row)2 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)2 CellReference (org.apache.poi.ss.util.CellReference)2 CTItems (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTItems)2 CTWorksheetSource (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheetSource)2 HashSet (java.util.HashSet)1 FormulaShifter (org.apache.poi.ss.formula.FormulaShifter)1 CellCopyPolicy (org.apache.poi.ss.usermodel.CellCopyPolicy)1 Name (org.apache.poi.ss.usermodel.Name)1