Microsoft has released the RTM version of Open XML SDK 2.0 for Microsoft Office today. This is great news and another big step forward for developers who write software systems that read and write Open XML documents. Till now, we’ve been working with Community Technology Previews (CTP) that had licensing restrictions (you couldn’t ‘go live’ with solutions). We now have a stable platform on which we can build the next generation of Open XML solutions.
As with the CTPs, the RTM version of the Open XML SDK consists of two principle components:
A .NET managed class library that provides capabilities for reading, writing, modifying, and validating Open XML documents.
A productivity tool that includes the ability to diff Open XML documents, a C# code generator, and tools to explore and read about the class library and the standard.
About the Library
Some of the key characteristics of the library are:
You can use a powerful functional programming approach to write applications that generate documents, spreadsheets, and presentations.
You can use Language Integrated Query (LINQ) to retrieve data and content from documents, spreadsheets, and presentations.
You can write code to open, modify, and save documents.
You can use validation functionality to be more certain that your documents conform to the IS29500 standard and will be able to be opened using Microsoft Office and other conforming applications. Document formats, by their very nature, are involved. The validation functionality in the Open XML SDK is a big help when writing real-world solutions.
About the Tool
Key features of the tool are:
You can compare two Open XML documents to see exact changes in their markup. This is one of the best ways to learn about Open XML markup. If you want to understand which elements and attributes represent a feature that you want to interact with, create a document without the feature, copy the document to a new document, modify the new document, and compare to the old. After determining the elements and attributes that changed, you can research them in the Open XML specification.
You can build a document generation program with a minimum of effort. You supply the tool with a sample document. You can then generate C# code that that will generate the entire document, a specific part, or a specific element with its children elements. This code is generated in a style that takes advantage of ‘functional construction’. By this, I mean that any element (or its descendant elements) can be generated in a single expression. You don’t need to write multiple statements. This ability to generate content in an expression instead of a statement means that you can use LINQ queries and projections to formulate new descendant content for an element. It’s a powerful approach.
The ability to explore the Open XML specification, the implementation notes, and the Open XML SDK class hierarchy in the tool means that you have one integrated tool to do much of the work that is necessary to build sophisticated document generation systems.
For more information on the Open XML SDK, samples, snippets, and articles, go to the Open XML Developer Center.
Gray Knowlton posted about how the Open XML SDK contributes to interoperability.
Erika Ehrli Cabral has a great post that contains a list of a lot of new content available for the Open XML SDK.
When I first started working with the Open XML document formats, the tools and resources available to me were quite limited. The only released library was System.IO.Packaging. The Open XML SDK version 1.0 was still a CTP. We’ve come a very long way since then. Congratulations to the development team and to everyone else who worked on this excellent technology.