Announcing the Open XML Format SDK 1.0

We have great news for all Open XML developers who have waited so patiently for the fully supported release of the Open XML Format SDK 1.0. Today we published the final bits and online documentation on MSDN. You can get the SDK from the following locations:

What is the Open XML Format SDK?

I talked about this before in previous blog entries, but for those of you who are not familiar with this SDK, here's a brief intro.

The Open XML Format SDK Technology Preview simplifies the task of manipulating Open XML packages. The Open XML Application Programming Interface (API) encapsulates many common tasks that developers perform on Open XML packages, so you can perform complex operations with just a few lines of code. Using this API, you can programmatically generate and manipulate Word 2007 documents, Excel 2007 spreadsheets, and PowerPoint 2007 presentations. The programming model uses managed code, so it's safe for server-side scenarios.

The Open XML Format SDK also provides how-to articles and reference documentation that can help you get started with Open XML programming.

What's New in the Open XML Format SDK 1.0

The Open XML Format SDK 1.0 contains the changes described below:

  1. Renames the Microsoft.Office.DocumentFormat.OpenXml dll to DocumentFormat.OpenXml

  2. Renames the Microsoft.Office.DocumentFormat.OpenXml.Packaging namespace to DocumentFormat.OpenXml.Packaging

  3. Renames the Microsoft.Office.DocumentFormat.OpenXml namespace to DocumentFormat.OpenXml

  4. Adds support for validating by using the XmlSchemaSet object

If you have written code using previous CTP releases, keep in mind that the first three are breaking changes. You need to delete the current reference to the Microsoft.Office.DocumentFormat.OpenXml.dll and replace it with DocumentFormat.OpenXml.dll. Also, you need to change the namespace references to DocumentFormat.OpenXml.Packaging and DocumentFormat.OpenXml.

The last change has to do with a common ask from developers. Previous releases of the CTP allowed you to validate the contents of a part in an Open XML Package against a single schema file. However, it was not possible to validate against a collection of schemas. The Open XML Format SDK 1.0 provides an overloaded method of the ValidateXml method that allows you to validate a document part against a specific XmlSchemaSet object. The following sample code shows you how to validate the XML content of the MainDocumentPart part of a WordprocessingDocument package by calling the ValidateXml method of MainDocumentPart part. You pass a list of schemas to the ValidateXml method as an input parameter.

  

' Visual Basic
' How to validate the contents of a document part against
' a collection of schemas.
Public Shared Sub ValidDocumentContent(document As String,
schemaList As List (Of String))
   Dim schemas As New XmlSchemaSet()
   For Each schemaUri As String In schemaList
schemas.Add(Nothing, schemaUri)
   Next schemaUri
Using wordDoc As WordprocessingDocument =
                    WordprocessingDocument.Open(document, False)
wordDoc.MainDocumentPart.ValidateXml(schemas, Nothing)
   End Using
End Sub

// C#
// How to validate the contents of a document part against
// a collection of schemas.
public static void ValidDocumentContent(string document,
List<string> schemaList) {
XmlSchemaSet schemas = new XmlSchemaSet();
foreach (string schemaUri in schemaList) {
schemas.Add(null, schemaUri);
   }
   using (WordprocessingDocument wordDoc =
          WordprocessingDocument.Open(document, false)) {
wordDoc.MainDocumentPart.ValidateXml(schemas, null);
   }
}

Some additional improvements...

While looking at the class diagram, I noticed that the latest version includes support for a new MailMergeRecipientDataPart. You can find detailed info about this new part here. Some other minor object model changes are documented at the readme.htm file of the download.

Finally, we significantly improved the comments/descriptions of all the members included in the class reference documentation and Intellisense file. It's easier to learn how to use an API when the comments and member descriptions are in good shape.

Roadmap and Development Timeline

The Open XML API Version 1.0 is included with the Open XML Format SDK 1.0 and only contains the Open XML Packaging API. Open XML API Version 2.0 releases should contain all of the Open XML API components, including the Open XML Packaging API with further updates. In the next months, the Open XML Format SDK product team will be releasing CTPs of the Open XML API Version 2.0.

As I mentioned earlier, the latest version has some breaking changes, so the MSDN team is also planning to update the code and content of the Open XML Format SDK related articles such as:

Manipulate Excel 2007 and PowerPoint 2007 Files with the Open XML Object Model (Part 1 of 2)

Manipulate Excel 2007 and PowerPoint 2007 Files with the Open XML Object Model (Part 2 of 2)

Manipulate Word 2007 Files with the Open XML Object Model (Part 1 of 3)

Manipulate Word 2007 Files with the Open XML Object Model (Part 2 of 3)

Manipulate Word 2007 Files with the Open XML Object Model (Part 3 of 3)

Build Server-Side Document Generation Solutions Using the Open XML Object Model (Part 1 of 2)

Build Server-Side Document Generation Solutions Using the Open XML Object Model (Part 2 of 2)

Additional Resources

I recommend that you continue to monitor the following blogs for more news about the Open XML Format SDK:

More code samples: OpenXmlDeveloper.org site

You can also watch Zeyad's and Eric's interview to learn more about the future of the Open XML Format SDK.

Please continue to use the following two resources to ask questions to the product team and provide feedback :

  1. MSDN Forum: Open XML Format SDK: Use the forum to ask questions and provide suggestions. The product team is monitoring and moderating this forum.
  2. MSDN Library: Open XML Format SDK (Online version) Wiki: The online version of the SDK is Wiki enabled. This allows you to add comments and report bugs you find on documentation. To leave comments, use the "Add Community Content" link located at the bottom of each topic.

Enjoy!

Bookmark and Share