Open XML Format SDK April CTP - Released !!
It's there, Open XML SDK April CTP is released, it's for all of us - the proud office developers :) I was waiting for it! Erica - thanks a lot ... (in fact I was searching for this last week, but couldn't find it ... well, I was a bit early). Also, you might want to look at the future plans (which looks concrete based on the previous experience with the team ... hey - you guys are doing a phenomenal job!). You can download it from here
And - why am I so exited? Because among all the other changes, there is the annotation thing which is super cool, this enables you to write efficient code by minimizing serialization and de-serialization.
That is to say - You can associate arbitrary data with a particular part(think of it as VB 6.0 tag property on steroids). For an example, After opening an Open XML document, you may want to read a part into a System.Xml.Linq.XDocument, query the XDocument object using LINQ to XML, perhaps modify the XDocument, and then serialize the XDocument back into the package. If you need to read the XML from the part, parse it, modify it, and then serialize it back into the package every time that you want to access the XML, your code will not perform as well as if you read the XML from the part only once, then use it as appropriate, and then serialize back into the part only once. If, once having read the XML from the part, you add the XDocument instance as an annotation on the part, you can easily retrieve the annotation instead of rereading the XML each time you need to access it. Annotations allow you to associate any object with an OpenXmlPartContainer (the base class of OpenXmlPart) in a type safe way.
An example code would be -
Module LocalExtensions ' How to create and extension method <Extension()> _ Function GetXDocument(ByVal part As OpenXmlPart) As XDocument Dim xdoc As XDocument = part.Annotation(Of XDocument)() If (xdoc Is Nothing = False) Then Return xdoc End If Using streamReader As StreamReader = new StreamReader(part.GetStream()) xdoc = XDocument.Load(XmlReader.Create(streamReader)) part.AddAnnotation(xdoc) End Using Return xdoc End Function End Module
For more details regarding annotations, have a look at http://msdn2.microsoft.com/en-us/library/cc471941.aspx . Believe me, annotations is really a great thing, Eric also agrees with me
Not responsible for errors in content, meaning, tact, or judgment. Live and let live. Toes go in first. I didn't do it. Enjoy.