Open XML SDK v2 FAQ Part2
-
יום שישי 05 מרץ 2010 05:55
Open XML SDK 2.0 FAQ Part2
Learning ResourcesTool
Download & Install
You could down load it together with SDK. To use the productivity tool, you must first install the Open XML SDK 2.0 for Microsoft Office. If you have installed previous version of the tool or SDK, you have to uninstall it first. The Tool is under path “Open XML SDK\V2.0\tool”.
What can be done by the Tool?
· Generate Open XML SDK source code based on document content. The source code could be used to regenerate all or part of the document.
· Compare source and target Open XML documents to highlight the differences. You can reveal the differences in the document part structure as well as the content differences. Based on those differences, you can generate source code that employs the Open XML SDK 2.0 to create the target document from the source.
· Validate documents. You can validate an entire document, specific document parts or a segment of content against Office 2007 or Office 2010 file formats.
· Display documentation for the Open XML SDK 2.0, the ISO/IEC 29500 Open XML File Formats standard, and the Microsoft Office implementer notes.
For more information about how to use the Tool, please select “help”->”help” from the menu.
How to solve questions regarding the file formats using the Tool?
Generally, it takes the following steps to generate sample code: make some changes to the source document and save it as a different document as the target document; compare the source and target to see what has been changed in the package. In this case, we take “how to add a table in a Word document” as an example.
1. Create an empty docx document and save it, such as “source.docx”.
2. Add a table (for instance, a table with 2 rows and 1 column) to the empty docx and save it as “target.docx”.
3. Open the Tool; click "Compare Files" to compare the “source.docx” and “target.docx” files.
4. In the "File Comparison" tab, click "View Part Diff" to show the differences between the selected two parts (in this case, we select “/word/document.xml”).
5. Click “View Part code” to see the complete sample code on how to add a table.
Standard
· ISO/IEC 29500
· ECMA – 376 (Office Open XML File Formats, ECMA-376 2nd edition is technically aligned with ISO/IEC 29500): http://www.ecma-international.org/publications/standards/Ecma-376.htm
How-to Articles
These how-to topics help users find out how to work with the Open XML Application Programming Interface (API) through sample code that is easy to understand. You can find these articles from:
· MSDN Online: http://msdn.microsoft.com/en-us/library/bb491088(office.14).aspx
· OpenXMLSDK.chm: search “how to” or other related key words to a specific topic.
Topics covered in these articles:
v Presentations
o How to: Add a Comment to a Slide in a Presentation by Using the OpenXML API
o How to: Apply a Theme to a Presentation by Using the OpenXML API
o How to: Change the Fill Color of a Shape in a Presentation by Using the OpenXML API
o How to: Count the Slides in a Presentation by Using the OpenXML API
o How to: Delete a Slide from a Presentation by Using the OpenXML API
o How to: Get All the Text in a Slide in a Presentation by Using the OpenXML API
o How to: Get the Titles of All the Slides in a Presentation by Using the OpenXML API
o How to: Insert a New Slide into a Presentation by Using the OpenXML API
o How to: Move a Slide to a New Position in a Presentation by Using the OpenXML API
o How to: Move a Paragraph from One Presentation to Another by Using the Open XML API
o How to: Get All the External Hyperlinks in a Presentation by Using the OpenXML API
v Packages and General
o How to: Validate an Office Open XML Package by Using the Open XML API
o How to: Validate an Open XML Package against a Collection of Schemas by Using the Open XML API
o How to: Validate the Contents of a Document Part in an Open XML Package by Using the Open XML API
o How to: Add an Image Part to an Open XML Package by Using the Open XML API
o How to: Add a New Document Part to an Open XML Package by Using the Open XML API
o How to: Get the Contents of a Document Part from an Open XML Package by Using the Open XML API
o How to: Remove a Document Part from an Open XML Package by Using the Open XML API
o How to: Replace a Document Part in an Office Open XML Package by Using the Open XML API
o How to: Set the Font for a Text Run by Using the Open XML API
o How to: Use Annotations to Minimize Serialization and Deserialization by Using the Open XML API
v Spreadsheets
o How to: Insert a Chart into a Spreadsheet Document Using the Open XML API
o How to: Calculate the Sum of a Range of Cells in a Spreadsheet Document Using the Open XML API
o How to: Delete a Row of Text from a Spreadsheet Document by Using the Open XML API
o How to: Delete Text from a Cell in a Spreadsheet Document by Using the Open XML API
o How to: Get a Column Heading in a Spreadsheet Document by Using the Open XML API
o How to: Get Worksheet Information from an Open XML Package by Using the Open XML API
o How to: Insert a New Worksheet into a Spreadsheet Document by Using the Open XML API
o How to: Insert Text into a Cell in a Spreadsheet Document by Using the Open XML API
o How to: Merge Two Adjacent Cells in a Spreadsheet Document by Using the Open XML API
v Wordprocessing
o How to: Accept All Revisions in a Wordprocessing Document by Using the Open XML API
o How to: Apply a Style to a Paragraph in a Wordprocessing Document by Using the Open XML API
o How to: Change Text in a Table in a Wordprocessing Document by Using the Open XML API
o How to: Delete Comments By Author in a Wordprocessing Document by Using the Open XML API
o How to: Delete the Headers and Footers in a Wordprocessing Document by Using the Open XML API
o How to: Insert a Comment into a Wordprocessing Document by Using the Open XML API
o How to: Insert a Table into a Wordprocessing Document by Using the Open XML API
o How to: Remove Hidden Text from a Wordprocessing Document by Using the Open XML API
o How to: Replace the Header in a Wordprocessing Document by Using the Open XML API
o How to: Retrieve Comments from a Wordprocessing Document by Using the Open XML API
o How to: Retrieve Property Values from a Wordprocessing Document by Using the Open XML API
v Others (will be available soon)
o How to open/create a word/excel/PPT document
o How to save changes in word/excel/PPT documents
o How to close a word/excel/PPT document
o How to open documents in Office 2007 context
o How to validate Office documents and understand validation errors
o How to access xml part content in memory
o How to traverse parts in a document
o How to set values on OpenXmlAttribute objects
o How to search content in a part
o Stream model processing Office documents
§ How to use OpenXmlReader to load an XML part
§ How to use OpenXmlWriter to write out an XML part
o How to change attribute values
o How to search for particular elements
o How to add an attribute
o How to add an element
o How to remove an element
o How to remove an attribute
כל התגובות
-
יום שישי 28 מאי 2010 15:30
Hi Lanqing,
You've stopped at a very interesting bit: the stream model! I'd be very interested in seeing the FAQ post related to using OpenXmlReader to read in an XML part in a forward-only, non-cached manner. Specifically I have to read in a spreadsheet document this way.
Thanks.
Andrew
-
יום שני 31 מאי 2010 07:52
Hi Andrew,
Thanks for your feedback.
Zeyad has just posted a blog on this topic: http://blogs.msdn.com/b/brian_jones/archive/2010/05/27/parsing-and-reading-large-excel-files-with-the-open-xml-sdk.aspx, which I think might be helpful to you.
Thanks,
Lu
-
יום שני 31 מאי 2010 12:41
Thanks - I'll check it out.
Andrew
-
יום שלישי 08 פברואר 2011 08:20
Thanks very much. It's very intresting. And maybe these available soon topics help me for http://social.msdn.microsoft.com/Forums/en-US/oxmlsdk/thread/efdc16d9-f6c6-4f1e-a75a-b285e78689fa ask.
o Stream model processing Office documents
§ How to use OpenXmlReader to load an XML part
§ How to use OpenXmlWriter to write out an XML part