@Override protected void write(OutputStream out) throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet")); chartsheet.save(out, xmlOptions); }
@Override protected void commit() throws IOException { if (ctSettings == null) { throw new IllegalStateException("Unable to write out settings that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTSettings.type.getName().getNamespaceURI(), "settings")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctSettings.save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { if (ctStyles == null) { throw new IllegalStateException("Unable to write out styles that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTStyles.type.getName().getNamespaceURI(), "styles")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctStyles.save(out, xmlOptions); out.close(); }
public T load(String name, Object... varargs) { Constructor<? extends T> constructor = _types.get(name); if (constructor == null) { @SuppressWarnings("unchecked") X xmlObject = (X) varargs[0]; String typeName = xmlObject.schemaType().getName().getLocalPart(); throw new POIXMLException("Invalid '" + typeName + "' name '" + name + "'"); } try { return constructor.newInstance(varargs); } catch (InvocationTargetException e) { throw new POIXMLException(e.getCause()); } catch (Exception e) { throw new POIXMLException(e); } }
/** * save and commit numbering */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "numbering")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctNumbering.save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctFootnotes.save(out, xmlOptions); out.close(); }
/** * commit and saves the document */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDocument1.type.getName().getNamespaceURI(), "document")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctDocument.save(out, xmlOptions); out.close(); }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTEndnotes.type.getName().getNamespaceURI(), "endnotes")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctEndnotes.save(out, xmlOptions); out.close(); }
private List<CTPicture> getCTPictures(XmlObject o) { List<CTPicture> pics = new ArrayList<>(); XmlObject[] picts = o.selectPath("declare namespace pic='" + CTPicture.type.getName().getNamespaceURI() + "' .//pic:pic"); for (XmlObject pict : picts) { if (pict instanceof XmlAnyTypeImpl) { // Pesky XmlBeans bug - see Bugzilla #49934 try { pict = CTPicture.Factory.parse(pict.toString(), DEFAULT_XML_OPTIONS); } catch (XmlException e) { throw new POIXMLException(e); } } if (pict instanceof CTPicture) { pics.add((CTPicture) pict); } } return pics; }
@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(CTPivotCacheDefinition.type.getName(). getNamespaceURI(), "pivotCacheDefinition")); ctPivotCacheDefinition.save(out, xmlOptions); out.close(); }
/** * save and commit footer */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "ftr")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); super._getHdrFtr().save(out, xmlOptions); out.close(); }
@Beta @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); //Sets the pivotTableDefinition tag xmlOptions.setSaveSyntheticDocumentElement(new QName(CTPivotTableDefinition.type.getName(). getNamespaceURI(), "pivotTableDefinition")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); pivotTableDefinition.save(out, xmlOptions); out.close(); }
/** * save and commit footer */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "hdr")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); super._getHdrFtr().save(out, xmlOptions); out.close(); }
@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(); } }
@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(); }
@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(); try (OutputStream out = part.getOutputStream()) { chartSpace.save(out, xmlOptions); } }
@Override protected void commit() throws IOException { saveNamedRanges(); saveCalculationChain(); XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorkbook.type.getName().getNamespaceURI(), "workbook")); PackagePart part = getPackagePart(); try (OutputStream out = part.getOutputStream()) { workbook.save(out, xmlOptions); } }
/** * The low level code to insert {@code <c:chart>} tag into * {@code<a:graphicData>}. * * Here is the schema (ECMA-376): * <pre> * {@code * <complexType name="CT_GraphicalObjectData"> * <sequence> * <any minOccurs="0" maxOccurs="unbounded" processContents="strict"/> * </sequence> * <attribute name="uri" type="xsd:token"/> * </complexType> * } * </pre> */ private void appendChartElement(CTGraphicalObjectData data, String id) { String r_namespaceUri = STRelationshipId.type.getName().getNamespaceURI(); String c_namespaceUri = XSSFDrawing.NAMESPACE_C; XmlCursor cursor = data.newCursor(); cursor.toNextToken(); cursor.beginElement(new QName(c_namespaceUri, "chart", "c")); cursor.insertAttributeWithValue(new QName(r_namespaceUri, "id", "r"), id); cursor.dispose(); data.setUri(c_namespaceUri); }
/** * save chart xml */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c")); if (workbook != null) { try { saveWorkbook(workbook); } catch (InvalidFormatException e) { throw new POIXMLException(e); } } PackagePart part = getPackagePart(); try (OutputStream out = part.getOutputStream()) { chartSpace.save(out, xmlOptions); } }
@Override public XWPFTable insertNewTbl(XmlCursor cursor) { if (isCursorInBody(cursor)) { String uri = CTTbl.type.getName().getNamespaceURI(); String localPart = "tbl"; cursor.beginElement(localPart, uri);