Search in sources :

Example 26 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project poi by apache.

the class XSSFChart method commit.

@Override
protected void commit() throws IOException {
    XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
    /*
		   Saved chart space must have the following namespaces set:
		   <c:chartSpace
		      xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
		      xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
		      xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
		 */
    xmlOptions.setSaveSyntheticDocumentElement(new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c"));
    PackagePart part = getPackagePart();
    OutputStream out = part.getOutputStream();
    chartSpace.save(out, xmlOptions);
    out.close();
}
Also used : QName(javax.xml.namespace.QName) XmlOptions(org.apache.xmlbeans.XmlOptions) OutputStream(java.io.OutputStream) PackagePart(org.apache.poi.openxml4j.opc.PackagePart)

Example 27 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project poi by apache.

the class SharedStringsTable method writeTo.

/**
     * Write this table out as XML.
     * 
     * @param out The stream to write to.
     * @throws IOException if an error occurs while writing.
     */
public void writeTo(OutputStream out) throws IOException {
    XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
    // the following two lines turn off writing CDATA
    // see Bugzilla 48936
    xmlOptions.setSaveCDataLengthThreshold(1000000);
    xmlOptions.setSaveCDataEntityCountThreshold(-1);
    //re-create the sst table every time saving a workbook
    CTSst sst = _sstDoc.getSst();
    sst.setCount(count);
    sst.setUniqueCount(uniqueCount);
    _sstDoc.save(out, xmlOptions);
}
Also used : CTSst(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst) XmlOptions(org.apache.xmlbeans.XmlOptions)

Example 28 with XmlOptions

use of org.apache.xmlbeans.XmlOptions in project poi by apache.

the class XSSFDrawing method commit.

@Override
protected void commit() throws IOException {
    XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
    /*
            Saved drawings must have the following namespaces set:
            <xdr:wsDr
                xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
                xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">
        */
    xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr"));
    PackagePart part = getPackagePart();
    OutputStream out = part.getOutputStream();
    drawing.save(out, xmlOptions);
    out.close();
}
Also used : QName(javax.xml.namespace.QName) XmlOptions(org.apache.xmlbeans.XmlOptions) OutputStream(java.io.OutputStream) PackagePart(org.apache.poi.openxml4j.opc.PackagePart)

Example 29 with XmlOptions

use of org.apache.xmlbeans.XmlOptions 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 30 with XmlOptions

use of org.apache.xmlbeans.XmlOptions 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)

Aggregations

XmlOptions (org.apache.xmlbeans.XmlOptions)36 OutputStream (java.io.OutputStream)18 QName (javax.xml.namespace.QName)18 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)17 XmlException (org.apache.xmlbeans.XmlException)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Beta (org.apache.poi.util.Beta)7 XmlError (org.apache.xmlbeans.XmlError)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 HashMap (java.util.HashMap)2 MarshalException (javax.xml.crypto.MarshalException)2 EncryptedDocumentException (org.apache.poi.EncryptedDocumentException)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 XmlObject (org.apache.xmlbeans.XmlObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 GeneralSecurityException (java.security.GeneralSecurityException)1