/// <summary> /// Creates a new custom properties parts /// </summary> public XDocument CreateCustomPropertiesPart() { // create the custom properties part OpenXmlSDK.CustomFilePropertiesPart customPropertiesPart = null; OpenXmlDocumentType type = OpenXmlDocument.GetDocumentType(parentDocument.Document.Package); switch (type) { case OpenXmlDocumentType.WordprocessingML: customPropertiesPart = ((OpenXmlSDK.WordprocessingDocument)parentDocument.Document).AddCustomFilePropertiesPart(); break; case OpenXmlDocumentType.SpreadsheetML: customPropertiesPart = ((OpenXmlSDK.SpreadsheetDocument)parentDocument.Document).AddCustomFilePropertiesPart(); break; case OpenXmlDocumentType.PresentationML: customPropertiesPart = ((OpenXmlSDK.PresentationDocument)parentDocument.Document).AddCustomFilePropertiesPart(); break; } XDocument customPropertiesXDocument = parentDocument.GetXDocument(customPropertiesPart); customPropertiesXDocument.Add( new XElement(customPropertiesns + "Properties", new XAttribute(XNamespace.Xmlns + "c", customPropertiesns), new XAttribute(XNamespace.Xmlns + "vt", vTypesns))); return(customPropertiesXDocument); }
/// <summary> /// FromPackage (static) /// </summary> public static OpenXmlDocument FromPackage(Package package, string fullName) { OpenXmlDocumentType type = GetDocumentType(package); switch (type) { case OpenXmlDocumentType.WordprocessingML: return(new PTWordprocessingDocument(OpenXmlSDK.WordprocessingDocument.Open(package), fullName)); case OpenXmlDocumentType.SpreadsheetML: return(new SpreadsheetDocument(OpenXmlSDK.SpreadsheetDocument.Open(package), fullName)); case OpenXmlDocumentType.PresentationML: //return new PresentationDocument(OpenXmlSDK.PresentationDocument.Open(package)); return(null); } return(null); }