views:

69

answers:

2

This is closely related to another question I asked: Is there functionality that is NOT exposed in the OpenXML SDK v2?

I am currently working with OpenXML files manually. I recently had a look at the SDK and was surprised to find that it looked pretty low level, quite similar in fact to the helper classes I have created myself. My question is what exactly does the SDK v2 take care of that you would have to do manually when coding by hand with an XML library?

For example, would it automatically patch the _rels files when deleting a power point slide?

+2  A: 

As a starting point, read this from the Brian Jones & Zeyad Rajabi blog.

I don't know of a side-by-side comparison, but the following articles/videos do discuss the two:

Finally, this is a What's New for 2.0 - it can be assumed that neither 1.0 or hand-coding have these benefits.

Otaku
+2  A: 

In addition to Otaku's links, this shows an example (near the bottom) of navigating an OpenXML document using the IO.Packaging namespace versus the SDK.

Just like Microsoft states on the download page for the SDK:

The Open XML SDK 2.0 for Microsoft Office is built on top of the System.IO.Packaging API and provides strongly typed part classes to manipulate Open XML documents. The SDK also uses the .NET Framework Language-Integrated Query (LINQ) technology to provide strongly typed object access to the XML content inside the parts of Open XML documents.

The Open XML SDK 2.0 simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. 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.

I've worked pretty much only with the SDK, but for example, it's nice to be able to grab a table out of a Word document by just using:

Table table = wordprocessingDocument.MainDocumentPart.Document.Body.Elements<Table>().First();

(I mean, assuming it's the first table)

I'd say the SDK does exactly what it seeks to do by providing a sort of intuitive object-based way to work with documents.

As far as automatically patching the relationships -- no, it doesn't do that. And looking back at how you actually state the question, I guess I might even say that (and I'm fairly new to Open XML so this isn't gospel by means) the SDK2.0 doesn't necessarily offer any extra functionality, so much as it offers a more convenient way to achieve the same functionality. For example, you still need to know about those relationships when you delete an element, but it's a lot easier to deal with them.

Also, there's been some efforts on top of the SDK to add even more abstraction -- see, for example, ExtremeML (Excel library only. I've never used it but I think it does get into things like patching relationships).

So I'm sorry if I've rambled a bit too much here. But I guess my short answer is: there's probably not extra functionality, but there's a nice level of abstraction that makes achieving certain functionality a lot easier to handle -- and if you've been doing it by hand up until now, you'll certainly have the understanding of the OPC to understand what exactly is being abstracted.

M_R_H