Announcing the Release of the December 2009 CTP for the Open XML SDK

I'm really happy to announce the 4th CTP for the Open XML SDK 2.0 for Microsoft Office! There were four major improvements we made to the SDK:

  1. Full support for the Office 2010 Open XML formats
  2. Office 2010 schema and semantic level validation
  3. General improvements based on a recent Open XML SDK usability study
  4. Open XML SDK tools improvement

Full Support for the Office 2010 Open XML Formats

With the latest CTP you are able to create, edit, and consume Office generated Open XML formats for either Office 2007 or Office 2010. Looking back at the original Open XML SDK architecture diagram I showed you when we first announced the Open XML SDK, we have extended the base level layer to include Office 2010 support:

image

What does that mean? Well, let me show you some examples.

The Open XML Packaging API component allows you to add/remove parts within an Open XML package. This component functions by providing you strongly typed classes for every part within a package. In Office 2010 we've added new parts to the package in order to support some of our new features. With this CTP you are able to deal with these new parts with classes. For example, Word 2010 added a new part called stylesWithEffects. This part is used to help round trip styles that are based on Word's new text effects feature.

image

 

The Open XML Low Level DOM component allows you to create, edit, or consume xml contained in parts contained within an Open XML package. Like the packaging API component, this component functions by providing you with strongly typed classes for every element supported within the xml. For example, imagine we have the following text in a Word document, which uses the new text effects feature glow:

image

 

This text is represented in xml and the Open XML SDK as the following:

XML

Open XML SDK Code

 clip_image001

using W14 = DocumentFormat.OpenXml.Office2010.Word;   ...   Run run2 = new Run();   RunProperties runProperties1 = new RunProperties();   W14.Glow glow1 = new W14.Glow() { GlowRadius = 228600L };   W14.SchemeColor schemeColor1 = new W14.SchemeColor() { Val = W14.SchemeColorValues.ExtraSchemeColor5 }; W14.Alpha alpha1 = new W14.Alpha() { Val = 60000 }; W14.SaturationModulation saturationModulation1 = new W14.SaturationModulation() { Val = 175000 }; schemeColor1.Append(alpha1); schemeColor1.Append(saturationModulation1);   glow1.Append(schemeColor1); runProperties1.Append(glow1); Text text2 = new Text(); text2.Text = "text effects";   ...

As you can see from the code snippet above, leveraging the Office 2010 Open XML functionality of the SDK is as simple as including the appropriate set of namespace references.

Office 2010 Schema and Semantic Level Validation

In a previous post I talked about how to find Open XML errors with the Open XML SDK validation functionality. In that post, I talked about finding both schema and semantic (constraints defined in the prose of the documentation that are not represented in schema markup) validation errors. With the latest SDK CTP you are now able to differentiate between errors specific to Office 2007 or Office 2010. The code to validate a file is pretty much the same as the code I showed in the previous post mentioned. The major difference is that we moved the validation functionality to be under its own namespace reference: "using DocumentFormat.OpenXml.Validation". We moved this functionality to its own namespace to improve discoverability of the feature. The OpenXmlValidator class now takes in an enumeration called FileFormatVersions that allows you to specify either Office 2007 or 2010:

image

 

The validation functionality also has the ability to automatically deal with extensibility markup, like alternate content blocks, as defined by the Open XML standard.

General Open XML SDK Improvements

We recently conducted a usability study for the Open XML SDK where we asked participants to complete a set of tasks. Based on the results of the study we found that users had issues around the complexity of the Open XML SDK Open methods. In the August 2009 CTP of the SDK, each of the classes WordprocessingDocument, SpreadsheetDocument and PresentationDocument had nine overloaded Open methods. For example, let's look at the WordprocessingDocument class as an example:

  • public static WordprocessingDocument Open(Package package);
  • public static WordprocessingDocument Open(Package package, bool autoSave);
  • public static WordprocessingDocument Open(Stream stream, bool isEditable);
  • public static WordprocessingDocument Open(string path, bool isEditable);
  • public static WordprocessingDocument Open(Package package, MCMode mode, bool processMCInWholePackage);
  • public static WordprocessingDocument Open(Stream stream, bool isEditable, bool autoSave);
  • public static WordprocessingDocument Open(string path, bool isEditable, bool autoSave);
  • public static WordprocessingDocument Open(Stream stream, bool isEditable, MCMode mode, bool processMCInWholePackage);
  • public static WordprocessingDocument Open(string path, bool isEditable, MCMode mode, bool processMCInWholePackage);

Now with the latest CTP, the number of overloaded methods for Open has been reduced to six methods:

  • public static WordprocessingDocument Open(Package package);
  • public static WordprocessingDocument Open(Package package, OpenSettings openSettings);
  • public static WordprocessingDocument Open(Stream stream, bool isEditable);
  • public static WordprocessingDocument Open(string path, bool isEditable);
  • public static WordprocessingDocument Open(Stream stream, bool isEditable, OpenSettings openSettings);
  • public static WordprocessingDocument Open(string path, bool isEditable, OpenSettings openSettings);

Advanced open settings are now part of a new class called OpenSettings. This class allows you to pre-process documents according to markup compatibility, auto save files, or caps the open method to deal with a specific number of characters within a part. Hopefully this change will make it easier to deal with the Open method.

Open XML SDK Tool Improvements

The last major improvement I want to call out is around the free Open XML SDK tool that comes with the SDK. In the August 2009 CTP, the Open XML SDK shipped with three separate tools:

  • Document Reflector
  • Open XML Class Explorer
  • Open XML Diff

Based on feedback we have separated the download of the tools from the SDK dll. In other words, the Open XML SDK download page now has two download links: one for the SDK dll and one for a new consolidated Open XML SDK tool. As of the December 2009 CTP, the Open XML SDK tools are consolidated into one tool. In addition we've added some new functionality to the SDK. Here is a video that shows you an overview of the new tool:

The new tool adds the following functionality:

  • Documentation for Office 2010 Open XML formats
  • Validation functionality. This feature allows you to validate Open XML files according to Office 2007 or Office 2010
  • New reflection feature that combines reflection with the Open XML Diff feature. This new feature allows you to automatically generate SDK code that transforms one document into another document

Let us know what you think of the new tool. I think of the new tool as the Open XML version of Macro Recording.

More Feedback Always Welcome

Please continue to send us your feedback, either on this blog or at our Microsoft Connect site for the Open XML SDK. We look forward to hearing from you.

Zeyad Rajabi