Open XML SDK 2.0 FAQ
Commonly Asked Questions
General
1. What is the Open XML SDK 2.0 for Microsoft Office?
2. Where to download Open XML SDK 2.0?
3. How to upgrade Open XML SDK?
Spreadsheet
5. How to delete a sheet which contains a defined-name?
6. How to insert a cell with a format style in Excel document using SDK 2.0?
Wordprocessing
8. How to generate TOC (table of contents) in Word document?
9. How to update TOC (table of contents) dynamically in Word document?
10. How to apply heading styles in Word using SDK 2.0?
11. How to search for the Content Controls inside the Word file with SDK 2.0?
12. How to add a watermark to a Word document?
13. How to generate document from database based on document template?
14. How to merge several documents into one document by using AltChunk?
15. How to embed custom data in the custom XML part in to Word document by using content control?
16. How to retrieve the text content of a Word document?
17. How to add a new CustomXml part a Word document?
Presentation
18. How to add rows to PowerPoint table?
19. How to merge multiple PPT slides?
20. How to find Open XML errors with Open XML SDK Validation?
Else
21. Is there a Java version of Open XML SDK?
22. Can I convert Open XML file format to HTML using SDK 2.0?
23. Can I protect/add passwords to a Word document using SDK 2.0?
24. Can I open a password protected Excel file using SDK 2.0?
25. Can I add digital signature to a Word document using SDK 2.0?
26. Can I open a signed document using SDK 2.0?
27. Can I add or run macro in Word document using SDK 2.0?
28. Can I insert building blocks with the SDK?
29. Can I run formula calculation with SDK 2.0?
30. Can I calculate the size of a paragraph with SDK 2.0?
1. What is the Open XML SDK 2.0 for Microsoft Office?
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
2. Where to download Open XML SDK 2.0?
You can download Open XML SDK 2.0 for Microsoft Office RTW fromhere.TOP
3. How to upgrade Open XML SDK?
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 isOpen 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
5. How to delete a sheet which contains a defined-name?
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
6. How to insert a cell with a format style in Excel document using SDK 2.0?
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
8. How to generate TOC (table of contents) in Word document?
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
9. How to update TOC (table of contents) dynamically in Word document?
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
10. How to apply heading styles in Word using SDK 2.0?
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
11.How to search for the Content Controls inside the Word file with SDK 2.0?
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
12.How to add a watermark to a Word document?
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
13.How to generate document from database based on document template?
14.How to merge several documents into one document by using AltChunk?
15.How to embed custom data in the custom XML part in to Word document by using content control?
16. How to retrieve the text content of a Word document?
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
17. How to add a new CustomXml part a Word document?
To add a new CustomXmlPart, you should specify the CustomXmlPartType, which is different from the API in Open XML SDK V1. For more detailed information, please refer to: forum discussion thread. TOP
18.How to add rows to PowerPoint table?
Adding rows to PowerPoint table is complex. You could make use of the Productivity Tool to generate the code. For more detailed information, please refer to:forum discussion thread.TOP
19.How to merge multiple PPT slides?
20.How to find Open XML errors with Open XML SDK Validation?
21.Is there a Java version of Open XML SDK?
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
22.Can I convert Open XML file format to HTML using SDK 2.0?
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.
For more detailed information about file format conversion, please refer to:forum discussion thread 1,forum discussion thread 2 and forum discussion thread 3.TOP
23.Can I protect/add passwords to a Word document using SDK 2.0?
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
24.Can I open a password protected Excel file using SDK 2.0?
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
25.Can I add digital signature to a Word document using SDK 2.0?
No. Open XML SDK doesn’t support features like generating digital signature, encryption/decryption of a file.TOP
26.Can I open a signed document using SDK 2.0?
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
27.Can I add or run macro in Word document using SDK 2.0?
No, Open XML SDK doesn’t support macro. It is a collection of classes that let you create and manipulate Open XML documents.TOP
28.Can I insert building blocks with the SDK?
No. Open XML SDK 2.0 doesn’t support such high level features as building blocks. The Open XML SDK isNOT 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
29.Can I run formula calculation with SDK 2.0?
No. The Open XML SDK is a collection of classes that let you create and manipulate Open XML documents. It isNOT 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
30.Can I calculate the size of a paragraph with SDK 2.0?
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