The Open XML SDK provides developers a set of classes to easily create, consume, and manipulate Open XML files without the need for automating Office client applications. The Open XML SDK is designed to let developers build high performance client-side or server-side solutions that perform complex operations using only a small amount of program code. When combined with Office Services, such as Excel and Word Automation Services, the Open XML SDK is able to accomplish many end-to-end scenarios. In addition to the Open XML SDK a new Productivity Tool has been released that provides a number of features designed to improve a developer’s productivity while working with the Open XML SDK and Open XML files. The tool is capable of automatically generating Open XML SDK source code based on document content. The source code can be used to generate all or part of the document. Another feature of the Productivity Tool is the ability to validate Open XML files according to Office 2007 and Office 2010. The Open XML SDK and the Productivity Tool adds important advances in the area of document format interoperability for Office. TOP
After you upgrade Open XML SDK, Visual Studio can’t find previous version assembly, so you need to add new reference for the upgraded SDK again. TOP
4. How many versions of Open XML Format SDK are there and which version is available in your solution?
So far, there have been two versions of Open XML Format SDK: V1 (1.0) and V2 (2.0). V1 is a product version, which can be redistributed in your solution. The latest version is Open XML Format SDK 2.0 RTW, you are able to redistribute the final RTW version of the Open XML SDK 2.0 with your solution. For more information about the product, please download it and see “OpenXMLSDK.chm” file in it.TOP
There is relationship between the sheet and defined names. We should operate on one sheet each time, remove a sheet and update all localSheetId values of remaining worksheet scoped definedName, then go to next one, which will ensure the whole spreadsheet document's validity. For more detailed information, please refer to: forum discussion thread.
Open XML SDK is based on low level DOM. Low level DOM is xml centric, especially comparing to the client OM. So many functions in the App OM cannot be achieved using the SDK easily, for example: inserting a row into a spreadsheet requires the code to re-index all the cells and correct the references in the formulas, etc. The same operation could be easily done through the Excel OM. TOP
It is suggested to use the Productivity Tool. You need to create an empty Excel document as the source document, then format a cell with desired format and save it as the target document. Compare two documents with the productivity tool's Open XML Diff function to see which Open XML part/elements need to be changed. Or you can use the “Code For Diff” function to generate C# code for the difference between the source and target documents. For more detailed information, please refer to: forum discussion thread.TOP
7. How to populate a spreadsheet with data from a real SQL database and create a cool looking chart based on that data
Open XML SDK 2.0 does not have this feature supported. But you can generate a small TOC through Word app, and reflect the TOC parts with Document Reflector component in Open XML SDK Productivity Tool to see how to generate a TOC programmatically. For more detailed information, please refer to: forum discussion thread 1, forum discussion thread 2. TOP
Creating a TOC requires layout engine in order to determine page numbers, but SDK does not perform such layout functionality. There is a workaround here to let Word update the TOC for you. For more detailed information, please refer to: forum discussion thread. TOP
To apply a heading style on specific text, the document should contain a styles part with a heading definition. We suggest using the Tool to see how to do this. For more detailed information, please refer to: forum discussion thread. TOP
To search for the content controls inside a Word file, you should use SdtElement instead of SdtBlock. SdtElement will match all content controls (run, block, etc.). It could be that the Content Control inside table is not SdtBlock. For more detailed information, please refer to: forum discussion thread. TOP
It is suggested to make use of the Productivity Tool. You could create an empty docx document and save it, such as source.docx. Add a watermark to the empty docx and save it as target.docx. Use "Compare Files"-> "View/Hide Code" to see the generated code. For more detailed information, please refer to: forum discussion thread. TOP
To retrieve the text of a word document, you need to be clear about the file format, usually the text content is under Pragraph\Run\Text element. For more detailed information, please refer to: forum discussion thread. TOP
No, currently there is no Microsoft version of the Open XML SDK that works with Java. Open XML SDK should be used on .NET platform. There is no raw C API or COM for the SDK available, too. You can use the Open XML SDK via C# or VB.NET on the .NET platform. For more detailed information, please refer to: forum discussion thread. TOP
No. Format conversion (e.g. converting Open XML file format from/to HTML, RTF, WordOpenXML, XML, etc.) is not covered in Open XML SDK 2.0.
To solve this problem, we suggest using Word Automation Service, which will allow you to convert Word documents to html on the server, without having Word installed. In the meanwhile Eric White is working on a docx to xhtml transformation built on top of the SDK: blog post link.
No. The current design of the SDK cannot decode an encrypted OOXML package or add passwords to/encrypt OOXML documents. You may leverage automation or server-side service to implement this requirement or refer to System.IO.Packaging. Open XML SDK only support features to protect a document such as preventing the sheet from being edited in UI. For detailed information, please refer to: forum discussion thread. TOP
No, Open XML SDK doesn’t support protected files. The SDK always throws exceptions for files that are protected by password and said they are corrupt documents. For more detailed information, please refer to: forum discussion thread. TOP
No. Open XML SDK doesn’t support features like generating digital signature, encryption/decryption of a file. TOP
Yes. You can open a signed document with Open XML SDK 2.0. But it does NOT support verifying the signature. Besides, if you make changes to the content part of the document, the digital signature part will not be automatically updated and thus it is NOT guaranteed to open it using Client OM successfully. TOP
No, Open XML SDK doesn’t support macro. It is a collection of classes that let you create and manipulate Open XML documents. TOP
No. Open XML SDK 2.0 doesn’t support such high level features as building blocks. The Open XML SDK is NOT a replacement for the Office Object Model; and provides no abstraction on top of the file formats. You need to understand the structure of the file formats to leverage the SDK; it doesn't hide it from you. TOP
No. The Open XML SDK is a collection of classes that let you create and manipulate Open XML documents. It is NOT a replacement for the Office Object Model. It does NOT provide application behaviors such as layout (ex. pagination of WordprocessingML documents), formula calculation (which is very common in Excel) or recalculation functionality. TOP
No. Calculating the size of a paragraph is some kinds of layout application behavior which Open XML SDK doesn’t support. For detailed information, please refer to Q29. TOP
- Edited by Lu Zhang Thursday, May 06, 2010 5:43 AM Adding more Q&A