What's New in the Open XML Format SDK 1.0
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
The Office Open XML Package specification defines a set of XML files that contain the content and define the relationships for all of the document parts stored in a single package. These packages combine the document parts that comprise the document files for Microsoft® Office Excel® 2007, Microsoft Office PowerPoint® 2007, and Microsoft Office Word 2007. The Open XML API allows you to create packages and manipulate the files that comprise the packages. This topic describes changes included in the Open XML Format Software Development Kit (SDK). For more information, see Getting Started with the Open XML Format SDK 1.0.
Changes in the Open XML Format SDK April 2008 Technology Preview
The Open XML Format SDK April 2008 Technology Preview release contained the featured changes described below:
Moved the AddNewPart<T>() method from the OpenXmlPart class to OpenXmlPartContainer class
Added the overloaded AddNewPart<T>() method that receives a relationship Id parameter as input
Supported annotations on document parts
Moved three document enumerations from the Microsoft.Office.DocumentFormat.OpenXml.Packaging namespace to the Microsoft.Office.DocumentFormat.OpenXml namespace
Implemented naming changes
Moved the AddNewPart<T>() Method from the OpenXmlPart Class to OpenXmlPartContainer Class
The Open XML Format SDK June 2007 Technology Preview provided an OpenXMLPart class that enables you to add a known document part at a package level through fixed methods such as the AddCoreFilePropertiesPart() method and the AddExtendedFilePropertiesPart() method. The Open XML Format SDK April 2008 Technology Preview moved the AddNewPart<T>() method from the OpenXMLPart class to the OpenXMLPartContainer class. Now, the Open XML API enables you to add any document part on the package with a generic call, therefore, the coding is made easier.
public class OpenXmlPartContainer{
public void AddNewPart<T>() where T: OpenXmlPart, IFixedContentTypePart
}
Note |
---|
The OpenXmlPart class derives from OpenXmlPartContainer. This is an improvement with no additional functionality. This is not a breaking change. |
Added the Overloaded AddNewPart<T>() Method that Receives a Relationship Id Parameter as Input
The Open XML Format SDK June 2007 Technology Preview provided an OpenXMLPart class that has an AddNewPart method. This method receives the OpenXMLPart object as shown in the code sample below.
public T AddNewPart<T> () where T : OpenXmlPart, IFixedContentTypePart
The Open XML Format SDK April 2008 Technology Preview added an overloaded method to the AddNewPart method that receives a relationship Id parameter as input as shown in the code sample below.
{
public void AddNewPart<T>(String id) where T: OpenXmlPart, IFixedContentTypePart
}
This new overloaded method allows you to create a new document part with an assigned Id. If the value of the Id parameter is null, the Open XML API generates a new Id value for the OpenXMLPart. If the Id parameter already exists, the Open XML API throws a duplicate ID exception.
Additionally, the Open XML Format SDK April 2008 Technology Preview provided an overloaded method to the AddNewPart method that receives a content type and a relationship Id parameter as input as shown in the code sample below.
{
public void AddNewPart<T>(string contentType, String id) where T: OpenXmlPart
}
Note |
---|
This is an addition. It is not a breaking change. |
For more information, see How to: Add a New Document Part to an Office Open XML Package by Using the Open XML API.
Support Annotations on Document Parts
LINQ to XML allows you to associate application-specific information with a particular node in an XML tree. This is useful for tracking miscellaneous information about an element, such as schema information, whether the element is bound to a user interface (UI), or any other kind of application-specific information. For more information, see LINQ to XML Annotations.
The Open XML Format SDK April 2008 Technology Preview provided support for annotations on document parts. The following sample code shows annotation support in the OpenXMLPartContainer class.
{
public void AddAnnotation(Object annotation)
public T Annotation<T>() where T : class
public Object Annotation(Type type)
public IEnumerable<T> Annotations<T>() where T : class
public IEnumerable<Object> Annotations(Type type)
public void RemoveAnnotations<T>() where T : class
public void RemoveAnnotations(Type type)
}
Note |
---|
This is an addition. It is not a breaking change. |
For more information, see How to: Use Annotations to Minimize Serialization and Deserialization by Using the Open XML API.
Moved Three Document Enumerations to a Different Namespace
The Open XML Format SDK June 2007 Technology Preview provided three key enumerations that are part of the Microsoft.Office.DocumentFormat.OpenXml.Packaging namespace:
WordprocessingDocumentType
SpreadsheetDocumentType
PresentationDocumentType
The Open XML Format SDK April 2008 Technology Preview moved the previous enumerations to the Microsoft.Office.DocumentFormat.OpenXml namespace.
Important |
---|
This is a breaking change. |
Implemented Naming Changes
The Open XML Format SDK April 2008 Technology Preview included a set of naming changes. If you have code that uses the Open XML Format SDK June 2007 Technology Preview, you must rename the objects shown in table 1.
Table 1. Naming changes implemented during the Open XML API April Technology Preview
June 2007 Technology Preview |
April 2008 Technology Preview |
---|---|
CommentsPart |
WordprocessingCommentsPart |
DiagramLayoutPart |
DiagramLayoutDefinitionPart |
EmbeddedControlPart |
EmbeddedControlPersistencePart |
EmbeddedControlPartType |
EmbeddedControlPersistencePartType |
PivotCachename such as:
PivotCacheRecordsPart.PivotCacheRecordsPart |
PivotTableCachename such as:
PivotTableCacheRecordsPart.PivotTableCacheRecordsPart |
OpenXmlPart.TargetExt |
OpenXmlPart.TargetFileExtension |
Important |
---|
This is a breaking change. |
Changes in the Open XML Format SDK 1.0
The Open XML Format SDK 1.0 contains the changes described below:
Renames the Microsoft.Office.DocumentFormat.OpenXml dll to DocumentFormat.OpenXml
Renames the Microsoft.Office.DocumentFormat.OpenXml.Packaging namespace to DocumentFormat.OpenXml.Packaging
Renames the Microsoft.Office.DocumentFormat.OpenXml namespace to DocumentFormat.OpenXml
Adds support for validating by using the XmlSchemaSet object
Renames the Microsoft.Office.DocumentFormat.OpenXml dll to DocumentFormat.OpenXML
The Open XML Format SDK April 2008 Technology Preview included the Microsoft.Office.DocumentFormat.OpenXml dll. The Open XML Format SDK 1.0 renames the previous dll to DocumentFormat.OpenXML.
Important |
---|
This is a breaking change. |
Renames the Microsoft.Office.DocumentFormat.OpenXml.Packaging Namespace to DocumentFormat.OpenXML.Packaging
The Open XML Format SDK April 2008 Technology Preview provided the Microsoft.Office.DocumentFormat.OpenXml.Packaging namespace. The Open XML Format SDK 1.0 renames the previous namespace to DocumentFormat.OpenXML.Packaging.
Important |
---|
This is a breaking change. |
Renames Microsoft.Office.DocumentFormat.OpenXml Namespace to DocumentFormat.OpenXML
The Open XML Format SDK April 2008 Technology Preview provided the Microsoft.Office.DocumentFormat.OpenXml namespace. The Open XML Format SDK 1.0 renames the previous namespace to DocumentFormat.OpenXML.
Important |
---|
This is a breaking change. |
Adds Support for Validating by Using the XmlSchemaSet Object
The Open XML Format SDK 1.0 provides an overloaded method of the ValidateXml method that receives a XmlSchemaSet object and the ValidationEventHandler parameter as input. This is shown in the following code sample.
{
public void ValidateXml(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
}
This new overloaded method allows you to validate a document part against a specific XmlSchemaSet object. If the existing XML is not valid according to the XmlSchemaSet object, the Open XML API throws an exception using the information stored in the ValidationEventArgs event arguments. If the ValidationEventHandler parameter has a null value, the XML API throws an exception.
Note |
---|
This is an addition. It is not a breaking change. |