├── CONTRIBUTING.md ├── Contribution License Agreement.pdf ├── LICENSE.md ├── README.md ├── en-us └── OpenXMLCon │ ├── README.md │ └── articles │ ├── 03636fa2-be44-4e8d-9c26-7d38415bb459.md │ ├── 03ac59c4-49a6-4721-8931-d045c4c9ddde.md │ ├── 0a81a7fb-c431-4f53-a199-e72eea91f360.md │ ├── 0aa2aef3-b329-4ccc-8f25-9660c083e14e.md │ ├── 119a7eb6-9a02-4914-b651-9ba090bf7994.md │ ├── 124cb0a0-cc47-433f-bad0-06b793890650.md │ ├── 15e26fbd-fc23-466a-a7cc-b7584ba8f821.md │ ├── 1771fc05-dd94-40e3-a788-6a13809d64f3.md │ ├── 17abd341-abe9-4eee-9bb3-27fded0b04d2.md │ ├── 1ec087c3-8b9e-46a9-9c3c-14586908eb0e.md │ ├── 1fbc6d30-bfe4-4b2b-8fd8-0c5a400d1e03.md │ ├── 20258c39-9411-41f2-8463-e94a4b0fa326.md │ ├── 22f973f4-58d1-4dd4-943e-a15ac2571b7c.md │ ├── 281776d0-be75-46eb-8fdc-a1f656291175.md │ ├── 2ac3a285-8060-4f89-ae12-38ddbee00094.md │ ├── 30dfce05-00c1-423e-b4b4-149329fdf184.md │ ├── 360318b5-9d17-42a1-b707-c3ccd1a89c97.md │ ├── 36664cc7-30ef-4e9b-b569-846a9e404219.md │ ├── 3b35a153-c8ff-4dc7-96d5-02c515f31770.md │ ├── 3b892a6a-2972-461e-94a9-0a1ede854bda.md │ ├── 3d4a800e-64f0-4715-919f-a8f7d92a5c37.md │ ├── 3e9ca812-460e-442e-8257-38f523a53dc6.md │ ├── 403abe97-7ab2-40ba-92c0-d6312a6d10c8.md │ ├── 41c001da-204e-4669-a722-76c9f7928281.md │ ├── 43c49a6d-96b5-4e87-a5bf-01629d61aad4.md │ ├── 474f0a6c-62c8-4f04-b3f9-cd613a6e48d0.md │ ├── 4b395c48-b469-4d69-b229-d4bad3f3dd8b.md │ ├── 4fbda0e3-5676-4a8f-ba62-3fba59fa418b.md │ ├── 4fcb7fbb-0796-4737-8f05-acbcfa9e1a06.md │ ├── 56aeeed4-24ce-42ba-a236-6fec6785dd93.md │ ├── 56ba8cee-d789-4a03-b8ff-b161af0788ff.md │ ├── 56d28bc5-c9ea-4c0e-b2f5-20be9c16d290.md │ ├── 5adddb6e-545e-4fba-ae35-cc4682e3eda7.md │ ├── 5ded6212-e8d4-4206-9025-cb5991bd2f80.md │ ├── 6079a1ae-4567-4d99-b350-b819fd06fe5c.md │ ├── 620e86b5-49f2-43dc-85d4-9c7456c09552.md │ ├── 625bf571-5630-47f8-953f-e9e1a93e3229.md │ ├── 65c377d2-1763-4bb6-8915-bc6839ccf62d.md │ ├── 67edb37c-cfec-461c-b616-5a8b7d074c91.md │ ├── 69f7c94e-2b8c-4bec-be8c-31933e2ee042.md │ ├── 6de46612-f864-413f-a504-11ea85f1f88f.md │ ├── 70839c86-36ef-4b67-a682-abd5114b2bfe.md │ ├── 73747a65-0857-4fd4-8362-3613f4169203.md │ ├── 73cbca2d-3603-45a5-8a73-c2e718376b01.md │ ├── 75cff172-b29d-475a-8eb5-d8e90642f015.md │ ├── 7808dcc4-8f50-42c4-bad1-d69fe5f045fe.md │ ├── 7b72277f-3c5e-43ba-bbd8-7467cf532c95.md │ ├── 7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md │ ├── 7dbfd93c-a9e3-4465-9b57-4a043b07b807.md │ ├── 7dfd78a3-e233-4abd-8c17-1e384780d3ec.md │ ├── 7fde676b-81b6-4210-82bf-f74d0d925dec.md │ ├── 80cdc1e8-d023-4886-b8d6-ee26327df739.md │ ├── 82deb499-7479-474d-9d89-c4847e6f3649.md │ ├── 8a9117f7-066e-409c-8681-a26610c0eede.md │ ├── 8d465a77-6c1b-453a-8375-ecf80d2f1bdc.md │ ├── 8dc8a6ac-aa9e-47cc-b45e-e128fcec3c57.md │ ├── 944036fa-9251-408f-86cb-2351a5f8cd48.md │ ├── 95fd9dcd-41e9-4e83-9191-2f3110ae73d5.md │ ├── 96697c37-3fa7-4814-85b6-657439435ce1.md │ ├── 98781b17-8de4-46e9-b29a-5b4033665491.md │ ├── 9d390cf8-1654-4a75-b3b8-4aba86ed1476.md │ ├── a0c1e144-2080-4470-bd4b-ed98f1399374.md │ ├── a20bf30b-204e-4c57-8ca3-badf4b0b3e03.md │ ├── a6d35b76-d12a-460c-9d9d-2334abde759e.md │ ├── ada81388-9ed2-43f4-ab2c-2bb82f711e90.md │ ├── ae8c98d9-dd11-4b75-804c-165095d60ffd.md │ ├── b0d3d890-431a-4838-89dc-1f0dccd5dcd0.md │ ├── b3406fcc-f10b-4075-a18f-116400f35faf.md │ ├── b3890e64-51d1-4643-8d07-2c9d8e060000.md │ ├── b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md │ ├── b6f429a7-4489-4155-b713-2139f3add8c2.md │ ├── b6f5afca-5feb-4003-b803-55dd2f9bf6d2.md │ ├── b7d5d1fd-dcdf-4f88-9d57-884562c8144f.md │ ├── bb5319c8-ee99-4862-937b-94dcae8deaca.md │ ├── bead244f-b551-477f-a296-41ead7bfcf5c.md │ ├── c38f2c94-f0b5-4bb5-8c95-02e556d4e9f1.md │ ├── c66a64ca-cb0d-4acc-9d05-535b5bbb8c96.md │ ├── c811c2c7-1066-45a5-a724-33d0fbfd5284.md │ ├── c984c74e-2f06-4aba-a64b-2bb928b2929e.md │ ├── c9b2ce55-548c-4443-8d2e-08fe1f06b7d7.md │ ├── cbb4547e-45fa-48ee-872e-8727beec6dfa.md │ ├── cfb75725-f3a7-43c0-85f4-7bb4c3f448ca.md │ ├── d4ef73a6-888a-4476-9e21-4df76782127f.md │ ├── d57e9b7d-b271-4c8d-998f-b7ca3eb6c850.md │ ├── d6daf04e-3e45-4570-a184-8f0449c7ab91.md │ ├── d7575014-8187-4e55-bafa-15bc317bf8c8.md │ ├── d7f0f1d3-bcf9-40b5-aaa4-4a08d862ac8e.md │ ├── dabc2fad-9ef8-4aee-9d77-ebec147b0e24.md │ ├── dd28d239-42be-42a9-893e-b65338fe184e.md │ ├── dd42a9a3-5c16-4cab-ad6d-506cf822ec7a.md │ ├── debad542-5915-45ad-a71c-eeb95b40ec1a.md │ ├── e3adae2b-c7e8-45f4-b1fc-93d937f4b3b1.md │ ├── e4e5a2e5-a97e-47b9-a263-6723bd4230a1.md │ ├── e5e9c6ba-b422-4639-bb8c-6da521307f13.md │ ├── ec83a076-9d71-49d1-915f-e7090f74c13a.md │ ├── edbe267a-ced9-43fd-a702-fd0165cb3438.md │ ├── ee6c905b-26c5-4aed-a414-9aa826364a23.md │ ├── ef817bef-27cd-4c2a-acf3-b7bba17e6e1e.md │ ├── f6a9ae68-7989-4208-97f5-3c945137a0ab.md │ ├── fb4b293c-9a23-44b7-8af6-afe5fac6611a.md │ ├── fdb29547-c295-4e7d-9fc5-d86d8d8c2967.md │ ├── fe261589-7b04-47df-8ee9-26b444e587b0.md │ ├── fe780fcd-ed8f-4ee1-938e-cf3bb358ccae.md │ ├── ffdf5bd3-53f5-4f48-8946-11a0287fb107.md │ └── images │ ├── OpenXMLCon_HowToConvertDOCMtoDOCX_Fig1.gif │ ├── OpenXmlCon_CreateCharacterStyle_Fig1.gif │ ├── OpenXmlCon_HowToReplaceStyles_Fig1.gif │ ├── OpenXmlCon_HowToSetCustomPropertyFig2.gif │ ├── OpenXmlCon_HowToSetCustomProperty_Fig1.gif │ ├── a-theme01.gif │ ├── odc_oxml_ppt_documentstructure_fig01.jpg │ ├── odc_oxml_ppt_documentstructure_fig02.jpg │ ├── odc_oxml_wd_documentstructure_fig01.jpg │ ├── odc_oxml_xl_documentstructure_fig01.gif │ ├── odc_oxml_xl_documentstructure_fig02.gif │ ├── w-comment01.gif │ ├── w-delparagraphs01.gif │ ├── w-delparagraphs02.gif │ └── w-headerref01.gif └── rest-api ├── android ├── getting-started-Office-365-APIs-android.md └── images │ ├── O365APIs_RunningApp1-50Percent.png │ ├── O365APIs_RunningApp2-50Percent.png │ ├── O365APIs_RunningApp3.png │ ├── O365APIs_RunningApp4.png │ └── O365APIs_RunningApp5.png ├── dotnet └── getting-started-Office-365-APIs-dotnet.md ├── ios ├── getting-started-Office-365-APIs-ios.md └── setup-ios.md ├── node └── getting-started-Office-365-APIs-node.md ├── php └── getting-started-Office-365-APIs-php.md ├── python └── getting-started-Office-365-APIs-python.md └── ruby └── getting-started-Office-365-APIs-ruby.md /Contribution License Agreement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/Contribution License Agreement.pdf -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This repository is licensed under the [Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States](https://creativecommons.org/licenses/by-nc-nd/3.0/us) license. 2 | 3 | Copyright (c) Microsoft Corporation. Distributed under the following terms: 4 | 5 | 1. Microsoft and any contributors to this project each grants you a license, under its respective copyrights, to the Microsoft Office Documentation under the [Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License](https://creativecommons.org/licenses/by-nc-nd/3.0/us/legalcode). In addition, with respect to any sample code contained in the documentation, Microsoft and any such contributors grants you an additional license, under its respective intellectual property rights, to use the code to develop or design your software for Microsoft Office and/or Office 365. 6 | 7 | 2. Microsoft, Microsoft Office, Office 365, Windows, Windows Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. This license does not grant you rights to use any names, logos, or trademarks. For Microsoft’s general trademark guidelines, go to [http://go.microsoft.com/fwlink/?LinkID=254653](http://go.microsoft.com/fwlink/?LinkID=254653). 8 | 9 | 3. Microsoft and any contributors reserves all others rights, whether under copyrights, patents, or trademarks, or by implication, estoppel or otherwise. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | Thank you for your interest in Office developer documentation! 4 | 5 | ## Ways to contribute 6 | 7 | You can contribute to [Office developer documentation](https://developer.microsoft.com/office/docs) in a few different ways: 8 | 9 | * Contribute to articles via the [public Office developer docs repo](https://github.com/OfficeDev/office-content)* 10 | * Report documentation bugs via [GitHub Issues](https://github.com/OfficeDev/office-content/issues) 11 | * Add documentation requests to the [Office/SharePoint developer UserVoice](http://officespdev.uservoice.com) 12 | 13 | *\*We're only taking documentation contributions for the OpenXML Conceptual content at this time* 14 | 15 | ## Repository organization 16 | 17 | The content in the office-content repository is grouped first by article language, then by topic. The README.md file at the root of each topic directory specifies the structure of the articles within the topic. 18 | 19 | Article within each topic are named by MSDN GUID rather than title name. This is a side effect of our document management process and cannot be changed at this time. We highly recommend using the table of contents within each topic directory (see links below) to navigate to the files you wish to view or edit. 20 | 21 | ## Articles in this repository 22 | ### Open XML 23 | 24 | - [Open XML Conceptual Content \[en-us\]](https://github.com/OfficeDev/office-content/tree/master/en-us/OpenXMLCon) 25 | 26 | ## Before we can accept your pull request 27 | 28 | ### Minor corrections 29 | 30 | Minor corrections or clarifications you submit for documentation and code examples in this repository do not require a Contribution License Agreement (CLA). Submissions are taken in the form of pull requests. We will do our best to review pull requests within ten business days. 31 | 32 | 33 | ### Larger submissions 34 | 35 | If you submit new or significant changes to documentation and code examples, you need to send a signed Contribution License Agreement (CLA) before we can accept your pull request if you are in one of these groups: 36 | 37 | * Members of the Microsoft Open Technologies group. 38 | * Contributors who don't work for Microsoft. 39 | 40 | As a community member, **you must sign the Contribution License Agreement (CLA) before you can contribute large submissions to this project**, but you only need complete and submit the documentation once. Please carefully review the document; you may also need to have your employer sign the document. 41 | 42 | Signing the Contribution License Agreement (CLA) does not grant you rights to commit to the main repository, but it does mean that the Office Developer and Content Publishing teams will be able to review and consider your contributions and you will get credit if we do. 43 | 44 | You can download the Contribution License Agreement (CLA) [here](https://github.com/OfficeDev/office-content/raw/master/Contribution%20License%20Agreement.pdf). Please fill out the form and email it to [officedev@microsoft.com](mailto:officedev@microsoft.com). 45 | 46 | Once we receive and process your CLA, we will do our best to review your pull request(s) within ten business days. 47 | 48 | ## Guidance for contributors 49 | For more guidance on contributing to Office developer documentation, see [CONTRIBUTING.md](https://github.com/OfficeDev/office-content/blob/master/CONTRIBUTING.md) in this repo. 50 | 51 | 52 | 53 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 54 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Open XML SDK 2.5 Table of contents 4 | 5 | - [Open XML SDK 2.5](articles/f6a9ae68-7989-4208-97f5-3c945137a0ab.md) 6 | - [Getting started](articles/7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md) 7 | - [About the Open XML SDK 2.5](articles/620e86b5-49f2-43dc-85d4-9c7456c09552.md) 8 | - [What's new in the Open XML SDK 2.5](articles/4fbda0e3-5676-4a8f-ba62-3fba59fa418b.md) 9 | - [Open XML SDK 2.5 design considerations](articles/43c49a6d-96b5-4e87-a5bf-01629d61aad4.md) 10 | - [Understanding the Open XML file formats](articles/ada81388-9ed2-43f4-ab2c-2bb82f711e90.md) 11 | - [Introduction to markup compatibility](articles/dd42a9a3-5c16-4cab-ad6d-506cf822ec7a.md) 12 | - [Working with PresentationML documents](articles/56aeeed4-24ce-42ba-a236-6fec6785dd93.md) 13 | - [Structure of a PresentationML document](articles/fe780fcd-ed8f-4ee1-938e-cf3bb358ccae.md) 14 | - [Working with animation](articles/d4ef73a6-888a-4476-9e21-4df76782127f.md) 15 | - [Working with comments](articles/d7f0f1d3-bcf9-40b5-aaa4-4a08d862ac8e.md) 16 | - [Working with handout master slides](articles/fb4b293c-9a23-44b7-8af6-afe5fac6611a.md) 17 | - [Working with notes slides](articles/56d28bc5-c9ea-4c0e-b2f5-20be9c16d290.md) 18 | - [Working with presentations](articles/82deb499-7479-474d-9d89-c4847e6f3649.md) 19 | - [Working with presentation slides](articles/ee6c905b-26c5-4aed-a414-9aa826364a23.md) 20 | - [Working with slide layouts](articles/1ec087c3-8b9e-46a9-9c3c-14586908eb0e.md) 21 | - [Working with slide masters](articles/7dfd78a3-e233-4abd-8c17-1e384780d3ec.md) 22 | - [Working with SpreadsheetML documents](articles/c984c74e-2f06-4aba-a64b-2bb928b2929e.md) 23 | - [Structure of a SpreadsheetML document](articles/3b35a153-c8ff-4dc7-96d5-02c515f31770.md) 24 | - [Working with the calculation chain](articles/ffdf5bd3-53f5-4f48-8946-11a0287fb107.md) 25 | - [Working with conditional formatting](articles/b6f5afca-5feb-4003-b803-55dd2f9bf6d2.md) 26 | - [Working with formulas](articles/17abd341-abe9-4eee-9bb3-27fded0b04d2.md) 27 | - [Working with PivotTables](articles/96697c37-3fa7-4814-85b6-657439435ce1.md) 28 | - [Working with the shared string table](articles/36664cc7-30ef-4e9b-b569-846a9e404219.md) 29 | - [Working with sheets](articles/119a7eb6-9a02-4914-b651-9ba090bf7994.md) 30 | - [Working with tables](articles/7b72277f-3c5e-43ba-bbd8-7467cf532c95.md) 31 | - [Working with WordprocessingML documents](articles/bead244f-b551-477f-a296-41ead7bfcf5c.md) 32 | - [Structure of a WordprocessingML document](articles/03636fa2-be44-4e8d-9c26-7d38415bb459.md) 33 | - [Working with paragraphs](articles/8a9117f7-066e-409c-8681-a26610c0eede.md) 34 | - [Working with runs](articles/1fbc6d30-bfe4-4b2b-8fd8-0c5a400d1e03.md) 35 | - [Working with tables](articles/2ac3a285-8060-4f89-ae12-38ddbee00094.md) 36 | - [How do I...](articles/b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md) 37 | - [Presentations](articles/0a81a7fb-c431-4f53-a199-e72eea91f360.md) 38 | - [How to: Add a comment to a slide in a presentation](articles/403abe97-7ab2-40ba-92c0-d6312a6d10c8.md) 39 | - [How to: Apply a theme to a presentation](articles/d7575014-8187-4e55-bafa-15bc317bf8c8.md) 40 | - [How to: Change the fill color of a shape in a presentation](articles/e3adae2b-c7e8-45f4-b1fc-93d937f4b3b1.md) 41 | - [How to: Create a presentation document by providing a file name](articles/3d4a800e-64f0-4715-919f-a8f7d92a5c37.md) 42 | - [How to: Delete all the comments by an author from all the slides in a presentation](articles/3b892a6a-2972-461e-94a9-0a1ede854bda.md) 43 | - [How to: Delete a slide from a presentation](articles/98781b17-8de4-46e9-b29a-5b4033665491.md) 44 | - [How to: Get all the external hyperlinks in a presentation](articles/d6daf04e-3e45-4570-a184-8f0449c7ab91.md) 45 | - [How to: Get all the text in a slide in a presentation](articles/6de46612-f864-413f-a504-11ea85f1f88f.md) 46 | - [How to: Get all the text in all slides in a presentation](articles/debad542-5915-45ad-a71c-eeb95b40ec1a.md) 47 | - [How to: Get the titles of all the slides in a presentation](articles/b7d5d1fd-dcdf-4f88-9d57-884562c8144f.md) 48 | - [How to: Insert a new slide into a presentation](articles/6079a1ae-4567-4d99-b350-b819fd06fe5c.md) 49 | - [How to: Move a slide to a new position in a presentation](articles/95fd9dcd-41e9-4e83-9191-2f3110ae73d5.md) 50 | - [How to: Move a paragraph from one presentation to another](articles/ef817bef-27cd-4c2a-acf3-b7bba17e6e1e.md) 51 | - [How to: Open a presentation document for read-only access](articles/8dc8a6ac-aa9e-47cc-b45e-e128fcec3c57.md) 52 | - [How to: Retrieve the number of slides in a presentation document](articles/b6f429a7-4489-4155-b713-2139f3add8c2.md) 53 | - [Packages and general](articles/edbe267a-ced9-43fd-a702-fd0165cb3438.md) 54 | - [How to: Add a new document part that receives a relationship ID to a package](articles/c9b2ce55-548c-4443-8d2e-08fe1f06b7d7.md) 55 | - [How to: Add a new document part to a package](articles/ec83a076-9d71-49d1-915f-e7090f74c13a.md) 56 | - [How to: Copy the contents of an Open XML package part to a document part in a different package](articles/7dbfd93c-a9e3-4465-9b57-4a043b07b807.md) 57 | - [How to: Create a package](articles/fe261589-7b04-47df-8ee9-26b444e587b0.md) 58 | - [How to: Get the contents of a document part from a package](articles/b0d3d890-431a-4838-89dc-1f0dccd5dcd0.md) 59 | - [How to: Remove a document part from a package](articles/b3890e64-51d1-4643-8d07-2c9d8e060000.md) 60 | - [How to: Replace the theme part in a word processing document](articles/cfb75725-f3a7-43c0-85f4-7bb4c3f448ca.md) 61 | - [How to: Search and replace text in a document part](articles/cbb4547e-45fa-48ee-872e-8727beec6dfa.md) 62 | - [Spreadsheets](articles/7808dcc4-8f50-42c4-bad1-d69fe5f045fe.md) 63 | - [How to: Add custom UI to a spreadsheet document](articles/fdb29547-c295-4e7d-9fc5-d86d8d8c2967.md) 64 | - [How to: Calculate the sum of a range of cells in a spreadsheet document](articles/41c001da-204e-4669-a722-76c9f7928281.md) 65 | - [How to: Create a spreadsheet document by providing a file name](articles/03ac59c4-49a6-4721-8931-d045c4c9ddde.md) 66 | - [How to: Delete text from a cell in a spreadsheet](articles/4b395c48-b469-4d69-b229-d4bad3f3dd8b.md) 67 | - [How to: Get a column heading in a spreadsheet](articles/56ba8cee-d789-4a03-b8ff-b161af0788ff.md) 68 | - [How to: Get worksheet information from a package](articles/124cb0a0-cc47-433f-bad0-06b793890650.md) 69 | - [How to: Insert a chart into a spreadsheet](articles/281776d0-be75-46eb-8fdc-a1f656291175.md) 70 | - [How to: Insert a new worksheet into a spreadsheet](articles/944036fa-9251-408f-86cb-2351a5f8cd48.md) 71 | - [How to: Insert text into a cell in a spreadsheet](articles/5ded6212-e8d4-4206-9025-cb5991bd2f80.md) 72 | - [How to: Merge two adjacent cells in a spreadsheet](articles/73747a65-0857-4fd4-8362-3613f4169203.md) 73 | - [How to: Open a spreadsheet document for read-only access](articles/625bf571-5630-47f8-953f-e9e1a93e3229.md) 74 | - [How to: Open a spreadsheet document from a stream](articles/7fde676b-81b6-4210-82bf-f74d0d925dec.md) 75 | - [How to: Parse and read a large spreadsheet](articles/dd28d239-42be-42a9-893e-b65338fe184e.md) 76 | - [How to: Retrieve a dictionary of all named ranges in a spreadsheet](articles/0aa2aef3-b329-4ccc-8f25-9660c083e14e.md) 77 | - [How to: Retrieve a list of the hidden rows or columns in a spreadsheet](articles/5adddb6e-545e-4fba-ae35-cc4682e3eda7.md) 78 | - [How to: Retrieve a list of the hidden worksheets in a spreadsheet](articles/a6d35b76-d12a-460c-9d9d-2334abde759e.md) 79 | - [How to: Retrieve the values of cells in a spreadsheet](articles/15e26fbd-fc23-466a-a7cc-b7584ba8f821.md) 80 | - [How to: Retrieve a list of the worksheets in a spreadsheet](articles/a0c1e144-2080-4470-bd4b-ed98f1399374.md) 81 | - [Word processing](articles/4fcb7fbb-0796-4737-8f05-acbcfa9e1a06.md) 82 | - [How to: Accept all revisions in a word processing document](articles/b3406fcc-f10b-4075-a18f-116400f35faf.md) 83 | - [How to: Add tables to word processing documents](articles/65c377d2-1763-4bb6-8915-bc6839ccf62d.md) 84 | - [How to: Apply a style to a paragraph in a word processing document](articles/8d465a77-6c1b-453a-8375-ecf80d2f1bdc.md) 85 | - [How to: Change the print orientation of a word processing document](articles/bb5319c8-ee99-4862-937b-94dcae8deaca.md) 86 | - [How to: Change text in a table in a word processing document](articles/69f7c94e-2b8c-4bec-be8c-31933e2ee042.md) 87 | - [How to: Convert a word processing document from the DOCM to the DOCX file format](articles/80cdc1e8-d023-4886-b8d6-ee26327df739.md) 88 | - [How to: Create and add a character style to a word processing document](articles/c38f2c94-f0b5-4bb5-8c95-02e556d4e9f1.md) 89 | - [How to: Create and add a paragraph style to a word processing document](articles/73cbca2d-3603-45a5-8a73-c2e718376b01.md) 90 | - [How to: Create a word processing document by providing a file name](articles/1771fc05-dd94-40e3-a788-6a13809d64f3.md) 91 | - [How to: Delete comments by all or a specific author in a word processing document](articles/c66a64ca-cb0d-4acc-9d05-535b5bbb8c96.md) 92 | - [How to: Extract styles from a word processing document](articles/20258c39-9411-41f2-8463-e94a4b0fa326.md) 93 | - [How to: Insert a comment into a word processing document](articles/474f0a6c-62c8-4f04-b3f9-cd613a6e48d0.md) 94 | - [How to: Insert a picture into a word processing document](articles/ae8c98d9-dd11-4b75-804c-165095d60ffd.md) 95 | - [How to: Insert a table into a word processing document](articles/9d390cf8-1654-4a75-b3b8-4aba86ed1476.md) 96 | - [How to: Open and add text to a word processing document](articles/360318b5-9d17-42a1-b707-c3ccd1a89c97.md) 97 | - [How to: Open a word processing document for read-only access](articles/c811c2c7-1066-45a5-a724-33d0fbfd5284.md) 98 | - [How to: Open a word processing document from a stream](articles/75cff172-b29d-475a-8eb5-d8e90642f015.md) 99 | - [How to: Remove hidden text from a word processing document](articles/e5e9c6ba-b422-4639-bb8c-6da521307f13.md) 100 | - [How to: Remove the headers and footers from a word processing document](articles/22f973f4-58d1-4dd4-943e-a15ac2571b7c.md) 101 | - [How to: Replace the header in a word processing document](articles/d57e9b7d-b271-4c8d-998f-b7ca3eb6c850.md) 102 | - [How to: Replace the styles parts in a word processing document](articles/67edb37c-cfec-461c-b616-5a8b7d074c91.md) 103 | - [How to: Retrieve application property values from a word processing document](articles/3e9ca812-460e-442e-8257-38f523a53dc6.md) 104 | - [How to: Retrieve comments from a word processing document](articles/70839c86-36ef-4b67-a682-abd5114b2bfe.md) 105 | - [How to: Set a custom property in a word processing document](articles/30dfce05-00c1-423e-b4b4-149329fdf184.md) 106 | - [How to: Set the font for a text run](articles/e4e5a2e5-a97e-47b9-a263-6723bd4230a1.md) 107 | - [How to: Validate a word processing document](articles/a20bf30b-204e-4c57-8ca3-badf4b0b3e03.md) 108 | - [Class library reference on MSDN](http://msdn.microsoft.com/en-us/library/office/gg278315(v=office.15).aspx) 109 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/03636fa2-be44-4e8d-9c26-7d38415bb459.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/03636fa2-be44-4e8d-9c26-7d38415bb459.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/03ac59c4-49a6-4721-8931-d045c4c9ddde.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Create a spreadsheet document by providing a file name (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Getting a SpreadsheetDocument Object](#sectionSection1) 10 | 11 | [Basic Structure of a SpreadsheetML Document](#sectionSection2) 12 | 13 | [Generating the SpreadsheetML Markup](#sectionSection3) 14 | 15 | [Sample Code](#sectionSection4) 16 | 17 | 18 | 19 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically create a spreadsheet document. 20 | 21 | The following assembly directives are required to compile the code in this topic. 22 | 23 | 24 | ```C# 25 | using DocumentFormat.OpenXml; 26 | using DocumentFormat.OpenXml.Packaging; 27 | using DocumentFormat.OpenXml.Spreadsheet; 28 | 29 | ``` 30 | 31 | 32 | 33 | 34 | ```VB.net 35 | Imports DocumentFormat.OpenXml 36 | Imports DocumentFormat.OpenXml.Packaging 37 | Imports DocumentFormat.OpenXml.Spreadsheet 38 | 39 | ``` 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## Getting a SpreadsheetDocument Object 49 | 50 | 51 | In the Open XML SDK, the ** **SpreadsheetDocument**** class represents an Excel document package. To create an Excel document, create an instance of the **SpreadsheetDocument** class and populate it with parts. At a minimum, the document must have a workbook part that serves as a container for the document, and at least one worksheet part. The text is represented in the package as XML using **SpreadsheetML** markup. 52 | 53 | To create the class instance, call the **Create(Package, SpreadsheetDocumentType)** method. Several **Create** methods are provided, each with a different signature. The sample code in this topic uses the **Create** method with a signature that requires two parameters. The first parameter,package, takes a full path string that represents the document that you want to create. The second parameter, type, is a member of the **SpreadsheetDocumentType** enumeration. This parameter represents the document type. For example, there are different members of the **SpreadsheetDocumentType** enumeration for add-ins, templates, workbooks, and macro-enabled templates and workbooks. 54 | 55 | 56 | **Note** Select the appropriate **SpreadsheetDocumentType** and ensure that the persisted file has the correct, matching file name extension. If the **SpreadsheetDocumentType** does not match the file name extension, an error occurs when you open the file in Excel. 57 | 58 | 59 | The following code example calls the **Create** method. 60 | 61 | 62 | ```C# 63 | SpreadsheetDocument spreadsheetDocument = 64 | SpreadsheetDocument.Create(filepath, SpreadsheetDocumentType.Workbook); 65 | ``` 66 | 67 | 68 | 69 | 70 | ```VB.net 71 | Dim spreadsheetDocument As SpreadsheetDocument = _ 72 | SpreadsheetDocument.Create(filepath, SpreadsheetDocumentType.Workbook) 73 | ``` 74 | 75 | 76 | 77 | When you have created the Excel document package, you can add parts to it. To add the workbook part you call the **AddWorkbookPart()** method of the **SpreadsheetDocument** class. A workbook part must have at least one worksheet. To add a worksheet, create a new **Sheet**. When you create a new **Sheet**, associate the **Sheet** with the **Workbook** by passing theId, SheetId andName parameters. Use the **GetIdOfPart(OpenXmlPart)** method to get theId of the **Sheet**. Then add the new sheet to the **Sheet** collection by calling the **Append([])** method of the **Sheets** class. The following code example creates a new worksheet, associates the worksheet, and appends the worksheet to the workbook. 78 | 79 | 80 | ```C# 81 | Sheet sheet = new Sheet() { Id = spreadsheetDocument.WorkbookPart. 82 | GetIdOfPart(worksheetPart), SheetId = 1, Name = "mySheet" }; 83 | sheets.Append(sheet); 84 | ``` 85 | 86 | 87 | 88 | 89 | ```VB.net 90 | Dim sheet As New Sheet() With {.Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart), .SheetId = 1, .Name = "mySheet"} 91 | sheets.Append(sheet) 92 | ``` 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | ## Basic Structure of a SpreadsheetML Document 102 | The following code example is the **SpreadsheetML** markup for the workbook that the sample code creates. 103 | 104 | 105 | ```XML 106 | 107 | 108 | 109 | 110 | 111 | ``` 112 | 113 | 114 | 115 | The basic document structure of a **SpreadsheetML** document consists of the **Sheets** and **Sheet** elements, which reference the worksheets in the workbook. A separate XML file is created for each worksheet. The worksheet XML files contain one or more block level elements such as **SheetData**. **sheetData** represents the cell table and contains one or more **Row** elements. A **row** contains one or more **Cell** elements. Each cell contains a **CellValue** element that represents the cell value. The following code example is the SpreadsheetML markup for the worksheet created by the sample code. 116 | 117 | 118 | ```XML 119 | 120 | 121 | 122 | ``` 123 | 124 | 125 | 126 | Using the Open XML SDK 2.5, you can create document structure and content by using strongly-typed classes that correspond to SpreadsheetML elements. You can find these classes in the **DocumentFormat.OpenXml.Spreadsheet** namespace. The following table lists the class names of the classes that correspond to the **workbook**, **sheets**, **sheet**, **worksheet**, and **sheetData** elements. 127 | 128 | 129 | **** 130 | 131 |

SpreadsheetML Element

Open XML SDK 2.5 Class

Description

workbook

DocumentFormat.OpenXml.Spreadsheet.Workbook

The root element for the main document part.

sheets

DocumentFormat.OpenXml.Spreadsheet.Sheets

The container for the block-level structures such as sheet, fileVersion, and others specified in the ISO/IEC 29500 specification.

sheet

DocumentFormat.OpenXml.Spreadsheet.Sheet

A sheet that points to a sheet definition file.

worksheet

DocumentFormat.OpenXml.Spreadsheet.Worksheet

A sheet definition file that contains the sheet data.

sheetData

DocumentFormat.OpenXml.Spreadsheet.SheetData

The cell table, grouped together by rows.

132 |
133 | 134 | 135 | 136 | 137 | ## Generating the SpreadsheetML Markup 138 | To create the basic document structure using the Open XML SDK, instantiate the **Workbook** class, assign it to the **WorkbookPart** property of the main document part, and then add instances of the **WorksheetPart**, **Worksheet**, and **Sheet** classes. This is shown in the sample code and generates the required **SpreadsheetML** markup. 139 | 140 | 141 | 142 | 143 | 144 | 145 | ## Sample Code 146 | The **CreateSpreadsheetWorkbook** method shown here can be used to create a basic Excel document, a workbook with one sheet named "mySheet". To call it in your program, you can use the following code example that creates a file named "Sheet2.xlsx" in the public documents folder. 147 | 148 | 149 | ```C# 150 | CreateSpreadsheetWorkbook(@"c:\Users\Public\Documents\Sheet2.xlsx") 151 | ``` 152 | 153 | 154 | 155 | 156 | ```VB.net 157 | CreateSpreadsheetWorkbook("c:\Users\Public\Documents\Sheet2.xlsx") 158 | ``` 159 | 160 | 161 | 162 | Notice that the file name extension, .xlsx, matches the type of file specified by the **SpreadsheetDocumentType.Workbook** parameter in the call to the **Create** method. 163 | 164 | Following is the complete sample code in both C# and Visual Basic. 165 | 166 | 167 | ```C# 168 | public static void CreateSpreadsheetWorkbook(string filepath) 169 | { 170 | // Create a spreadsheet document by supplying the filepath. 171 | // By default, AutoSave = true, Editable = true, and Type = xlsx. 172 | SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument. 173 | Create(filepath, SpreadsheetDocumentType.Workbook); 174 | 175 | // Add a WorkbookPart to the document. 176 | WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart(); 177 | workbookpart.Workbook = new Workbook(); 178 | 179 | // Add a WorksheetPart to the WorkbookPart. 180 | WorksheetPart worksheetPart = workbookpart.AddNewPart(); 181 | worksheetPart.Worksheet = new Worksheet(new SheetData()); 182 | 183 | // Add Sheets to the Workbook. 184 | Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook. 185 | AppendChild(new Sheets()); 186 | 187 | // Append a new worksheet and associate it with the workbook. 188 | Sheet sheet = new Sheet() { Id = spreadsheetDocument.WorkbookPart. 189 | GetIdOfPart(worksheetPart), SheetId = 1, Name = "mySheet" }; 190 | sheets.Append(sheet); 191 | 192 | workbookpart.Workbook.Save(); 193 | 194 | // Close the document. 195 | spreadsheetDocument.Close(); 196 | } 197 | ``` 198 | 199 | 200 | 201 | 202 | ```VB.net 203 | Public Sub CreateSpreadsheetWorkbook(ByVal filepath As String) 204 | ' Create a spreadsheet document by supplying the filepath. 205 | ' By default, AutoSave = true, Editable = true, and Type = xlsx. 206 | Dim spreadsheetDocument As SpreadsheetDocument = _ 207 | spreadsheetDocument.Create(filepath, SpreadsheetDocumentType.Workbook) 208 | 209 | ' Add a WorkbookPart to the document. 210 | Dim workbookpart As WorkbookPart = spreadsheetDocument.AddWorkbookPart 211 | workbookpart.Workbook = New Workbook 212 | 213 | ' Add a WorksheetPart to the WorkbookPart. 214 | Dim worksheetPart As WorksheetPart = workbookpart.AddNewPart(Of WorksheetPart)() 215 | worksheetPart.Worksheet = New Worksheet(New SheetData()) 216 | 217 | ' Add Sheets to the Workbook. 218 | Dim sheets As Sheets = spreadsheetDocument.WorkbookPart.Workbook.AppendChild(Of Sheets)(New Sheets()) 219 | 220 | ' Append a new worksheet and associate it with the workbook. 221 | Dim sheet As Sheet = New Sheet 222 | sheet.Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart) 223 | sheet.SheetId = 1 224 | sheet.Name = "mySheet" 225 | 226 | sheets.Append(sheet) 227 | 228 | workbookpart.Workbook.Save() 229 | 230 | ' Close the document. 231 | spreadsheetDocument.Close() 232 | End Sub 233 | ``` 234 | 235 | 236 | 237 | 238 | ## See also 239 | 240 | #### Other resources 241 | 242 | 243 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 244 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/0a81a7fb-c431-4f53-a199-e72eea91f360.md: -------------------------------------------------------------------------------- 1 | 2 | # Presentations (Open XML SDK) 3 | **Last modified:** July 25, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides how-to topics for working with presentation documents using the Open XML SDK 2.5. 8 | 9 | 10 | ## In this section 11 | [How to: Add a comment to a slide in a presentation (Open XML SDK)](403abe97-7ab2-40ba-92c0-d6312a6d10c8.md) 12 | 13 | [How to: Apply a theme to a presentation (Open XML SDK)](d7575014-8187-4e55-bafa-15bc317bf8c8.md) 14 | 15 | [How to: Change the fill color of a shape in a presentation (Open XML SDK)](e3adae2b-c7e8-45f4-b1fc-93d937f4b3b1.md) 16 | 17 | [How to: Create a presentation document by providing a file name (Open XML SDK)](3d4a800e-64f0-4715-919f-a8f7d92a5c37.md) 18 | 19 | [How to: Delete all the comments by an author from all the slides in a presentation (Open XML SDK)](3b892a6a-2972-461e-94a9-0a1ede854bda.md) 20 | 21 | [How to: Delete a slide from a presentation (Open XML SDK)](98781b17-8de4-46e9-b29a-5b4033665491.md) 22 | 23 | [How to: Get all the external hyperlinks in a presentation (Open XML SDK)](d6daf04e-3e45-4570-a184-8f0449c7ab91.md) 24 | 25 | [How to: Get all the text in a slide in a presentation (Open XML SDK)](6de46612-f864-413f-a504-11ea85f1f88f.md) 26 | 27 | [How to: Get all the text in all slides in a presentation (Open XML SDK)](debad542-5915-45ad-a71c-eeb95b40ec1a.md) 28 | 29 | [How to: Get the titles of all the slides in a presentation (Open XML SDK)](b7d5d1fd-dcdf-4f88-9d57-884562c8144f.md) 30 | 31 | [How to: Insert a new slide into a presentation (Open XML SDK)](6079a1ae-4567-4d99-b350-b819fd06fe5c.md) 32 | 33 | [How to: Move a slide to a new position in a presentation (Open XML SDK)](95fd9dcd-41e9-4e83-9191-2f3110ae73d5.md) 34 | 35 | [How to: Move a paragraph from one presentation to another (Open XML SDK)](ef817bef-27cd-4c2a-acf3-b7bba17e6e1e.md) 36 | 37 | [How to: Open a presentation document for read-only access (Open XML SDK)](8dc8a6ac-aa9e-47cc-b45e-e128fcec3c57.md) 38 | 39 | [How to: Retrieve the number of slides in a presentation document (Open XML SDK)](b6f429a7-4489-4155-b713-2139f3add8c2.md) 40 | 41 | 42 | ## Related sections 43 | [How do I... (Open XML SDK)](b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md) 44 | 45 | [Getting started with the Open XML SDK 2.5 for Office](7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md) 46 | 47 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/0aa2aef3-b329-4ccc-8f25-9660c083e14e.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/0aa2aef3-b329-4ccc-8f25-9660c083e14e.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/119a7eb6-9a02-4914-b651-9ba090bf7994.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/119a7eb6-9a02-4914-b651-9ba090bf7994.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/124cb0a0-cc47-433f-bad0-06b793890650.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Get worksheet information from an Open XML package (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Create SpreadsheetDocument Object](#sectionSection1) 10 | 11 | [Basic Structure of a SpreadsheetML](#sectionSection2) 12 | 13 | [How the Sample Code Works](#sectionSection3) 14 | 15 | [Sample Code](#sectionSection4) 16 | 17 | 18 | 19 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically retrieve information from a worksheet in a Spreadsheet document. 20 | 21 | The following assembly directives are required to compile the code in this topic. 22 | 23 | 24 | ```C# 25 | using System; 26 | using DocumentFormat.OpenXml.Packaging; 27 | using S = DocumentFormat.OpenXml.Spreadsheet.Sheets; 28 | using E = DocumentFormat.OpenXml.OpenXmlElement; 29 | using A = DocumentFormat.OpenXml.OpenXmlAttribute; 30 | 31 | ``` 32 | 33 | 34 | 35 | 36 | ```VB.net 37 | Imports System 38 | Imports DocumentFormat.OpenXml.Packaging 39 | Imports S = DocumentFormat.OpenXml.Spreadsheet.Sheets 40 | Imports E = DocumentFormat.OpenXml.OpenXmlElement 41 | Imports A = DocumentFormat.OpenXml.OpenXmlAttribute 42 | 43 | ``` 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## Create SpreadsheetDocument Object 53 | In the Open XML SDK, the ** **SpreadsheetDocument**** class represents an Excel document package. To create an Excel document, you create an instance of the **SpreadsheetDocument** class and populate it with parts. At a minimum, the document must have a workbook part that serves as a container for the document, and at least one worksheet part. The text is represented in the package as XML using **SpreadsheetML** markup. 54 | 55 | To create the class instance from the document you call one of the **Open()** methods. In this example, you must open the file for read access only. Therefore, you can use the **Open(String, Boolean)** method, and set the Boolean parameter to **false**. 56 | 57 | The following code example calls the **Open** method to open the file specified by thefilepath for read-only access. 58 | 59 | 60 | ```C# 61 | // Open file as read-only. 62 | using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(fileName, false)) 63 | ``` 64 | 65 | 66 | 67 | 68 | ```VB.net 69 | ' Open file as read-only. 70 | Using mySpreadsheet As SpreadsheetDocument = SpreadsheetDocument.Open(fileName, False) 71 | 72 | ``` 73 | 74 | 75 | 76 | The **using** statement provides a recommended alternative to the typical .Open, .Save, .Close sequence. It ensures that the **Dispose** method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing brace is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this casemySpreadsheet. 77 | 78 | 79 | 80 | 81 | 82 | 83 | ## Basic Structure of a SpreadsheetML 84 | The basic document structure of a **SpreadsheetML** document consists of the **Sheets** and **Sheet** elements, which reference the worksheets in the **Workbook**. A separate XML file is created for each **Worksheet**. For example, the **SpreadsheetML** for a workbook that has two worksheets name MySheet1 and MySheet2 is located in the Workbook.xml file and is shown in the following code example. 85 | 86 | 87 | ```XML 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | ``` 96 | 97 | 98 | 99 | The worksheet XML files contain one or more block level elements such as **SheetData**. **sheetData** represents the cell table and contains one or more **Row** elements. A **row** contains one or more **Cell** elements. Each cell contains a **CellValue** element that represents the value of the cell. For example, the SpreadsheetML for the first worksheet in a workbook, that only has the value 100 in cell A1, is located in the Sheet1.xml file and is shown in the following code example. 100 | 101 | 102 | ```XML 103 | 104 | 105 | 106 | 107 | 108 | 100 109 | 110 | 111 | 112 | 113 | 114 | ``` 115 | 116 | 117 | 118 | Using the Open XML SDK 2.5, you can create document structure and content that uses strongly-typed classes that correspond to **SpreadsheetML** elements. You can find these classes in the **DocumentFormat.OpenXML.Spreadsheet** namespace. The following table lists the class names of the classes that correspond to the **workbook**, **sheets**, **sheet**, **worksheet**, and **sheetData** elements. 119 | 120 | 121 | **** 122 | 123 |

SpreadsheetML Element

Open XML SDK 2.5 Class

Description

workbook

DocumentFormat.OpenXml.Spreadsheet.Workbook

The root element for the main document part.

sheets

DocumentFormat.OpenXml.Spreadsheet.Sheets

The container for the block level structures such as sheet, fileVersion, and others specified in the ISO/IEC 29500 specification.

sheet

DocumentFormat.OpenXml.Spreadsheet.Sheet

A sheet that points to a sheet definition file.

worksheet

DocumentFormat.OpenXml.Spreadsheet.Worksheet

A sheet definition file that contains the sheet data.

sheetData

DocumentFormat.OpenXml.Spreadsheet.SheetData

The cell table, grouped together by rows.

row

DocumentFormat.OpenXml.Spreadsheet.Row

A row in the cell table.

c

DocumentFormat.OpenXml.Spreadsheet.Cell

A cell in a row.

v

DocumentFormat.OpenXml.Spreadsheet.CellValue

The value of a cell.

124 |
125 | 126 | 127 | 128 | 129 | ## How the Sample Code Works 130 | After you have opened the file for read-only access, you instantiate the **Sheets** class. 131 | 132 | 133 | ```C# 134 | S sheets = mySpreadsheet.WorkbookPart.Workbook.Sheets; 135 | ``` 136 | 137 | 138 | 139 | 140 | ```VB.net 141 | Dim sheets As S = mySpreadsheet.WorkbookPart.Workbook.Sheets 142 | ``` 143 | 144 | 145 | 146 | You then you iterate through the **Sheets** collection and display **OpenXmlElement** and the **OpenXmlAttribute** in each element. 147 | 148 | 149 | ```C# 150 | foreach (E sheet in sheets) 151 | { 152 | foreach (A attr in sheet.GetAttributes()) 153 | { 154 | Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value); 155 | } 156 | } 157 | 158 | ``` 159 | 160 | 161 | 162 | 163 | ```VB.net 164 | For Each sheet In sheets 165 | For Each attr In sheet.GetAttributes() 166 | Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value) 167 | Next 168 | Next 169 | 170 | ``` 171 | 172 | 173 | 174 | By displaying the attribute information you get the name and ID for each worksheet in the spreadsheet file. 175 | 176 | 177 | 178 | 179 | 180 | 181 | ## Sample Code 182 | In the following code example, you retrieve and display the attributes of the all sheets in the specified workbook contained in a **SpreadsheetDocument** document. The following code example shows how to call the **GetSheetInfo** method. 183 | 184 | 185 | ```C# 186 | GetSheetInfo(@"C:\Users\Public\Documents\Sheet5.xlsx"); 187 | ``` 188 | 189 | 190 | 191 | 192 | ```VB.net 193 | GetSheetInfo("C:\Users\Public\Documents\Sheet5.xlsx") 194 | ``` 195 | 196 | 197 | 198 | The following is the complete code sample in both C# and Visual Basic. 199 | 200 | 201 | ```C# 202 | public static void GetSheetInfo(string fileName) 203 | { 204 | // Open file as read-only. 205 | using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(fileName, false)) 206 | { 207 | S sheets = mySpreadsheet.WorkbookPart.Workbook.Sheets; 208 | 209 | // For each sheet, display the sheet information. 210 | foreach (E sheet in sheets) 211 | { 212 | foreach (A attr in sheet.GetAttributes()) 213 | { 214 | Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value); 215 | } 216 | } 217 | } 218 | } 219 | 220 | ``` 221 | 222 | 223 | 224 | 225 | ```VB.net 226 | Public Sub GetSheetInfo(ByVal fileName As String) 227 | ' Open file as read-only. 228 | Using mySpreadsheet As SpreadsheetDocument = SpreadsheetDocument.Open(fileName, False) 229 | Dim sheets As S = mySpreadsheet.WorkbookPart.Workbook.Sheets 230 | 231 | ' For each sheet, display the sheet information. 232 | For Each sheet As E In sheets 233 | For Each attr As A In sheet.GetAttributes() 234 | Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value) 235 | Next 236 | Next 237 | End Using 238 | End Sub 239 | 240 | ``` 241 | 242 | 243 | 244 | 245 | ## See also 246 | 247 | #### Other resources 248 | 249 | 250 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 251 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/15e26fbd-fc23-466a-a7cc-b7584ba8f821.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/15e26fbd-fc23-466a-a7cc-b7584ba8f821.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/1771fc05-dd94-40e3-a788-6a13809d64f3.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Create a word processing document by providing a file name (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Creating a WordprocessingDocument Object](#sectionSection1) 10 | 11 | [Structure of a WordProcessingML Document](#sectionSection2) 12 | 13 | [Generating the WordprocessingML Markup](#sectionSection3) 14 | 15 | [Sample Code](#sectionSection4) 16 | 17 | 18 | 19 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically create a word processing document. 20 | 21 | The following assembly directives are required to compile the code in this topic. 22 | <-- test comment --> 23 | 24 | ```C# 25 | using DocumentFormat.OpenXml; 26 | using DocumentFormat.OpenXml.Packaging; 27 | using DocumentFormat.OpenXml.Wordprocessing; 28 | 29 | ``` 30 | 31 | 32 | 33 | 34 | ```VB.net 35 | Imports DocumentFormat.OpenXml 36 | Imports DocumentFormat.OpenXml.Packaging 37 | Imports DocumentFormat.OpenXml.Wordprocessing 38 | 39 | ``` 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## Creating a WordprocessingDocument Object 49 | 50 | 51 | In the Open XML SDK, the **WordprocessingDocument** class represents a Word document package. To create a Word document, you create an instance of the **WordprocessingDocument** class and populate it with parts. At a minimum, the document must have a main document part that serves as a container for the main text of the document. The text is represented in the package as XML using WordprocessingML markup. 52 | 53 | To create the class instance you call the **Create(String, WordprocessingDocumentType)** method. Several **Create()** methods are provided, each with a different signature. The sample code in this topic uses the **Create** method with a signature that requires two parameters. The first parameter takes a full path string that represents the document that you want to create. The second parameter is a member of the **WordprocessingDocumentType** enumeration. This parameter represents the type of document. For example, there is a different member of the **WordProcessingDocumentType** enumeration for each of document, template, and the macro enabled variety of document and template. 54 | 55 | 56 | **Note** Carefully select the appropriate **WordProcessingDocumentType** and verify that the persisted file has the correct, matching file extension. If the **WordProcessingDocumentType** does not match the file extension, an error occurs when you open the file in Microsoft Word. 57 | 58 | 59 | The code that calls the **Create** method is part of a **using** statement followed by a bracketed block, as shown in the following code example. 60 | 61 | 62 | ```C# 63 | using (WordprocessingDocument wordDocument = 64 | WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document)) 65 | { 66 | // Insert other code here. 67 | } 68 | 69 | ``` 70 | 71 | 72 | 73 | 74 | ```VB.net 75 | Using wordDocument As WordprocessingDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document) 76 | ' Insert other code here. 77 | End Using 78 | ``` 79 | 80 | 81 | 82 | The **using** statement provides a recommended alternative to the typical .Create, .Save, .Close sequence. It ensures that the **Dispose** () method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing bracket is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this case **wordDocument**. Because the **WordprocessingDocument** class in the Open XML SDK automatically saves and closes the object as part of its **System.IDisposable** implementation, and because **Dispose** is automatically called when you exit the bracketed block, you do not have to explicitly call **Save** and **Close**-as long as you use **using**. 83 | 84 | Once you have created the Word document package, you can add parts to it. To add the main document part you call the **AddMainDocumentPart()** method of the **WordprocessingDocument** class. Having done that, you can set about adding the document structure and text. 85 | 86 | 87 | 88 | 89 | 90 | 91 | ## Structure of a WordProcessingML Document 92 | The basic document structure of a WordProcessingML document consists of the **document** and **body** elements, followed by one or more block level elements such as **p**, which represents a paragraph. A paragraph contains one or more **r** elements. The **r** stands for run, which is a region of text with a common set of properties, such as formatting. A run contains one or more **t** elements. The **t** element contains a range of text. The WordprocessingML markup for the document that the sample code creates is shown in the following code example. 93 | 94 | 95 | ```XML 96 | 97 | 98 | 99 | 100 | Create text in body - CreateWordprocessingDocument 101 | 102 | 103 | 104 | 105 | ``` 106 | 107 | 108 | 109 | Using the Open XML SDK 2.5, you can create document structure and content using strongly-typed classes that correspond to WordprocessingML elements. You can find these classes in the **DocumentFormat.OpenXml.Wordprocessing** namespace. The following table lists the class names of the classes that correspond to the **document**, **body**, **p**, **r**, and **t** elements. 110 | 111 | 112 | **** 113 | 114 |

WordprocessingML Element

Open XML SDK 2.5 Class

Description

document

Document

The root element for the main document part.

body

Body

The container for the block level structures such as paragraphs, tables, annotations, and others specified in the ISO/IEC 29500 specification.

p

Paragraph

A paragraph.

r

Run

A run.

t

Text

A range of text.

115 |
116 | 117 | 118 | 119 | 120 | ## Generating the WordprocessingML Markup 121 | To create the basic document structure using the Open XML SDK, you instantiate the **Document** class, assign it to the **Document** property of the main document part, and then add instances of the **Body**, **Paragraph**, **Run** and **Text** classes. This is shown in the sample code listing, and does the work of generating the required WordprocessingML markup. While the code in the sample listing calls the **AppendChild** method of each class, you can sometimes make code shorter and easier to read by using the technique shown in the following code example. 122 | 123 | 124 | ```C# 125 | mainPart.Document = new Document( 126 | new Body( 127 | new Paragraph( 128 | new Run( 129 | new Text("Create text in body - CreateWordprocessingDocument"))))); 130 | ``` 131 | 132 | 133 | 134 | 135 | ```VB.net 136 | mainPart.Document = New Document(New Body(New Paragraph(New Run(New Text("Create text in body - CreateWordprocessingDocument"))))) 137 | 138 | ``` 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | ## Sample Code 148 | The **CreateWordprocessingDocument** method can be used to create a basic Word document. You call it by passing a full path as the only parameter. The following code example creates the Invoice.docx file in the Public Documents folder. 149 | 150 | 151 | ```C# 152 | CreateWordprocessingDocument(@"c:\Users\Public\Documents\Invoice.docx"); 153 | ``` 154 | 155 | 156 | 157 | 158 | ```VB.net 159 | CreateWordprocessingDocument("c:\Users\Public\Documents\Invoice.docx") 160 | ``` 161 | 162 | 163 | 164 | The file extension, .docx, matches the type of file specified by the **WordprocessingDocumentType.Document** parameter in the call to the **Create** method. 165 | 166 | Following is the complete code example in both C# and Visual Basic. 167 | 168 | 169 | ```C# 170 | public static void CreateWordprocessingDocument(string filepath) 171 | { 172 | // Create a document by supplying the filepath. 173 | using (WordprocessingDocument wordDocument = 174 | WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document)) 175 | { 176 | // Add a main document part. 177 | MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); 178 | 179 | // Create the document structure and add some text. 180 | mainPart.Document = new Document(); 181 | Body body = mainPart.Document.AppendChild(new Body()); 182 | Paragraph para = body.AppendChild(new Paragraph()); 183 | Run run = para.AppendChild(new Run()); 184 | run.AppendChild(new Text("Create text in body - CreateWordprocessingDocument")); 185 | } 186 | } 187 | ``` 188 | 189 | 190 | 191 | 192 | ```VB.net 193 | Public Sub CreateWordprocessingDocument(ByVal filepath As String) 194 | ' Create a document by supplying the filepath. 195 | Using wordDocument As WordprocessingDocument = _ 196 | WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document) 197 | 198 | ' Add a main document part. 199 | Dim mainPart As MainDocumentPart = wordDocument.AddMainDocumentPart() 200 | 201 | ' Create the document structure and add some text. 202 | mainPart.Document = New Document() 203 | Dim body As Body = mainPart.Document.AppendChild(New Body()) 204 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 205 | Dim run As Run = para.AppendChild(New Run()) 206 | run.AppendChild(New Text("Create text in body - CreateWordprocessingDocument")) 207 | End Using 208 | End Sub 209 | ``` 210 | 211 | 212 | 213 | 214 | ## See also 215 | 216 | #### Other resources 217 | 218 | 219 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 220 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/17abd341-abe9-4eee-9bb3-27fded0b04d2.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/17abd341-abe9-4eee-9bb3-27fded0b04d2.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/1ec087c3-8b9e-46a9-9c3c-14586908eb0e.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/1ec087c3-8b9e-46a9-9c3c-14586908eb0e.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/1fbc6d30-bfe4-4b2b-8fd8-0c5a400d1e03.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/1fbc6d30-bfe4-4b2b-8fd8-0c5a400d1e03.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/20258c39-9411-41f2-8463-e94a4b0fa326.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Extract styles from a word processing document (Open XML SDK) 3 | **Last modified:** March 25, 2013 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [ExtractStylesPart Method](#sectionSection1) 10 | 11 | [Calling the Sample Method](#sectionSection2) 12 | 13 | [How the Code Works](#sectionSection3) 14 | 15 | [Find the Correct Styles Part](#sectionSection4) 16 | 17 | [Retrieve the Part Contents](#sectionSection5) 18 | 19 | [Sample Code](#sampleCode) 20 | 21 | 22 | 23 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically extract the styles or stylesWithEffects part from a word processing document to an [XDocument](http://msdn.microsoft.com/en-us/library/Bb345449(v=VS.100).aspx) instance. It contains an example**ExtractStylesPart** method to illustrate this task. 24 | 25 | To use the sample code in this topic, you must install the [Open XML SDK 2.5](http://www.microsoft.com/en-us/download/details.aspx?id=30425). You must explicitly reference the following assemblies in your project: 26 | 27 | 28 | - WindowsBase 29 | 30 | 31 | - DocumentFormat.OpenXml (installed by the Open XML SDK) 32 | 33 | 34 | 35 | You must also use the following **using** directives or **Imports** statements to compile the code in this topic. 36 | 37 | 38 | ```C# 39 | using System; 40 | using System.IO; 41 | using System.Xml; 42 | using System.Xml.Linq; 43 | using DocumentFormat.OpenXml.Packaging; 44 | ``` 45 | 46 | 47 | 48 | 49 | ```VB.net 50 | Imports System.IO 51 | Imports System.Xml 52 | Imports DocumentFormat.OpenXml.Packaging 53 | 54 | ``` 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | ## ExtractStylesPart Method 64 | You can use the **ExtractStylesPart** sample method to retrieve an **XDocument** instance that contains the styles or stylesWithEffects part for a Microsoft Word 2010 or Microsoft Word 2013 document. Be aware that in a document created in Word 2010, there will only be a single styles part; Word 2013 adds a second stylesWithEffects part. To provide for "round-tripping" a document from Word 2013 to Word 2010 and back, Word 2013 maintains both the original styles part and the new styles part. (The Office Open XML File Formats specification requires that Microsoft Word ignore any parts that it does not recognize; Word 2010 does not notice the stylesWithEffects part that Word 2013 adds to the document.) You (and your application) must interpret the results of retrieving the styles or stylesWithEffects part. 65 | 66 | The **ExtractStylesPart** procedure accepts a two parameters: the first parameter contains a string indicating the path of the file from which you want to extract styles, and the second indicates whether you want to retrieve the styles part, or the newer stylesWithEffects part (basically, you must call this procedure two times for Word 2013 documents, retrieving each the part). The procedure returns an **XDocument** instance that contains the complete styles or stylesWithEffects part that you requested, with all the style information for the document (or a null reference, if the part you requested does not exist). 67 | 68 | 69 | ```C# 70 | public static XDocument ExtractStylesPart( 71 | string fileName, 72 | bool getStylesWithEffectsPart = true) 73 | ``` 74 | 75 | 76 | 77 | 78 | ```VB.net 79 | Public Function ExtractStylesPart( 80 | ByVal fileName As String, 81 | Optional ByVal getStylesWithEffectsPart As Boolean = True) As XDocument 82 | 83 | ``` 84 | 85 | 86 | 87 | The complete code listing for the method can be found in the [Sample Code](20258c39-9411-41f2-8463-e94a4b0fa326.md) section. 88 | 89 | 90 | 91 | 92 | 93 | 94 | ## Calling the Sample Method 95 | To call the sample method, pass a string for the first parameter that contains the file name of the document from which to extract the styles, and a Boolean for the second parameter that specifies whether the type of part to retrieve is the styleWithEffects part (true), or the styles part (false). The following sample code shows an example. When you have the **XDocument** instance you can do what you want with it; in the following sample code the content of the **XDocument** instance is displayed to the console. 96 | 97 | 98 | ```C# 99 | string filename = @"C:\Users\Public\Documents\StylesFrom.docx"; 100 | 101 | // Retrieve the StylesWithEffects part. You could pass false in the 102 | // second parameter to retrieve the Styles part instead. 103 | var styles = ExtractStylesPart(filename, true); 104 | 105 | // If the part was retrieved, send the contents to the console. 106 | if (styles != null) 107 | Console.WriteLine(styles.ToString()); 108 | ``` 109 | 110 | 111 | 112 | 113 | ```VB.net 114 | Dim filename As String = "C:\Users\Public\Documents\StylesFrom.docx" 115 | 116 | ' Retrieve the stylesWithEffects part. You could pass False 117 | ' in the second parameter to retrieve the styles part instead. 118 | Dim styles = ExtractStylesPart(filename, True) 119 | 120 | ' If the part was retrieved, send the contents to the console. 121 | If styles IsNot Nothing Then 122 | Console.WriteLine(styles.ToString()) 123 | End If 124 | ``` 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | ## How the Code Works 134 | The code starts by creating a variable named styles that the method returns before it exits. 135 | 136 | 137 | ```C# 138 | // Declare a variable to hold the XDocument. 139 | XDocument styles = null; 140 | // Code removed here... 141 | // Return the XDocument instance. 142 | return styles; 143 | ``` 144 | 145 | 146 | 147 | 148 | ```VB.net 149 | ' Declare a variable to hold the XDocument. 150 | Dim styles As XDocument = Nothing 151 | ' Code removed here... 152 | ' Return the XDocument instance. 153 | Return styles 154 | ``` 155 | 156 | 157 | 158 | The code continues by opening the document by using the **Open** method and indicating that the document should be open for read-only access (the final false parameter). Given the open document, the code uses the **MainDocumentPart** property to navigate to the main document part, and then prepares a variable namedstylesPart to hold a reference to the styles part. 159 | 160 | 161 | ```C# 162 | // Open the document for read access and get a reference. 163 | using (var document = 164 | WordprocessingDocument.Open(fileName, false)) 165 | { 166 | // Get a reference to the main document part. 167 | var docPart = document.MainDocumentPart; 168 | 169 | // Assign a reference to the appropriate part to the 170 | // stylesPart variable. 171 | StylesPart stylesPart = null; 172 | // Code removed here... 173 | } 174 | ``` 175 | 176 | 177 | 178 | 179 | ```VB.net 180 | ' Open the document for read access and get a reference. 181 | Using document = WordprocessingDocument.Open(fileName, False) 182 | 183 | ' Get a reference to the main document part. 184 | Dim docPart = document.MainDocumentPart 185 | 186 | ' Assign a reference to the appropriate part to the 187 | ' stylesPart variable. 188 | Dim stylesPart As StylesPart = Nothing 189 | ' Code removed here... 190 | End Using 191 | ``` 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | ## Find the Correct Styles Part 201 | The code next retrieves a reference to the requested styles part by using the getStylesWithEffectsPart Boolean parameter. Based on this value, the code retrieves a specific property of thedocPart variable, and stores it in thestylesPart variable. 202 | 203 | 204 | ```C# 205 | if (getStylesWithEffectsPart) 206 | stylesPart = docPart.StylesWithEffectsPart; 207 | else 208 | stylesPart = docPart.StyleDefinitionsPart; 209 | ``` 210 | 211 | 212 | 213 | 214 | ```VB.net 215 | If getStylesWithEffectsPart Then 216 | stylesPart = docPart.StylesWithEffectsPart 217 | Else 218 | stylesPart = docPart.StyleDefinitionsPart 219 | End If 220 | ``` 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | ## Retrieve the Part Contents 230 | If the requested styles part exists, the code must return the contents of the part in an **XDocument** instance. Each part provides a **GetStream** method, which returns a Stream. The code passes the Stream instance to the [XmlNodeReader.Create](http://msdn.microsoft.com/en-us/library/ay7fxzht(v=VS.100).aspx) method, and then calls the [XDocument.Load](http://msdn.microsoft.com/en-us/library/bb356384.aspx) method, passing the **XmlNodeReader** as a parameter. 231 | 232 | 233 | ```C# 234 | // If the part exists, read it into the XDocument. 235 | if (stylesPart != null) 236 | { 237 | using (var reader = XmlNodeReader.Create( 238 | stylesPart.GetStream(FileMode.Open, FileAccess.Read))) 239 | { 240 | // Create the XDocument. 241 | styles = XDocument.Load(reader); 242 | } 243 | } 244 | ``` 245 | 246 | 247 | 248 | 249 | ```VB.net 250 | ' If the part exists, read it into the XDocument. 251 | If stylesPart IsNot Nothing Then 252 | Using reader = XmlNodeReader.Create( 253 | stylesPart.GetStream(FileMode.Open, FileAccess.Read)) 254 | ' Create the XDocument: 255 | styles = XDocument.Load(reader) 256 | End Using 257 | End If 258 | ``` 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | ## Sample Code 268 | The following is the complete **ExtractStylesPart** code sample in C# and Visual Basic. 269 | 270 | 271 | ```C# 272 | // Extract the styles or stylesWithEffects part from a 273 | // word processing document as an XDocument instance. 274 | public static XDocument ExtractStylesPart( 275 | string fileName, 276 | bool getStylesWithEffectsPart = true) 277 | { 278 | // Declare a variable to hold the XDocument. 279 | XDocument styles = null; 280 | 281 | // Open the document for read access and get a reference. 282 | using (var document = 283 | WordprocessingDocument.Open(fileName, false)) 284 | { 285 | // Get a reference to the main document part. 286 | var docPart = document.MainDocumentPart; 287 | 288 | // Assign a reference to the appropriate part to the 289 | // stylesPart variable. 290 | StylesPart stylesPart = null; 291 | if (getStylesWithEffectsPart) 292 | stylesPart = docPart.StylesWithEffectsPart; 293 | else 294 | stylesPart = docPart.StyleDefinitionsPart; 295 | 296 | // If the part exists, read it into the XDocument. 297 | if (stylesPart != null) 298 | { 299 | using (var reader = XmlNodeReader.Create( 300 | stylesPart.GetStream(FileMode.Open, FileAccess.Read))) 301 | { 302 | // Create the XDocument. 303 | styles = XDocument.Load(reader); 304 | } 305 | } 306 | } 307 | // Return the XDocument instance. 308 | return styles; 309 | } 310 | ``` 311 | 312 | 313 | 314 | 315 | ```VB.net 316 | ' Extract the styles or stylesWithEffects part from a 317 | ' word processing document as an XDocument instance. 318 | Public Function ExtractStylesPart( 319 | ByVal fileName As String, 320 | Optional ByVal getStylesWithEffectsPart As Boolean = True) As XDocument 321 | 322 | ' Declare a variable to hold the XDocument. 323 | Dim styles As XDocument = Nothing 324 | 325 | ' Open the document for read access and get a reference. 326 | Using document = WordprocessingDocument.Open(fileName, False) 327 | 328 | ' Get a reference to the main document part. 329 | Dim docPart = document.MainDocumentPart 330 | 331 | ' Assign a reference to the appropriate part to the 332 | ' stylesPart variable. 333 | Dim stylesPart As StylesPart = Nothing 334 | If getStylesWithEffectsPart Then 335 | stylesPart = docPart.StylesWithEffectsPart 336 | Else 337 | stylesPart = docPart.StyleDefinitionsPart 338 | End If 339 | 340 | ' If the part exists, read it into the XDocument. 341 | If stylesPart IsNot Nothing Then 342 | Using reader = XmlNodeReader.Create( 343 | stylesPart.GetStream(FileMode.Open, FileAccess.Read)) 344 | ' Create the XDocument: 345 | styles = XDocument.Load(reader) 346 | End Using 347 | End If 348 | End Using 349 | ' Return the XDocument instance. 350 | Return styles 351 | End Function 352 | ``` 353 | 354 | 355 | 356 | 357 | ## See also 358 | 359 | #### Other resources 360 | 361 | 362 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 363 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/281776d0-be75-46eb-8fdc-a1f656291175.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/281776d0-be75-46eb-8fdc-a1f656291175.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/2ac3a285-8060-4f89-ae12-38ddbee00094.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/2ac3a285-8060-4f89-ae12-38ddbee00094.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/30dfce05-00c1-423e-b4b4-149329fdf184.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/30dfce05-00c1-423e-b4b4-149329fdf184.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/360318b5-9d17-42a1-b707-c3ccd1a89c97.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Open and add text to a word processing document (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [How to Open and Add Text to a Document](#sectionSection1) 10 | 11 | [Create a WordprocessingDocument Object](#sectionSection2) 12 | 13 | [Structure of a WordProcessingML Document](#sectionSection3) 14 | 15 | [Generate the WordprocessingML Markup to Add the Text](#sectionSection4) 16 | 17 | [Sample Code](#sectionSection5) 18 | 19 | 20 | 21 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically open and add text to a Word processing document. 22 | 23 | The following assembly directives are required to compile the code in this topic. 24 | 25 | 26 | ```C# 27 | using DocumentFormat.OpenXml.Packaging; 28 | using DocumentFormat.OpenXml.Wordprocessing; 29 | 30 | ``` 31 | 32 | 33 | 34 | 35 | ```VB.net 36 | Imports DocumentFormat.OpenXml.Packaging 37 | Imports DocumentFormat.OpenXml.Wordprocessing 38 | 39 | ``` 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## How to Open and Add Text to a Document 49 | The Open XML SDK 2.5 helps you create Word processing document structure and content using strongly-typed classes that correspond to **WordprocessingML** elements. This topic shows how to use the classes in the Open XML SDK 2.5 to open a Word processing document and add text to it. In addition, this topic introduces the basic document structure of a **WordprocessingML** document, the associated XML elements, and their corresponding Open XML SDK classes. 50 | 51 | 52 | 53 | 54 | 55 | 56 | ## Create a WordprocessingDocument Object 57 | In the Open XML SDK, the **WordprocessingDocument** class represents a Word document package. To open and work with a Word document, create an instance of the **WordprocessingDocument** class from the document. When you create the instance from the document, you can then obtain access to the main document part that contains the text of the document. The text in the main document part is represented in the package as XML using **WordprocessingML** markup. 58 | 59 | To create the class instance from the document you call one of the **Open** methods. Several are provided, each with a different signature. The sample code in this topic uses the **Open(String, Boolean)** method with a signature that requires two parameters. The first parameter takes a full path string that represents the document to open. The second parameter is either **true** or **false** and represents whether you want the file to be opened for editing. Changes you make to the document will not be saved if this parameter is **false**. 60 | 61 | The following code example calls the **Open** method. 62 | 63 | 64 | ```C# 65 | // Open a WordprocessingDocument for editing using the filepath. 66 | WordprocessingDocument wordprocessingDocument = 67 | WordprocessingDocument.Open(filepath, true); 68 | 69 | ``` 70 | 71 | 72 | 73 | 74 | ```VB.net 75 | ' Open a WordprocessingDocument for editing using the filepath. 76 | Dim wordprocessingDocument As WordprocessingDocument = WordprocessingDocument.Open(filepath, True) 77 | 78 | ``` 79 | 80 | 81 | 82 | When you have opened the Word document package, you can add text to the main document part. To access the body of the main document part, assign a reference to the existing document body, as shown in the following code example. 83 | 84 | 85 | ```C# 86 | // Assign a reference to the existing document body. 87 | Body body = wordprocessingDocument.MainDocumentPart.Document.Body; 88 | 89 | ``` 90 | 91 | 92 | 93 | 94 | ```VB.net 95 | ' Assign a reference to the existing document body. 96 | Dim body As Body = wordprocessingDocument.MainDocumentPart.Document.Body 97 | 98 | ``` 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | ## Structure of a WordProcessingML Document 108 | The basic document structure of a WordProcessingML document consists of the **document** and **body** elements, followed by one or more block level elements such as **p**, which represents a paragraph. A paragraph contains one or more **r** elements. The **r** stands for run, which is a region of text with a common set of properties, such as formatting. A run contains one or more **t** elements. The **t** element contains a range of text. The following code example shows the WordprocessingML markup for a document that contains the text "Example text." 109 | 110 | 111 | ```XML 112 | 113 | 114 | 115 | 116 | Example text. 117 | 118 | 119 | 120 | 121 | ``` 122 | 123 | 124 | 125 | Using the Open XML SDK 2.5, you can create document structure and content using strongly-typed classes that correspond to WordprocessingML elements. You will find these classes in the **DocumentFormat.OpenXml.Wordprocessing** namespace. The following table lists the class names of the classes that correspond to the **document**, **body**, **p**, **r**, and **t** elements. 126 | 127 | 128 | **** 129 | 130 |

WordprocessingML Element

Open XML SDK 2.5 Class

Description

document

Document

The root element for the main document part.

body

Body

The container for the block level structures such as paragraphs, tables, annotations and others specified in the ISO/IEC 29500 specification.

p

Paragraph

A paragraph.

r

Run

A run.

t

Text

A range of text.

131 |
132 | 133 | 134 | 135 | 136 | ## Generate the WordprocessingML Markup to Add the Text 137 | When you have access to the body of the main document part, add text by adding instances of the **Paragraph**, **Run**, and **Text** classes. This generates the required WordprocessingML markup. The following code example adds the paragraph, run and text. 138 | 139 | 140 | ```C# 141 | // Add new text. 142 | Paragraph para = body.AppendChild(new Paragraph()); 143 | Run run = para.AppendChild(new Run()); 144 | run.AppendChild(new Text(txt)); 145 | ``` 146 | 147 | 148 | 149 | 150 | ```VB.net 151 | ' Add new text. 152 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 153 | Dim run As Run = para.AppendChild(New Run()) 154 | run.AppendChild(New Text(txt)) 155 | 156 | ``` 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | ## Sample Code 166 | The example **OpenAndAddTextToWordDocument** method shown here can be used to open a Word document and append some text using the Open XML SDK. To call this method, pass a full path filename as the first parameter and the text to add as the second. For example, the following code example opens the Letter.docx file in the Public Documents folder and adds text to it. 167 | 168 | 169 | ```C# 170 | string strDoc = @"C:\Users\Public\Documents\Letter.docx"; 171 | string strTxt = "Append text in body - OpenAndAddTextToWordDocument"; 172 | OpenAndAddTextToWordDocument(strDoc, strTxt); 173 | ``` 174 | 175 | 176 | 177 | 178 | ```VB.net 179 | Dim strDoc As String = "C:\Users\Public\Documents\Letter.docx" 180 | Dim strTxt As String = "Append text in body - OpenAndAddTextToWordDocument" 181 | OpenAndAddTextToWordDocument(strDoc, strTxt) 182 | ``` 183 | 184 | 185 | 186 | Following is the complete sample code in both C# and Visual Basic. 187 | 188 | Notice that the **OpenAndAddTextToWordDocument** method does not include an explicit call to **Save**. That is because the AutoSave feature is on by default and has not been disabled in the call to the **Open** method through use of **OpenSettings**. 189 | 190 | 191 | ```C# 192 | public static void OpenAndAddTextToWordDocument(string filepath, string txt) 193 | { 194 | // Open a WordprocessingDocument for editing using the filepath. 195 | WordprocessingDocument wordprocessingDocument = 196 | WordprocessingDocument.Open(filepath, true); 197 | 198 | // Assign a reference to the existing document body. 199 | Body body = wordprocessingDocument.MainDocumentPart.Document.Body; 200 | 201 | // Add new text. 202 | Paragraph para = body.AppendChild(new Paragraph()); 203 | Run run = para.AppendChild(new Run()); 204 | run.AppendChild(new Text(txt)); 205 | 206 | // Close the handle explicitly. 207 | wordprocessingDocument.Close(); 208 | } 209 | ``` 210 | 211 | 212 | 213 | 214 | ```VB.net 215 | Public Sub OpenAndAddTextToWordDocument(ByVal filepath As String, ByVal txt As String) 216 | ' Open a WordprocessingDocument for editing using the filepath. 217 | Dim wordprocessingDocument As WordprocessingDocument = _ 218 | wordprocessingDocument.Open(filepath, True) 219 | 220 | ' Assign a reference to the existing document body. 221 | Dim body As Body = wordprocessingDocument.MainDocumentPart.Document.Body 222 | 223 | ' Add new text. 224 | Dim para As Paragraph = body.AppendChild(New Paragraph) 225 | Dim run As Run = para.AppendChild(New Run) 226 | run.AppendChild(New Text(txt)) 227 | 228 | ' Close the handle explicitly. 229 | wordprocessingDocument.Close() 230 | End Sub 231 | ``` 232 | 233 | 234 | 235 | 236 | ## See also 237 | 238 | #### Other resources 239 | 240 | 241 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 242 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/36664cc7-30ef-4e9b-b569-846a9e404219.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/36664cc7-30ef-4e9b-b569-846a9e404219.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/3b892a6a-2972-461e-94a9-0a1ede854bda.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/3b892a6a-2972-461e-94a9-0a1ede854bda.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/3d4a800e-64f0-4715-919f-a8f7d92a5c37.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/3d4a800e-64f0-4715-919f-a8f7d92a5c37.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/3e9ca812-460e-442e-8257-38f523a53dc6.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/3e9ca812-460e-442e-8257-38f523a53dc6.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/403abe97-7ab2-40ba-92c0-d6312a6d10c8.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/403abe97-7ab2-40ba-92c0-d6312a6d10c8.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/43c49a6d-96b5-4e87-a5bf-01629d61aad4.md: -------------------------------------------------------------------------------- 1 | 2 | # Open XML SDK 2.5 for Office design considerations 3 | **Last modified:** July 25, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | Before using the Open XML SDK 2.5 for Office, be aware of the following design considerations. 8 | 9 | 10 | ## Design Considerations 11 | The Open XML SDK 2.5: 12 | 13 | 14 | - Does not replace the Microsoft Office Object Model and provides no abstraction on top of the file formats. You must still understand the structure of the file formats to use the Open XML SDK 2.5. 15 | 16 | 17 | - Does not provide functionality to convert Open XML formats to and from other formats, such as HTML or XPS. 18 | 19 | 20 | - Does not guarantee document validity of Open XML Formats when you use the Open XML SDK 2.5 or if you decide to manipulate the underlying XML directly. 21 | 22 | 23 | - Does not provide application behavior such as layout functionality in Word or recalculation, data refresh, or adjustment functionalities in Excel. 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/474f0a6c-62c8-4f04-b3f9-cd613a6e48d0.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/474f0a6c-62c8-4f04-b3f9-cd613a6e48d0.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/4fbda0e3-5676-4a8f-ba62-3fba59fa418b.md: -------------------------------------------------------------------------------- 1 | 2 | # What's new in the Open XML SDK 2.5 for Office 3 | **Last modified:** June 23rd, 2014 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [In this Topic](#sectionSection0) 10 | 11 | [Introduction](#BKMK_Introduction) 12 | 13 | [System Requirements](#BKMK_Requirements) 14 | 15 | [New Software Requirements](#BKMK_OpenXMLSDK2.0ImprovedArchitecture) 16 | 17 | [Support of Office 2013 Preview File Format](#BKMK_OpenXMLProductivityToolforMicrosoftOffice) 18 | 19 | [Reads ISO Strict Document Files](#BKMK_MarkupCompatibility) 20 | 21 | [Updated API information](#BKMK_StreamReadingandWriting) 22 | 23 | [Deprecated API Information](#BKMK_DocumentValidation) 24 | 25 | 26 | 27 | This topic describes the new and improved features included in the Open XML SDK 2.5 for Office in addition to known issues and limitations. 28 | 29 | 30 | 31 | 32 | 33 | 34 | ## In this Topic 35 | 36 | - [Introduction](#BKMK_Introduction) 37 | 38 | 39 | - [System Requirements](#BKMK_Requirements) 40 | 41 | 42 | - [New Software Requirements](#BKMK_OpenXMLSDK2.0ImprovedArchitecture) 43 | 44 | 45 | - [Support of Office 2013 Preview File Format](#BKMK_OpenXMLProductivityToolforMicrosoftOffice) 46 | 47 | 48 | - [Reads ISO Strict Document Files](#BKMK_MarkupCompatibility) 49 | 50 | 51 | - [Deprecated API Information](#BKMK_DocumentValidation) 52 | 53 | 54 | - [Updated API information](#BKMK_StreamReadingandWriting) 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | ## Introduction 64 | The Open XML SDK 2.5 is a collection of classes that let you create and manipulate Open XML documents - documents that adhere to the [Office Open XML File Formats Standard](http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=51463). Because the SDK provides an application program interface that lets you manipulate Open XML documents directly, you can do so without the need for the Office client products themselves in both client and server operating environments. The SDK is designed to let you build high performance client-side or server-side solutions that perform complex operations using only a small amount of program code. 65 | 66 | This release of the SDK greatly extends support for the file formats while adding new features. 67 | 68 | 69 | 70 | 71 | 72 | 73 | ## System Requirements 74 | The Open XML SDK 2.5 has the following system requirements: 75 | 76 | **Supported operating systems:** Windows 8 Preview, Windows 7, Windows Server 2003 Service Pack 2, Windows Server 2008 R2, Windows Server 2008 Service Pack 2, Windows Vista Service Pack 2, Windows XP Service Pack 3 77 | 78 | **System Prerequisites:** .NET Framework version 4.0, Up to 300 MB of available disk space 79 | 80 | 81 | 82 | 83 | 84 | 85 | ## New Software Requirements 86 | Open XML SDK 2.5 requires .NET Framework 4.0 or the greater version. Accordingly, the supported operating systems are updated to be the same as the requirements of the .NET Framework 4.0. 87 | 88 | 89 | 90 | 91 | 92 | 93 | ## Support of Office 2013 Preview File Format 94 | In addition to offering compatibility with the Open XML SDK 1.0 classes and the Open XML SDK 2.0 for Microsoft Office classes, Open XML SDK 2.5 provides new classes that enable you to write and build applications to manipulate Open XML file extensions of the new Microsoft Office 2013 features (see Table 1). By using the Open XML SDK 2.5 Productivity Tool for Office, those new extensions can be browsed inside the Open XML SDK documentation in the left pane. 95 | 96 | **Table 1. DocumentFormat.OpenXml.Office15 classes** 97 | 98 | 99 | **** 100 | 101 |

Class

Description

DocumentFormat.OpenXml.Office15.Excel

Supports new PivotTable features, timeline, and the other new features of Excel

DocumentFormat.OpenXml.Office15.Word

Supports new Comment features (e.g. Comments pane) and other new features of Word. For example, the CommentEx class reads the comments author; The WebVideoProperty property is used to insert a video in a Word document

DocumentFormat.OpenXml.Office15.PowerPoint, Theme

Supports comment hint, theme family, and the other new features of PowerPoint

DocumentFormat.OpenXml.Office15.Drawing

Supports new Charts, PivotCharts, and other new Drawing and Chart features

DocumentFormat.OpenXml.Office15.WebExtension, WebExtentionPane

Supports app for Office and Task Pane app for Office features. The classes are viable for inserting or modifying app for Office into Word and Excel document files

102 | For code samples demonstrating how to use these new classes, please refer to new articles posted to [Open XML Format SDK Forum](http://social.msdn.microsoft.com/Forums/en-US/oxmlsdk/threads) in the Microsoft Developer Network. 103 | 104 |
105 | 106 | 107 | 108 | 109 | ## Reads ISO Strict Document Files 110 | The Open XML SDK 2.5 can read ISO/IEC 29500 Strict Format files. Its document contents are recognized as an Open XML Transitional Format file when the document is opened. When the file is saved, the document is saved as an Open XML Transitional Format file. 111 | 112 | The Open XML SDK 2.5 converts ISO Strict files to Transitional Formatted files when any changes are made to the document or when the document is saved. Unless the document is saved or modified, the document is left as an ISO Strict Format file. 113 | 114 | 115 | 116 | 117 | 118 | 119 | ## Updated API information 120 | Because the file format extension of Office 2013 extends members of the **** element which did not have any member elements, Open XML SDK 2.0 classes associated with the empty **** (e.g. **DocumentFormat.OpenXml.Spreadsheet.PivotFilter:ExtensionList**) are updated to the new variants of **ExtensionList** classes of Open XML SDK 2.5 (e.g. **DocumentFormat.OpenXml.Spreadsheet.PivotFilter:PivotFilterExtensionList**). The following empty **ExtensionList** in each class are replaced with a new **ExtensionList** class including new **Off Open XML** child element members. 121 | 122 | **ExtensionList:** 123 | 124 | 125 | - **DocumentFormat.OpenXml.Drawing.ConnectionShapeLocks** 126 | 127 | 128 | - **DocumentFormat.OpenXml.Drawing.Theme** 129 | 130 | 131 | - **DocumentFormat.OpenXml.Drawing.ChartDrawing.NonVisualGroupShapeDrawingProperties** 132 | 133 | 134 | - **DocumentFormat.OpenXml.Drawing.Charts.MultiLevelStringReference** 135 | 136 | 137 | - **DocumentFormat.OpenXml.Drawing.Charts.NumberReference** 138 | 139 | 140 | - **DocumentFormat.OpenXml.Drawing.Charts.StringReference** 141 | 142 | 143 | - **DocumentFormat.OpenXml.Drawing.Charts.SurfaceChartSeries** 144 | 145 | 146 | - **DocumentFormat.OpenXml.Drawing.Diagrams.DataModelRoot** 147 | 148 | 149 | - **DocumentFormat.OpenXml.Drawing.Spreadsheet.NonVisualDrawingProperties** 150 | 151 | 152 | - **DocumentFormat.OpenXml.Drawing.Spreadsheet.NonVisualGroupShapeDrawingProperties** 153 | 154 | 155 | - **DocumentFormat.OpenXml.Office.Drawing.NonVisualGroupDrawingShapeProperties** 156 | 157 | 158 | - **DocumentFormat.OpenXml.Office2010.Excel.SlicerCacheDefinition** 159 | 160 | 161 | - **DocumentFormat.OpenXml.Office2010.Word.DrawingGroup.NonVisualGroupDrawingShapeProperties** 162 | 163 | 164 | - **DocumentFormat.OpenXml.Presentation.CommentAuthor** 165 | 166 | 167 | - **DocumentFormat.OpenXml.Presentation.NonVisualGroupShapeDrawingProperties** 168 | 169 | 170 | - **DocumentFormat.OpenXml.Spreadsheet.PivotFilter** 171 | 172 | 173 | - **DocumentFormat.OpenXml.Spreadsheet.QueryTable** 174 | 175 | 176 | 177 | **ExtensionListWithModification:** 178 | 179 | 180 | - **DocumentFormat.OpenXml.Presentation.Comment** 181 | 182 | 183 | - **DocumentFormat.OpenXml.Presentation.HandoutMaster** 184 | 185 | 186 | - **DocumentFormat.OpenXml.Presentation.NotesMaster** 187 | 188 | 189 | - **DocumentFormat.OpenXml.Presentation.SlideLayout** 190 | 191 | 192 | - **DocumentFormat.OpenXml.Presentation.SlideMaster** 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | ## Deprecated API Information 202 | The following section discusses deprecated API members: 203 | 204 | **Smart Tags** 205 | 206 | Because _smart tags_ were deprecated in Office 2010, the Open XML SDK 2.5 doesn't support smart tag related Open XML elements. The Open XML SDK 2.5 still can process smart tag elements as_unknown_ elements, however the Open XML SDK 2.5 Productivity Tool for Office validates those elements (see the following list) in Office document files as_invalid tags_. 207 | 208 | DocumentFormat.OpenXml.Spreadsheet: 209 | 210 | 211 | - **SmartTagDisplayValues** 212 | 213 | 214 | - **SmartTagProperties** 215 | 216 | 217 | - **SmartTags** 218 | 219 | 220 | - **SmartTagType** 221 | 222 | 223 | - **SmartTagTypes** 224 | 225 | 226 | 227 | DocumentFormat.OpenXml.Wordprocessing: 228 | 229 | 230 | - **SaveSmartTagAsXml** 231 | 232 | 233 | - **SmartTagAttribut** 234 | 235 | 236 | - **SmartTagProperties** 237 | 238 | 239 | - **SmartTagRun** 240 | 241 | 242 | - **SmartTagType** 243 | 244 | 245 | 246 | **Office 2010 Beta only tags** 247 | 248 | The Open XML SDK 2.0 classes for Office 2010 _beta only_ Open XML tags are deprecated. For example, the beta only non-visual properties of **DocumentFormat.OpenXml.Office2010.Drawing.ChartDrawing**, **DocumentFormat.OpenXml.Office2010.Word**, and **DocumentFormat.OpenXml.Office2010.Drawing** have been removed from the Open XML SDK 2.5. 249 | 250 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/4fcb7fbb-0796-4737-8f05-acbcfa9e1a06.md: -------------------------------------------------------------------------------- 1 | 2 | # Word processing (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides how-to topics for working with word processing documents using the Open XML SDK 2.5 for Office. 8 | 9 | 10 | ## In this section 11 | [How to: Accept all revisions in a word processing document (Open XML SDK)](b3406fcc-f10b-4075-a18f-116400f35faf.md) 12 | 13 | [How to: Add tables to word processing documents (Open XML SDK)](65c377d2-1763-4bb6-8915-bc6839ccf62d.md) 14 | 15 | [How to: Apply a style to a paragraph in a word processing document (Open XML SDK)](8d465a77-6c1b-453a-8375-ecf80d2f1bdc.md) 16 | 17 | [How to: Change the print orientation of a word processing document (Open XML SDK)](bb5319c8-ee99-4862-937b-94dcae8deaca.md) 18 | 19 | [How to: Change text in a table in a word processing document (Open XML SDK)](69f7c94e-2b8c-4bec-be8c-31933e2ee042.md) 20 | 21 | [How to: Convert a word processing document from the DOCM to the DOCX file format (Open XML SDK)](80cdc1e8-d023-4886-b8d6-ee26327df739.md) 22 | 23 | [How to: Create and add a character style to a word processing document (Open XML SDK)](c38f2c94-f0b5-4bb5-8c95-02e556d4e9f1.md) 24 | 25 | [How to: Create and add a paragraph style to a word processing document (Open XML SDK)](73cbca2d-3603-45a5-8a73-c2e718376b01.md) 26 | 27 | [How to: Create a word processing document by providing a file name (Open XML SDK)](1771fc05-dd94-40e3-a788-6a13809d64f3.md) 28 | 29 | [How to: Delete comments by all or a specific author in a word processing document (Open XML SDK)](c66a64ca-cb0d-4acc-9d05-535b5bbb8c96.md) 30 | 31 | [How to: Extract styles from a word processing document (Open XML SDK)](20258c39-9411-41f2-8463-e94a4b0fa326.md) 32 | 33 | [How to: Insert a comment into a word processing document (Open XML SDK)](474f0a6c-62c8-4f04-b3f9-cd613a6e48d0.md) 34 | 35 | [How to: Insert a picture into a word processing document (Open XML SDK)](ae8c98d9-dd11-4b75-804c-165095d60ffd.md) 36 | 37 | [How to: Insert a table into a word processing document (Open XML SDK)](9d390cf8-1654-4a75-b3b8-4aba86ed1476.md) 38 | 39 | [How to: Open and add text to a word processing document (Open XML SDK)](360318b5-9d17-42a1-b707-c3ccd1a89c97.md) 40 | 41 | [How to: Open a word processing document for read-only access (Open XML SDK)](c811c2c7-1066-45a5-a724-33d0fbfd5284.md) 42 | 43 | [How to: Open a word processing document from a stream (Open XML SDK)](75cff172-b29d-475a-8eb5-d8e90642f015.md) 44 | 45 | [How to: Remove hidden text from a word processing document (Open XML SDK)](e5e9c6ba-b422-4639-bb8c-6da521307f13.md) 46 | 47 | [How to: Remove the headers and footers from a word processing document (Open XML SDK)](22f973f4-58d1-4dd4-943e-a15ac2571b7c.md) 48 | 49 | [How to: Replace the header in a word processing document (Open XML SDK)](d57e9b7d-b271-4c8d-998f-b7ca3eb6c850.md) 50 | 51 | [How to: Replace the styles parts in a word processing document (Open XML SDK)](67edb37c-cfec-461c-b616-5a8b7d074c91.md) 52 | 53 | [How to: Retrieve comments from a word processing document (Open XML SDK)](70839c86-36ef-4b67-a682-abd5114b2bfe.md) 54 | 55 | [How to: Retrieve Property Values from a Word 2007 Document by Using the Open XML API](http://msdn.microsoft.com/library/e0aacc31-524a-4392-aafa-290bbf7ae7b9(Office.15).aspx) 56 | 57 | [How to: Set a custom property in a word processing document (Open XML SDK)](30dfce05-00c1-423e-b4b4-149329fdf184.md) 58 | 59 | [How to: Set the font for a text run (Open XML SDK)](e4e5a2e5-a97e-47b9-a263-6723bd4230a1.md) 60 | 61 | [How to: Validate a word processing document (Open XML SDK)](a20bf30b-204e-4c57-8ca3-badf4b0b3e03.md) 62 | 63 | 64 | ## Related sections 65 | [How do I... (Open XML SDK)](b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md) 66 | 67 | [Getting started with the Open XML SDK 2.5 for Office](7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md) 68 | 69 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/56aeeed4-24ce-42ba-a236-6fec6785dd93.md: -------------------------------------------------------------------------------- 1 | 2 | # Working with PresentationML documents (Open XML SDK) 3 | **Last modified:** January 13, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides conceptual topics for working with PresentationML documents. 8 | 9 | 10 | ## In this section 11 | [Structure of a PresentationML document (Open XML SDK)](fe780fcd-ed8f-4ee1-938e-cf3bb358ccae.md) 12 | 13 | [Working with animation (Open XML SDK)](d4ef73a6-888a-4476-9e21-4df76782127f.md) 14 | 15 | [Working with comments (Open XML SDK)](d7f0f1d3-bcf9-40b5-aaa4-4a08d862ac8e.md) 16 | 17 | [Working with handout master slides (Open XML SDK)](fb4b293c-9a23-44b7-8af6-afe5fac6611a.md) 18 | 19 | [Working with notes slides (Open XML SDK)](56d28bc5-c9ea-4c0e-b2f5-20be9c16d290.md) 20 | 21 | [Working with presentations (Open XML SDK)](82deb499-7479-474d-9d89-c4847e6f3649.md) 22 | 23 | [Working with presentation slides (Open XML SDK)](ee6c905b-26c5-4aed-a414-9aa826364a23.md) 24 | 25 | [Working with slide layouts (Open XML SDK)](1ec087c3-8b9e-46a9-9c3c-14586908eb0e.md) 26 | 27 | [Working with slide masters (Open XML SDK)](7dfd78a3-e233-4abd-8c17-1e384780d3ec.md) 28 | 29 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/56d28bc5-c9ea-4c0e-b2f5-20be9c16d290.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/56d28bc5-c9ea-4c0e-b2f5-20be9c16d290.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/6079a1ae-4567-4d99-b350-b819fd06fe5c.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/6079a1ae-4567-4d99-b350-b819fd06fe5c.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/620e86b5-49f2-43dc-85d4-9c7456c09552.md: -------------------------------------------------------------------------------- 1 | 2 | # About the Open XML SDK 2.5 for Office 3 | **Last modified:** August 23, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML | SharePoint 2013_ 6 | 7 | **In this article** 8 | 9 | [Structure of an Open XML Package](#sectionSection0) 10 | 11 | [Open XML SDK 1.0](#sectionSection1) 12 | 13 | [Open XML SDK 2.0 for Microsoft Office](#sectionSection2) 14 | 15 | [Open XML SDK 2.5 for Office](#sectionSection3) 16 | 17 | 18 | 19 | Open XML is an open standard for word-processing documents, presentations, and spreadsheets that can be freely implemented by multiple applications on different platforms. Open XML is designed to faithfully represent existing word-processing documents, presentations, and spreadsheets that are encoded in binary formats defined by Microsoft Office applications. The reason for Open XML is simple: billions of documents now exist but, unfortunately, the information in those documents is tightly coupled with the programs that created them. The purpose of the Open XML standard is to de-couple documents created by Microsoft Office applications so that they can be manipulated by other applications independent of proprietary formats and without the loss of data. 20 | 21 | 22 | 23 | 24 | 25 | 26 | ## Structure of an Open XML Package 27 | An Open XML file is stored in a ZIP archive for packaging and compression. You can view the structure of any Open XML file using a ZIP viewer. An Open XML document is built of multiple document parts. The relationships between the parts are themselves stored in document parts. The ZIP format supports random access to each part. For example, an application can move a slide from one presentation to another presentation without parsing the slide content. Likewise, an application can strip all of the comments out of a word processing document without parsing any of its contents. 28 | 29 | The document parts in an Open XML package are created as XML markup. Because XML is structured plain text, you can view the contents of a document part using text readers or you can parse the contents using processes such as XPath. 30 | 31 | Structurally, an Open XML document is an Open Packaging Conventions (OPC) package. As stated previously, a package is composed of a collection of document parts. Each part has a part name that consists of a sequence of segments or a pathname such as "/word/theme/theme1.xml." The package contains a [Content_Types].xml part that allows you to determine the content type of all document parts in the package. A set of explicit relationships for a source package or part is contained in a relationships part that ends with the .rels extension. 32 | 33 | Word processing documents are described by using WordprocessingML markup. For more information, see [Working with WordprocessingML documents (Open XML SDK)](bead244f-b551-477f-a296-41ead7bfcf5c.md). A WordprocessingML document is composed of a collection of stories where each story is one of the following: 34 | 35 | 36 | - Main document (the only required story) 37 | 38 | 39 | - Glossary document 40 | 41 | 42 | - Header and footer 43 | 44 | 45 | - Comments 46 | 47 | 48 | - Text box 49 | 50 | 51 | - Footnote and endnote 52 | 53 | 54 | 55 | Presentations are described by using PresentationML markup. For more information, see [Working with PresentationML documents (Open XML SDK)](56aeeed4-24ce-42ba-a236-6fec6785dd93.md). Presentation packages can contain the following document parts: 56 | 57 | 58 | - Slide master 59 | 60 | 61 | - Notes master 62 | 63 | 64 | - Handout master 65 | 66 | 67 | - Slide layout 68 | 69 | 70 | - Notes 71 | 72 | 73 | 74 | Spreadsheet workbooks are described by using SpreadsheetML markup. For more information, see [Working with SpreadsheetML documents (Open XML SDK)](c984c74e-2f06-4aba-a64b-2bb928b2929e.md). Workbook packages can contain: 75 | 76 | 77 | - Workbook part (required part) 78 | 79 | 80 | - One or more worksheets 81 | 82 | 83 | - Charts 84 | 85 | 86 | - Tables 87 | 88 | 89 | - Custom XML 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | ## Open XML SDK 1.0 99 | Version 1 of the Open XML SDK simplified the manipulation of Open XML packages. The Open XML SDK Application Programming Interface (API) encapsulates many of the common tasks that you typically perform on Open XML packages, so you can perform complex operations with just a few lines of code. Some common tasks: 100 | 101 | 102 | - Search—With a few lines of code, you can search a collection of Excel 2007 worksheets for some arbitrary data. 103 | 104 | 105 | - Document assembly—You can create documents by combining the document parts of existing documents programmatically. For example, you can pull slides from various PowerPoint 2007 presentations to create a single presentation. 106 | 107 | 108 | - Validation—With a few lines of code, you can validate the document parts in a package or validate an entire package against a schema. 109 | 110 | 111 | - Data update—With the Open XML object model, you can easily modify the data in multiple packages. 112 | 113 | 114 | - Privacy—With a few lines of code, you can remove comments and other personal information from a document before it is distributed. 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | ## Open XML SDK 2.0 for Microsoft Office 124 | The Open XML SDK 2.0 for Microsoft Office extended the strongly typed class support from the part classes, which are provided in version 1.0, to the XML content in each part. All functions available in version 1.0 are still supported. With version 2.0, you are able to program against the XML content inside the part. The SDK supports programming in the style of LINQ to XML which makes coding against the XML content much easier than the traditional W3C XML DOM programming model. 125 | 126 | The SDK supports the following common tasks/scenarios: 127 | 128 | 129 | - Strongly Typed Classes and Objects—Instead of relying on generic XML functionality to manipulate XML, which requires that you be aware of element/attribute/value spelling as well as namespaces, you can use the Open XML SDK to accomplish the same solution simply by manipulating objects that represent elements/attributes/values. All schema types are represented as strongly typed Common Language Runtime (CLR) classes and all attribute values as enumerations. 130 | 131 | 132 | - Content Construction, Search, and Manipulation—The LINQ technology is built directly into the SDK. As a result, you are able to perform functional constructs and lambda expression queries directly on objects representing Open XML elements. In addition, the SDK allows you to easily traverse and manipulate content by providing support for collections of objects, like tables and paragraphs. 133 | 134 | 135 | - Validation—The Open XML SDK 2.0 for Microsoft Office provides validation functionality, enabling you to validate Open XML documents against different variations of the Open XML Format. 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | ## Open XML SDK 2.5 for Office 145 | The Open XML SDK 2.5 provides the namespaces and members to support the Microsoft Office 2013. The Open XML SDK 2.5 can also read ISO/IEC 29500 Strict Format files. The Strict format is a subset of the Transitional format that does not include legacy features - this makes it theoretically easier for a new implementer to support since it has a smaller technical footprint. 146 | 147 | The SDK supports the following common tasks/scenarios: 148 | 149 | 150 | - Support of Office 2013 Preview file format—In addition to the Open XML SDK 2.0 for Microsoft Office classes, Open XML SDK 2.5 provides new classes that enable you to write and build applications to manipulate Open XML file extensions of the new Office 2013 features. 151 | 152 | 153 | - Reads ISO Strict Document File—Open XML SDK 2.5 can read ISO/IEC 29500 Strict Format files. When the Open XML SDK 2.5 API opens a Strict Format file, each Open XML part in the file is loaded to an **OpenXmlPart** class of the Open XML SDK 2.5 by mapping **http://purl.oclc.org/ooxml/** namespaces to the corresponding **http://schemas.openxmlformats.org/** namespaces. 154 | 155 | 156 | - Fixes to the Open XML SDK 2.0 for Microsoft Office—Open XML SDK 2.5 includes fixes to known issues in the Open XML SDK 2.0 for Microsoft Office. These include lost whitespaces in PowerPoint presentations and an issue with the Custom UI in Word documents where a specified argument was reported as being out of the range of valid values. 157 | 158 | 159 | 160 | You can find more information about these and other new features of the Open XML SDK 2.5 in the [What's new in the Open XML SDK 2.5 for Office](4fbda0e3-5676-4a8f-ba62-3fba59fa418b.md) article. 161 | 162 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/65c377d2-1763-4bb6-8915-bc6839ccf62d.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/65c377d2-1763-4bb6-8915-bc6839ccf62d.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/69f7c94e-2b8c-4bec-be8c-31933e2ee042.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Change text in a table in a word processing document (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Open the Existing Document](#sectionSection1) 10 | 11 | [The Structure of a Table](#sectionSection2) 12 | 13 | [How the Sample Code Works](#sectionSection3) 14 | 15 | [Change Text in a Cell in a Table](#sectionSection4) 16 | 17 | [Sample Code](#sectionSection5) 18 | 19 | 20 | 21 | This topic shows how to use the Open XML SDK 2.5 for Office to programmatically change text in a table in an existing word processing document. 22 | 23 | The following assembly directives are required to compile the code in this topic. 24 | 25 | 26 | ```C# 27 | using System.Linq; 28 | using DocumentFormat.OpenXml.Packaging; 29 | using DocumentFormat.OpenXml.Wordprocessing; 30 | 31 | ``` 32 | 33 | 34 | 35 | 36 | ```VB.net 37 | Imports System.Linq 38 | Imports DocumentFormat.OpenXml.Packaging 39 | Imports DocumentFormat.OpenXml.Wordprocessing 40 | ``` 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ## Open the Existing Document 50 | To open an existing document, instantiate the **WordprocessingDocument** class as shown in the following **using** statement. In the same statement, open the word processing file at the specifiedfilepath by using the **Open** method, with the Boolean parameter set to **true** to enable editing the document. 51 | 52 | 53 | ```C# 54 | using (WordprocessingDocument doc = 55 | WordprocessingDocument.Open(filepath, true)) 56 | { 57 | // Insert other code here. 58 | } 59 | 60 | ``` 61 | 62 | 63 | 64 | 65 | ```VB.net 66 | Using doc As WordprocessingDocument = WordprocessingDocument.Open(filepath, True) 67 | ' Insert other code here. 68 | End Using 69 | ``` 70 | 71 | 72 | 73 | The **using** statement provides a recommended alternative to the typical .Open, .Save, .Close sequence. It ensures that the **Dispose** method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing brace is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this casedoc. Because the **WordprocessingDocument** class in the Open XML SDK automatically saves and closes the object as part of its **System.IDisposable** implementation, and because **Dispose** is automatically called when you exit the block, you do not have to explicitly call **Save** and **Close**-as long as you use **using**. 74 | 75 | 76 | 77 | 78 | 79 | 80 | ## The Structure of a Table 81 | The basic document structure of a **WordProcessingML** document consists of the **document** and **body** elements, followed by one or more block level elements such as **p**, which represents a paragraph. A paragraph contains one or more **r** elements. The **r** stands for run, which is a region of text with a common set of properties, such as formatting. A run contains one or more **t** elements. The **t** element contains a range of text. 82 | 83 | The document might contain a table as in this example. A table is a set of paragraphs (and other block-level content) arranged inrows andcolumns. Tables in **WordprocessingML** are defined via the **tbl** element, which is analogous to the HTML table tag. Consider an empty one-cell table (that is, a table with one row and one column) and 1 point borders on all sides. This table is represented by the following **WordprocessingML** code example. 84 | 85 | 86 | ```XML 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | ``` 110 | 111 | 112 | 113 | This table specifies table-wide properties of 100% of page width using the **tblW** element, a set of table borders using the **tblBorders** element, the table grid, which defines a set of shared vertical edges within the table using the **tblGrid** element, and a single table row using the **tr** element. 114 | 115 | 116 | 117 | 118 | 119 | 120 | ## How the Sample Code Works 121 | In the sample code, after you open the document in the **using** statement, you locate the first table in the document. Then you locate the second row in the table by finding the row whose index is 1. Next, you locate the third cell in that row whose index is 2, as shown in the following code example. 122 | 123 | 124 | ```C# 125 | // Find the first table in the document. 126 | Table table = 127 | doc.MainDocumentPart.Document.Body.Elements().First(); 128 | 129 | // Find the second row in the table. 130 | TableRow row = table.Elements().ElementAt(1); 131 | 132 | // Find the third cell in the row. 133 | TableCell cell = row.Elements().ElementAt(2); 134 | 135 | ``` 136 | 137 | 138 | 139 | 140 | ```VB.net 141 | ' Find the first table in the document. 142 | Dim table As Table = doc.MainDocumentPart.Document.Body.Elements(Of Table)().First() 143 | 144 | ' Find the second row in the table. 145 | Dim row As TableRow = table.Elements(Of TableRow)().ElementAt(1) 146 | 147 | ' Find the third cell in the row. 148 | Dim cell As TableCell = row.Elements(Of TableCell)().ElementAt(2) 149 | 150 | ``` 151 | 152 | 153 | 154 | After you have located the target cell, you locate the first run in the first paragraph of the cell and replace the text with the passed in text. The following code example shows these actions. 155 | 156 | 157 | ```C# 158 | Paragraph p = cell.Elements().First(); 159 | Run r = p.Elements().First(); 160 | Text t = r.Elements().First(); 161 | t.Text = txt; 162 | ``` 163 | 164 | 165 | 166 | 167 | ```VB.net 168 | Dim p As Paragraph = cell.Elements(Of Paragraph)().First() 169 | Dim r As Run = p.Elements(Of Run)().First() 170 | Dim t As Text = r.Elements(Of Text)().First() 171 | t.Text = txt 172 | 173 | ``` 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | ## Change Text in a Cell in a Table 183 | The following code example shows how to change the text in the specified table cell in a word processing document. The code example expects that the document, whose file name and path are passed as an argument to the **ChangeTextInCell** method, contains a table. The code example also expects that the table has at least two rows and three columns, and that the table contains text in the cell that is located at the second row and the third column position. When you call the **ChangeTextInCell** method in your program, the text in the cell at the specified location will be replaced by the text that you pass in as the second argument to the **ChangeTextInCell** method. In the following table the text "The text from the API example" was used. 184 | 185 | 186 | **** 187 | 188 |

Some text

Some text

Some text

Some text

Some text

The text from the API example

189 | 190 | 191 | 192 | 193 | 194 | ## Sample Code 195 | The **ChangeTextinCell** method changes the text in the second row and the third column of the first table found in the file. You call it by passing a full path to the file as the first parameter, and the text to use as the second parameter. For example, the following call to the **ChangeTextInCell** method changes the text in the specified cell to "The text from the API example." 196 | 197 | 198 | ```C# 199 | ChangeTextInCell(@"c:\Users\Public\Documents\word4.docx", 200 | "The text from the API example"); 201 | ``` 202 | 203 | 204 | 205 | 206 | ```VB.net 207 | ChangeTextInCell("C:\Users\Public\Documents\word4.docx", _ 208 | "The text from the API example") 209 | ``` 210 | 211 | 212 | 213 | Following is the complete code example. 214 | 215 | 216 | ```C# 217 | // Change the text in a table in a word processing document. 218 | public static void ChangeTextInCell(string filepath, string txt) 219 | { 220 | // Use the file name and path passed in as an argument to 221 | // open an existing document. 222 | using (WordprocessingDocument doc = 223 | WordprocessingDocument.Open(filepath, true)) 224 | { 225 | // Find the first table in the document. 226 | Table table = 227 | doc.MainDocumentPart.Document.Body.Elements().First(); 228 | 229 | // Find the second row in the table. 230 | TableRow row = table.Elements().ElementAt(1); 231 | 232 | // Find the third cell in the row. 233 | TableCell cell = row.Elements().ElementAt(2); 234 | 235 | // Find the first paragraph in the table cell. 236 | Paragraph p = cell.Elements().First(); 237 | 238 | // Find the first run in the paragraph. 239 | Run r = p.Elements().First(); 240 | 241 | // Set the text for the run. 242 | Text t = r.Elements().First(); 243 | t.Text = txt; 244 | } 245 | } 246 | ``` 247 | 248 | 249 | 250 | 251 | ```VB.net 252 | ' Change the text in a table in a word processing document. 253 | Public Sub ChangeTextInCell(ByVal filepath As String, ByVal txt As String) 254 | ' Use the file name and path passed in as an argument to 255 | ' Open an existing document. 256 | Using doc As WordprocessingDocument = WordprocessingDocument.Open(filepath, True) 257 | ' Find the first table in the document. 258 | Dim table As Table = doc.MainDocumentPart.Document.Body.Elements(Of Table)().First() 259 | 260 | ' Find the second row in the table. 261 | Dim row As TableRow = table.Elements(Of TableRow)().ElementAt(1) 262 | 263 | ' Find the third cell in the row. 264 | Dim cell As TableCell = row.Elements(Of TableCell)().ElementAt(2) 265 | 266 | ' Find the first paragraph in the table cell. 267 | Dim p As Paragraph = cell.Elements(Of Paragraph)().First() 268 | 269 | ' Find the first run in the paragraph. 270 | Dim r As Run = p.Elements(Of Run)().First() 271 | 272 | ' Set the text for the run. 273 | Dim t As Text = r.Elements(Of Text)().First() 274 | t.Text = txt 275 | End Using 276 | End Sub 277 | ``` 278 | 279 | 280 | 281 | 282 | ## See also 283 | 284 | #### Other resources 285 | 286 | 287 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 288 | 289 | [How to: Change Text in a Table in a Word Processing Document](http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.table(office.14).aspx) 290 | 291 | [Language-Integrated Query (LINQ)](http://msdn.microsoft.com/en-us/library/bb397926.aspx) 292 | 293 | [Extension Methods (C# Programming Guide)](http://msdn.microsoft.com/en-us/library/bb383977.aspx) 294 | 295 | [Extension Methods (Visual Basic)](http://msdn.microsoft.com/en-us/library/bb384936.aspx) 296 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/6de46612-f864-413f-a504-11ea85f1f88f.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/6de46612-f864-413f-a504-11ea85f1f88f.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/70839c86-36ef-4b67-a682-abd5114b2bfe.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/70839c86-36ef-4b67-a682-abd5114b2bfe.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/73cbca2d-3603-45a5-8a73-c2e718376b01.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/73cbca2d-3603-45a5-8a73-c2e718376b01.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/75cff172-b29d-475a-8eb5-d8e90642f015.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Open a word processing document from a stream (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [When to Open a Document from a Stream](#sectionSection1) 10 | 11 | [Creating a WordprocessingDocument Object](#sectionSection2) 12 | 13 | [Structure of a WordProcessingML Document](#sectionSection3) 14 | 15 | [How the Sample Code Works](#sectionSection4) 16 | 17 | [Sample Code](#sectionSection5) 18 | 19 | 20 | 21 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically open a Word processing document from a stream. 22 | 23 | The following assembly directives are required to compile the code in this topic. 24 | 25 | 26 | ```C# 27 | using System.IO; 28 | using DocumentFormat.OpenXml.Packaging; 29 | using DocumentFormat.OpenXml.Wordprocessing; 30 | 31 | ``` 32 | 33 | 34 | 35 | 36 | ```VB.net 37 | Imports System.IO 38 | Imports DocumentFormat.OpenXml.Packaging 39 | Imports DocumentFormat.OpenXml.Wordprocessing 40 | 41 | ``` 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ## When to Open a Document from a Stream 51 | If you have an application, such as a SharePoint application, that works with documents using stream input/output, and you want to employ the Open XML SDK 2.5 to work with one of the documents, this is designed to be easy to do. This is particularly true if the document exists and you can open it using the Open XML SDK 2.5. However, suppose the document is an open stream at the point in your code where you need to employ the SDK to work with it? That is the scenario for this topic. The sample method in the sample code accepts an open stream as a parameter and then adds text to the document behind the stream using the Open XML SDK 2.5. 52 | 53 | 54 | 55 | 56 | 57 | 58 | ## Creating a WordprocessingDocument Object 59 | In the Open XML SDK, the **WordprocessingDocument** class represents a Word document package. To work with a Word document, first create an instance of the **WordprocessingDocument** class from the document, and then work with that instance. When you create the instance from the document, you can then obtain access to the main document part that contains the text of the document. Every Open XML package contains some number of parts. At a minimum, a **WordProcessingDocument** must contain a main document part that acts as a container for the main text of the document. The package can also contain additional parts. Notice that in a Word document, the text in the main document part is represented in the package as XML using **WordprocessingML** markup. 60 | 61 | To create the class instance from the document call the **Open(Stream, Boolean)** method. Several **Open** methods are provided, each with a different signature. The sample code in this topic uses the **Open** method with a signature that requires two parameters. The first parameter takes a handle to the stream from which you want to open the document. The second parameter is either **true** or **false** and represents whether the stream is opened for editing. 62 | 63 | The following code example calls the **Open** method. 64 | 65 | 66 | ```C# 67 | // Open a WordProcessingDocument based on a stream. 68 | WordprocessingDocument wordprocessingDocument = 69 | WordprocessingDocument.Open(stream, true); 70 | 71 | ``` 72 | 73 | 74 | 75 | 76 | ```VB.net 77 | ' Open a WordProcessingDocument based on a stream. 78 | Dim wordprocessingDocument As WordprocessingDocument = _ 79 | WordprocessingDocument.Open(stream, True) 80 | ``` 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | ## Structure of a WordProcessingML Document 90 | The basic document structure of a **WordProcessingML** document consists of the **document** and **body** elements, followed by one or more block level elements such as **p**, which represents a paragraph. A paragraph contains one or more **r** elements. The **r** stands for run, which is a region of text with a common set of properties, such as formatting. A run contains one or more **t** elements. The **t** element contains a range of text. For example, the WordprocessingML markup for a document that contains only the text "Example text." is shown in the following code example. 91 | 92 | 93 | ```XML 94 | 95 | 96 | 97 | 98 | Example text. 99 | 100 | 101 | 102 | 103 | ``` 104 | 105 | 106 | 107 | Using the Open XML SDK 2.5, you can create document structure and content using strongly-typed classes that correspond to WordprocessingML elements. You can find these classes in the **DocumentFormat.OpenXml.Wordprocessing** namespace. The following table lists the class names of the classes that correspond to the **document**, **body**, **p**, **r**, and **t** elements. 108 | 109 | 110 | **** 111 | 112 |

WordprocessingML Element

Open XML SDK 2.5 Class

Description

document

Document

The root element for the main document part.

body

Body

The container for the block-level structures such as paragraphs, tables, annotations, and others specified in the ISO/IEC 29500 specification.

p

Paragraph

A paragraph.

r

Run

A run.

t

Text

A range of text.

113 | 114 | 115 | 116 | 117 | 118 | ## How the Sample Code Works 119 | When you open the Word document package, you can add text to the main document part. To access the body of the main document part you assign a reference to the existing document body, as shown in the following code segment. 120 | 121 | 122 | ```C# 123 | // Assign a reference to the existing document body. 124 | Body body = wordprocessingDocument.MainDocumentPart.Document.Body; 125 | 126 | ``` 127 | 128 | 129 | 130 | 131 | ```VB.net 132 | ' Assign a reference to the existing document body. 133 | Dim body As Body = wordprocessingDocument.MainDocumentPart.Document.Body 134 | ``` 135 | 136 | 137 | 138 | When you access to the body of the main document part, add text by adding instances of the **Paragraph**, **Run**, and **Text** classes. This generates the required **WordprocessingML** markup. The following lines from the sample code add the paragraph, run, and text. 139 | 140 | 141 | ```C# 142 | // Add new text. 143 | Paragraph para = body.AppendChild(new Paragraph()); 144 | Run run = para.AppendChild(new Run()); 145 | run.AppendChild(new Text(txt)); 146 | ``` 147 | 148 | 149 | 150 | 151 | ```VB.net 152 | ' Add new text. 153 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 154 | Dim run As Run = para.AppendChild(New Run()) 155 | run.AppendChild(New Text(txt)) 156 | ``` 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | ## Sample Code 166 | The example **OpenAndAddToWordprocessingStream** method shown here can be used to open a Word document from an already open stream and append some text using the Open XML SDK. You can call it by passing a handle to an open stream as the first parameter and the text to add as the second. For example, the following code example opens the Word13.docx file in the Public Documents folder and adds text to it. 167 | 168 | 169 | ```C# 170 | string strDoc = @"C:\Users\Public\Public Documents\Word13.docx"; 171 | string txt = "Append text in body - OpenAndAddToWordprocessingStream"; 172 | Stream stream = File.Open(strDoc, FileMode.Open); 173 | OpenAndAddToWordprocessingStream(stream, txt); 174 | stream.Close(); 175 | ``` 176 | 177 | 178 | 179 | 180 | ```VB.net 181 | Dim strDoc As String = "C:\Users\Public\Documents\Word13.docx" 182 | Dim txt As String = "Append text in body - OpenAndAddToWordprocessingStream" 183 | Dim stream As Stream = File.Open(strDoc, FileMode.Open) 184 | OpenAndAddToWordprocessingStream(stream, txt) 185 | stream.Close() 186 | ``` 187 | 188 | 189 | 190 | 191 | **Note** Notice that the **OpenAddAddToWordprocessingStream** method does not close the stream passed to it. The calling code must do that. 192 | 193 | 194 | Following is the complete sample code in both C# and Visual Basic. 195 | 196 | 197 | ```C# 198 | public static void OpenAndAddToWordprocessingStream(Stream stream, string txt) 199 | { 200 | // Open a WordProcessingDocument based on a stream. 201 | WordprocessingDocument wordprocessingDocument = 202 | WordprocessingDocument.Open(stream, true); 203 | 204 | // Assign a reference to the existing document body. 205 | Body body = wordprocessingDocument.MainDocumentPart.Document.Body; 206 | 207 | // Add new text. 208 | Paragraph para = body.AppendChild(new Paragraph()); 209 | Run run = para.AppendChild(new Run()); 210 | run.AppendChild(new Text(txt)); 211 | 212 | // Close the document handle. 213 | wordprocessingDocument.Close(); 214 | 215 | // Caller must close the stream. 216 | } 217 | ``` 218 | 219 | 220 | 221 | 222 | ```VB.net 223 | Public Sub OpenAndAddToWordprocessingStream(ByVal stream As Stream, ByVal txt As String) 224 | ' Open a WordProcessingDocument based on a stream. 225 | Dim wordprocessingDocument As WordprocessingDocument = WordprocessingDocument.Open(stream, true) 226 | 227 | ' Assign a reference to the existing document body. 228 | Dim body As Body = wordprocessingDocument.MainDocumentPart.Document.Body 229 | 230 | ' Add new text. 231 | Dim para As Paragraph = body.AppendChild(New Paragraph) 232 | Dim run As Run = para.AppendChild(New Run) 233 | run.AppendChild(New Text(txt)) 234 | 235 | ' Close the document handle. 236 | wordprocessingDocument.Close 237 | 238 | ' Caller must close the stream. 239 | End Sub 240 | ``` 241 | 242 | 243 | 244 | 245 | ## See also 246 | 247 | #### Other resources 248 | 249 | 250 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 251 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/7808dcc4-8f50-42c4-bad1-d69fe5f045fe.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/7808dcc4-8f50-42c4-bad1-d69fe5f045fe.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/7b72277f-3c5e-43ba-bbd8-7467cf532c95.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/7b72277f-3c5e-43ba-bbd8-7467cf532c95.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md: -------------------------------------------------------------------------------- 1 | 2 | # Getting started with the Open XML SDK 2.5 for Office 3 | **Last modified:** July 25, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | The Open XML SDK 2.5 for Office simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. The classes in the Open XML SDK 2.5 encapsulate many common tasks that developers perform on Open XML packages, so that you can perform complex operations with just a few lines of code. 8 | 9 | 10 | ## Using the Classes in the Open XML SDK 11 | Using the classes in the Open XML SDK 2.5 is simple. When you have installed the Open XML SDK 2.5, open your existing project or application in Visual Studio, or create a new project or application. Then, in your project or application, add references to the following components. 12 | 13 | 14 | - **DocumentFormat.OpenXml** 15 | 16 | 17 | - **WindowsBase** 18 | 19 | 20 | 21 | 22 | ### To add a reference in a Microsoft Visual Studio 2008 project 23 | 24 | 1. In Solution Explorer, right-click References and then click **Add Reference**. If the References node is not visible, click **Project** and then click **Show All Files**. 25 | 26 | 27 | 28 | 2. In the **Add Reference** dialog box, click **.NET**. 29 | 30 | 31 | 32 | 3. In the **Component Name** column, select the components (scroll if you need to), and then click **OK**. 33 | 34 | 35 | **Tip** To select more than one component, hold down the Ctrl key and click each component. 36 | 37 | 38 | 39 | 40 | 41 | The added components are displayed in the References section in Solution Explorer. 42 | 43 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/7dbfd93c-a9e3-4465-9b57-4a043b07b807.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/7dbfd93c-a9e3-4465-9b57-4a043b07b807.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/7dfd78a3-e233-4abd-8c17-1e384780d3ec.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/7dfd78a3-e233-4abd-8c17-1e384780d3ec.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/7fde676b-81b6-4210-82bf-f74d0d925dec.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Open a spreadsheet document from a stream (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [When to Open From a Stream](#sectionSection1) 10 | 11 | [Getting a SpreadsheetDocument Object](#sectionSection2) 12 | 13 | [Generating the SpreadsheetML Markup to Add a Worksheet](#sectionSection3) 14 | 15 | [Sample Code](#sectionSection4) 16 | 17 | 18 | 19 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to open a spreadsheet document from a stream programmatically. 20 | 21 | The following assembly directives are required to compile the code in this topic. 22 | 23 | 24 | ```C# 25 | using System.IO; 26 | using DocumentFormat.OpenXml.Packaging; 27 | using DocumentFormat.OpenXml.Spreadsheet; 28 | using System.Linq; 29 | 30 | ``` 31 | 32 | 33 | 34 | 35 | ```VB.net 36 | Imports System.IO 37 | Imports DocumentFormat.OpenXml.Packaging 38 | Imports DocumentFormat.OpenXml.Spreadsheet 39 | Imports System.Linq 40 | 41 | ``` 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ## When to Open From a Stream 51 | If you have an application, such as Microsoft SharePoint Foundation 2010, that works with documents by using stream input/output, and you want to use the Open XML SDK 2.5 to work with one of the documents, this is designed to be easy to do. This is especially true if the document exists and you can open it using the Open XML SDK 2.5. However, suppose that the document is an open stream at the point in your code where you must use the SDK to work with it? That is the scenario for this topic. The sample method in the sample code accepts an open stream as a parameter and then adds text to the document behind the stream using the Open XML SDK 2.5. 52 | 53 | 54 | 55 | 56 | 57 | 58 | ## Getting a SpreadsheetDocument Object 59 | In the Open XML SDK, the **SpreadsheetDocument** class represents an Excel document package. To open and work with an Excel document, you create an instance of the **SpreadsheetDocument** class from the document. After you create the instance from the document, you can then obtain access to the main workbook part that contains the worksheets. The text in the document is represented in the package as XML using SpreadsheetML markup. 60 | 61 | To create the class instance from the document, you call one of the **Open()** methods. Several are provided, each with a different signature. The sample code in this topic uses the **Open(String, Boolean)** method with a signature that requires two parameters. The first parameter takes a full path string that represents the document that you want to open. The second parameter is either **true** or **false** and represents whether you want the file to be opened for editing. Any changes that you make to the document will not be saved if this parameter is **false**. 62 | 63 | The code that calls the **Open** method is shown in the following example. 64 | 65 | 66 | ```C# 67 | // Open the document for editing. 68 | using (SpreadsheetDocument document = SpreadsheetDocument.Open(docName, true)) 69 | ``` 70 | 71 | 72 | 73 | 74 | ```VB.net 75 | ' Open the document for editing. 76 | Using document As SpreadsheetDocument = SpreadsheetDocument.Open(docName, True) 77 | ``` 78 | 79 | 80 | 81 | After you have opened the spreadsheet document package, you can add a row to a sheet in the workbook. Each workbook has a workbook part and at least one **Worksheet**. To access the **Workbook** assign a reference to the existing document body, represented by the **WorkbookPart**, as shown in the following code example. 82 | 83 | 84 | ```C# 85 | WorkbookPart wbPart = document.WorkbookPart; 86 | ``` 87 | 88 | 89 | 90 | 91 | ```VB.net 92 | Dim wbPart As WorkbookPart = document.WorkbookPart 93 | ``` 94 | 95 | 96 | 97 | The basic document structure of a SpreadsheetML document consists of the **Sheets** and **Sheet** elements, which reference the worksheets in the workbook. A separate XML file is created for each worksheet. For example, the SpreadsheetML for a workbook that has two worksheets name MySheet1 and MySheet2 is located in the Workbook.xml file and is shown in the following code example. 98 | 99 | 100 | ```XML 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | ``` 110 | 111 | 112 | 113 | The worksheet XML files contain one or more block level elements such as **SheetData**. **sheetData** represents the cell table and contains one or more **Row** elements. A **row** contains one or more **Cell** elements. Each cell contains a **CellValue** element that represents the value of the cell. For example, the **SpreadsheetML** for the first worksheet in a workbook, that only has the value 100 in cell A1, is located in the Sheet1.xml file and is shown in the following code example. 114 | 115 | 116 | ```XML 117 | 118 | 119 | 120 | 121 | 122 | 100 123 | 124 | 125 | 126 | 127 | ``` 128 | 129 | 130 | 131 | Using the Open XML SDK 2.5, you can create document structure and content that uses strongly-typed classes that correspond to SpreadsheetML elements. You can find these classes in the **DocumentFormat.OpenXML.Spreadsheet** namespace. The following table lists the class names of the classes that correspond to the **workbook**, **sheets**, **sheet**, **worksheet**, and **sheetData** elements. 132 | 133 | 134 | **** 135 | 136 |

SpreadsheetML Element

Open XML SDK 2.5 Class

Description

workbook

DocumentFormat.OpenXml.Spreadsheet.Workbook

The root element for the main document part.

sheets

DocumentFormat.OpenXml.Spreadsheet.Sheets

The container for the block level structures such as sheet, fileVersion, and others specified in the ISO/IEC 29500 specification.

sheet

DocumentFormat.OpenXml.Spreadsheet.Sheet

A sheet that points to a sheet definition file.

worksheet

DocumentFormat.OpenXml.Spreadsheet.Worksheet

A sheet definition file that contains the sheet data.

sheetData

DocumentFormat.OpenXml.Spreadsheet.SheetData

The cell table, grouped together by rows.

row

DocumentFormat.OpenXml.Spreadsheet.Row

A row in the cell table.

c

DocumentFormat.OpenXml.Spreadsheet.Cell

A cell in a row.

v

DocumentFormat.OpenXml.Spreadsheet.CellValue

The value of a cell.

137 |
138 | 139 | 140 | 141 | 142 | ## Generating the SpreadsheetML Markup to Add a Worksheet 143 | When you have access to the body of the main document part, you add a worksheet by calling **AddNewPart(String, String)** method to create a new **WorksheetPart**. The following code example adds the new **WorksheetPart**. 144 | 145 | 146 | ```C# 147 | // Add a new worksheet. 148 | WorksheetPart newWorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart(); 149 | newWorksheetPart.Worksheet = new Worksheet(new SheetData()); 150 | newWorksheetPart.Worksheet.Save(); 151 | ``` 152 | 153 | 154 | 155 | 156 | ```VB.net 157 | ' Add a new worksheet. 158 | Dim newWorksheetPart As WorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart(Of WorksheetPart)() 159 | newWorksheetPart.Worksheet = New Worksheet(New SheetData()) 160 | newWorksheetPart.Worksheet.Save() 161 | ``` 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | ## Sample Code 171 | In this example, the **OpenAndAddToSpreadsheetStream** method can be used to open a spreadsheet document from an already open stream and append some text to it. In your program, you can use the following example to call the **OpenAndAddToSpreadsheetStream** method that uses a file named Sheet11.xslx. 172 | 173 | 174 | ```C# 175 | string strDoc = @"C:\Users\Public\Documents\Sheet11.xlsx"; 176 | ; 177 | Stream stream = File.Open(strDoc, FileMode.Open); 178 | OpenAndAddToSpreadsheetStream(stream); 179 | stream.Close(); 180 | ``` 181 | 182 | 183 | 184 | 185 | ```VB.net 186 | Dim strDoc As String = "C:\Users\Public\Documents\Sheet11.xlsx" 187 | Dim stream As Stream = File.Open(strDoc, FileMode.Open) 188 | OpenAndAddToSpreadsheetStream(stream) 189 | stream.Close() 190 | ``` 191 | 192 | 193 | 194 | Notice that the **OpenAddAndAddToSpreadsheetStream** method does not close the stream passed to it. The calling code must do that. 195 | 196 | The following is the complete sample code in both C# and Visual Basic. 197 | 198 | 199 | ```C# 200 | public static void OpenAndAddToSpreadsheetStream(Stream stream) 201 | { 202 | // Open a SpreadsheetDocument based on a stream. 203 | SpreadsheetDocument spreadsheetDocument = 204 | SpreadsheetDocument.Open(stream, true); 205 | 206 | // Add a new worksheet. 207 | WorksheetPart newWorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart(); 208 | newWorksheetPart.Worksheet = new Worksheet(new SheetData()); 209 | newWorksheetPart.Worksheet.Save(); 210 | 211 | Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild(); 212 | string relationshipId = spreadsheetDocument.WorkbookPart.GetIdOfPart(newWorksheetPart); 213 | 214 | // Get a unique ID for the new worksheet. 215 | uint sheetId = 1; 216 | if (sheets.Elements().Count() > 0) 217 | { 218 | sheetId = sheets.Elements().Select(s => s.SheetId.Value).Max() + 1; 219 | } 220 | 221 | // Give the new worksheet a name. 222 | string sheetName = "Sheet" + sheetId; 223 | 224 | // Append the new worksheet and associate it with the workbook. 225 | Sheet sheet = new Sheet() { Id = relationshipId, SheetId = sheetId, Name = sheetName }; 226 | sheets.Append(sheet); 227 | spreadsheetDocument.WorkbookPart.Workbook.Save(); 228 | 229 | // Close the document handle. 230 | spreadsheetDocument.Close(); 231 | 232 | // Caller must close the stream. 233 | } 234 | 235 | ``` 236 | 237 | 238 | 239 | 240 | ```VB.net 241 | Public Sub OpenAndAddToSpreadsheetStream(ByVal stream As Stream) 242 | ' Open a SpreadsheetDocument based on a stream. 243 | Dim mySpreadsheetDocument As SpreadsheetDocument = SpreadsheetDocument.Open(stream, True) 244 | 245 | ' Add a new worksheet. 246 | Dim newWorksheetPart As WorksheetPart = mySpreadsheetDocument.WorkbookPart.AddNewPart(Of WorksheetPart)() 247 | newWorksheetPart.Worksheet = New Worksheet(New SheetData()) 248 | newWorksheetPart.Worksheet.Save() 249 | 250 | Dim sheets As Sheets = mySpreadsheetDocument.WorkbookPart.Workbook.GetFirstChild(Of Sheets)() 251 | Dim relationshipId As String = mySpreadsheetDocument.WorkbookPart.GetIdOfPart(newWorksheetPart) 252 | 253 | ' Get a unique ID for the new worksheet. 254 | Dim sheetId As UInteger = 1 255 | If (sheets.Elements(Of Sheet).Count > 0) Then 256 | sheetId = sheets.Elements(Of Sheet).Select(Function(s) s.SheetId.Value).Max + 1 257 | End If 258 | 259 | ' Give the new worksheet a name. 260 | Dim sheetName As String = ("Sheet" + sheetId.ToString()) 261 | 262 | ' Append the new worksheet and associate it with the workbook. 263 | Dim sheet As Sheet = New Sheet 264 | sheet.Id = relationshipId 265 | sheet.SheetId = sheetId 266 | sheet.Name = sheetName 267 | sheets.Append(sheet) 268 | mySpreadsheetDocument.WorkbookPart.Workbook.Save() 269 | 270 | 'Close the document handle. 271 | mySpreadsheetDocument.Close() 272 | 273 | 'Caller must close the stream. 274 | End Sub 275 | ``` 276 | 277 | 278 | 279 | 280 | ## See also 281 | 282 | #### Other resources 283 | 284 | 285 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 286 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/80cdc1e8-d023-4886-b8d6-ee26327df739.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/80cdc1e8-d023-4886-b8d6-ee26327df739.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/82deb499-7479-474d-9d89-c4847e6f3649.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/82deb499-7479-474d-9d89-c4847e6f3649.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/8a9117f7-066e-409c-8681-a26610c0eede.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/8a9117f7-066e-409c-8681-a26610c0eede.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/8d465a77-6c1b-453a-8375-ecf80d2f1bdc.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/8d465a77-6c1b-453a-8375-ecf80d2f1bdc.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/8dc8a6ac-aa9e-47cc-b45e-e128fcec3c57.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/8dc8a6ac-aa9e-47cc-b45e-e128fcec3c57.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/95fd9dcd-41e9-4e83-9191-2f3110ae73d5.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/95fd9dcd-41e9-4e83-9191-2f3110ae73d5.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/96697c37-3fa7-4814-85b6-657439435ce1.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/96697c37-3fa7-4814-85b6-657439435ce1.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/98781b17-8de4-46e9-b29a-5b4033665491.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/98781b17-8de4-46e9-b29a-5b4033665491.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/a0c1e144-2080-4470-bd4b-ed98f1399374.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/a0c1e144-2080-4470-bd4b-ed98f1399374.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/a20bf30b-204e-4c57-8ca3-badf4b0b3e03.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Validate a word processing document (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically validate a word processing document. 8 | 9 | The following assembly directives are required to compile the code in this topic. 10 | 11 | 12 | ```C# 13 | using System; 14 | using DocumentFormat.OpenXml.Packaging; 15 | using DocumentFormat.OpenXml.Validation; 16 | using DocumentFormat.OpenXml.Wordprocessing; 17 | 18 | ``` 19 | 20 | 21 | 22 | 23 | ```VB.net 24 | Imports System 25 | Imports DocumentFormat.OpenXml.Packaging 26 | Imports DocumentFormat.OpenXml.Validation 27 | Imports DocumentFormat.OpenXml.Wordprocessing 28 | 29 | ``` 30 | 31 | 32 | 33 | 34 | ## How the Sample Code Works 35 | This code example consists of two methods. The first method, **ValidateWordDocument**, is used to validate a regular Word file. It doesn't throw any exceptions and closes the file after running the validation check. The second method, **ValidateCorruptedWordDocument**, starts by inserting some text into the body, which causes a schema error. It then validates the Word file, in which case the method throws an exception on trying to open the corrupted file. The validation is done by using the **Validate** method. The code displays information about any errors that are found, in addition to the count of errors. 36 | 37 | 38 | ## Sample Code 39 | In your main method, you can call the two methods, **ValidateWordDocument** and **ValidateCorruptedWordDocument** by using the following example that validates a file named "Word18.docx.". 40 | 41 | 42 | ```C# 43 | string filepath = @"C:\Users\Public\Documents\Word18.docx"; 44 | ValidateWordDocument(filepath); 45 | Console.WriteLine("The file is valid so far."); 46 | Console.WriteLine("Inserting some text into the body that would cause Schema error"); 47 | Console.ReadKey(); 48 | 49 | ValidateCorruptedWordDocument(filepath); 50 | Console.WriteLine("All done! Press a key."); 51 | Console.ReadKey(); 52 | 53 | ``` 54 | 55 | 56 | 57 | 58 | ```VB.net 59 | Dim filepath As String = "C:\Users\Public\Documents\Word18.docx" 60 | ValidateWordDocument(filepath) 61 | Console.WriteLine("The file is valid so far.") 62 | Console.WriteLine("Inserting some text into the body that would cause Schema error") 63 | Console.ReadKey() 64 | 65 | ValidateCorruptedWordDocument(filepath) 66 | Console.WriteLine("All done! Press a key.") 67 | Console.ReadKey() 68 | 69 | ``` 70 | 71 | 72 | 73 | 74 | **Important** Notice that you cannot run the code twice after corrupting the file in the first run. You have to start with a new Word file. 75 | 76 | 77 | Following is the complete sample code in both C# and Visual Basic. 78 | 79 | 80 | ```C# 81 | public static void ValidateWordDocument(string filepath) 82 | { 83 | using (WordprocessingDocument wordprocessingDocument = 84 | WordprocessingDocument.Open(filepath, true)) 85 | { 86 | try 87 | { 88 | OpenXmlValidator validator = new OpenXmlValidator(); 89 | int count = 0; 90 | foreach (ValidationErrorInfo error in 91 | validator.Validate(wordprocessingDocument)) 92 | { 93 | count++; 94 | Console.WriteLine("Error " + count); 95 | Console.WriteLine("Description: " + error.Description); 96 | Console.WriteLine("ErrorType: " + error.ErrorType); 97 | Console.WriteLine("Node: " + error.Node); 98 | Console.WriteLine("Path: " + error.Path.XPath); 99 | Console.WriteLine("Part: " + error.Part.Uri); 100 | Console.WriteLine("-------------------------------------------"); 101 | } 102 | 103 | Console.WriteLine("count={0}", count); 104 | } 105 | 106 | catch (Exception ex) 107 | { 108 | Console.WriteLine(ex.Message); 109 | } 110 | 111 | wordprocessingDocument.Close(); 112 | } 113 | } 114 | 115 | public static void ValidateCorruptedWordDocument(string filepath) 116 | { 117 | // Insert some text into the body, this would cause Schema Error 118 | using (WordprocessingDocument wordprocessingDocument = 119 | WordprocessingDocument.Open(filepath, true)) 120 | { 121 | // Insert some text into the body, this would cause Schema Error 122 | Body body = wordprocessingDocument.MainDocumentPart.Document.Body; 123 | Run run = new Run(new Text("some text")); 124 | body.Append(run); 125 | 126 | try 127 | { 128 | OpenXmlValidator validator = new OpenXmlValidator(); 129 | int count = 0; 130 | foreach (ValidationErrorInfo error in 131 | validator.Validate(wordprocessingDocument)) 132 | { 133 | count++; 134 | Console.WriteLine("Error " + count); 135 | Console.WriteLine("Description: " + error.Description); 136 | Console.WriteLine("ErrorType: " + error.ErrorType); 137 | Console.WriteLine("Node: " + error.Node); 138 | Console.WriteLine("Path: " + error.Path.XPath); 139 | Console.WriteLine("Part: " + error.Part.Uri); 140 | Console.WriteLine("-------------------------------------------"); 141 | } 142 | 143 | Console.WriteLine("count={0}", count); 144 | } 145 | 146 | catch (Exception ex) 147 | { 148 | Console.WriteLine(ex.Message); 149 | } 150 | } 151 | } 152 | 153 | ``` 154 | 155 | 156 | 157 | 158 | ```VB.net 159 | Public Sub ValidateWordDocument(ByVal filepath As String) 160 | Using wordprocessingDocument__1 As WordprocessingDocument = WordprocessingDocument.Open(filepath, True) 161 | Try 162 | Dim validator As New OpenXmlValidator() 163 | Dim count As Integer = 0 164 | For Each [error] As ValidationErrorInfo In validator.Validate(wordprocessingDocument__1) 165 | count += 1 166 | Console.WriteLine("Error " & count) 167 | Console.WriteLine("Description: " & [error].Description) 168 | Console.WriteLine("ErrorType: " & [error].ErrorType) 169 | Console.WriteLine("Node: " & [error].Node.ToString()) 170 | Console.WriteLine("Path: " & [error].Path.XPath) 171 | Console.WriteLine("Part: " & [error].Part.Uri.ToString()) 172 | Console.WriteLine("-------------------------------------------") 173 | Next 174 | 175 | Console.WriteLine("count={0}", count) 176 | 177 | Catch ex As Exception 178 | Console.WriteLine(ex.Message) 179 | End Try 180 | 181 | wordprocessingDocument__1.Close() 182 | End Using 183 | End Sub 184 | 185 | Public Sub ValidateCorruptedWordDocument(ByVal filepath As String) 186 | ' Insert some text into the body, this would cause Schema Error 187 | Using wordprocessingDocument__1 As WordprocessingDocument = WordprocessingDocument.Open(filepath, True) 188 | ' Insert some text into the body, this would cause Schema Error 189 | Dim body As Body = wordprocessingDocument__1.MainDocumentPart.Document.Body 190 | Dim run As New Run(New Text("some text")) 191 | body.Append(run) 192 | 193 | Try 194 | Dim validator As New OpenXmlValidator() 195 | Dim count As Integer = 0 196 | For Each [error] As ValidationErrorInfo In validator.Validate(wordprocessingDocument__1) 197 | count += 1 198 | Console.WriteLine("Error " & count) 199 | Console.WriteLine("Description: " & [error].Description) 200 | Console.WriteLine("ErrorType: " & [error].ErrorType) 201 | Console.WriteLine("Node: " & [error].Node.ToString()) 202 | Console.WriteLine("Path: " & [error].Path.XPath) 203 | Console.WriteLine("Part: " & [error].Part.Uri.ToString()) 204 | Console.WriteLine("-------------------------------------------") 205 | Next 206 | 207 | Console.WriteLine("count={0}", count) 208 | 209 | Catch ex As Exception 210 | Console.WriteLine(ex.Message) 211 | End Try 212 | End Using 213 | End Sub 214 | ``` 215 | 216 | 217 | 218 | 219 | ## See also 220 | 221 | #### Other resources 222 | 223 | 224 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 225 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/a6d35b76-d12a-460c-9d9d-2334abde759e.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/a6d35b76-d12a-460c-9d9d-2334abde759e.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/ada81388-9ed2-43f4-ab2c-2bb82f711e90.md: -------------------------------------------------------------------------------- 1 | 2 | # Understanding the Open XML file formats 3 | **Last modified:** January 13, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides conceptual topics for understanding and working the Open XML file formats and markup languages. 8 | 9 | 10 | ## In this section 11 | [Introduction to markup compatibility (Open XML SDK)](dd42a9a3-5c16-4cab-ad6d-506cf822ec7a.md) 12 | 13 | [Working with PresentationML documents (Open XML SDK)](56aeeed4-24ce-42ba-a236-6fec6785dd93.md) 14 | 15 | [Working with SpreadsheetML documents (Open XML SDK)](c984c74e-2f06-4aba-a64b-2bb928b2929e.md) 16 | 17 | [Working with WordprocessingML documents (Open XML SDK)](bead244f-b551-477f-a296-41ead7bfcf5c.md) 18 | 19 | 20 | ## Related sections 21 | [How do I... (Open XML SDK)](b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md) 22 | 23 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/ae8c98d9-dd11-4b75-804c-165095d60ffd.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/ae8c98d9-dd11-4b75-804c-165095d60ffd.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/b0d3d890-431a-4838-89dc-1f0dccd5dcd0.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/b0d3d890-431a-4838-89dc-1f0dccd5dcd0.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/b3890e64-51d1-4643-8d07-2c9d8e060000.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/b3890e64-51d1-4643-8d07-2c9d8e060000.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md: -------------------------------------------------------------------------------- 1 | 2 | # How do I... (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides how-to topics for working with the Open XML SDK 2.5 for Office. 8 | 9 | 10 | ## In this section 11 | [Presentations (Open XML SDK)](0a81a7fb-c431-4f53-a199-e72eea91f360.md) 12 | 13 | [Packages and general (Open XML SDK)](edbe267a-ced9-43fd-a702-fd0165cb3438.md) 14 | 15 | [Spreadsheets (Open XML SDK)](7808dcc4-8f50-42c4-bad1-d69fe5f045fe.md) 16 | 17 | [Word processing (Open XML SDK)](4fcb7fbb-0796-4737-8f05-acbcfa9e1a06.md) 18 | 19 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/b6f429a7-4489-4155-b713-2139f3add8c2.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/b6f429a7-4489-4155-b713-2139f3add8c2.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/b6f5afca-5feb-4003-b803-55dd2f9bf6d2.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/b6f5afca-5feb-4003-b803-55dd2f9bf6d2.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/b7d5d1fd-dcdf-4f88-9d57-884562c8144f.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/b7d5d1fd-dcdf-4f88-9d57-884562c8144f.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/bb5319c8-ee99-4862-937b-94dcae8deaca.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/bb5319c8-ee99-4862-937b-94dcae8deaca.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/bead244f-b551-477f-a296-41ead7bfcf5c.md: -------------------------------------------------------------------------------- 1 | 2 | # Working with WordprocessingML documents (Open XML SDK) 3 | **Last modified:** January 13, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides conceptual topics for working with WordprocessingML documents. 8 | 9 | 10 | ## In this section 11 | [Working with paragraphs (Open XML SDK)](8a9117f7-066e-409c-8681-a26610c0eede.md) 12 | 13 | [Working with runs (Open XML SDK)](1fbc6d30-bfe4-4b2b-8fd8-0c5a400d1e03.md) 14 | 15 | [Working with WordprocessingML tables (Open XML SDK)](2ac3a285-8060-4f89-ae12-38ddbee00094.md) 16 | 17 | [Structure of a WordprocessingML document (Open XML SDK)](03636fa2-be44-4e8d-9c26-7d38415bb459.md) 18 | 19 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/c38f2c94-f0b5-4bb5-8c95-02e556d4e9f1.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/c38f2c94-f0b5-4bb5-8c95-02e556d4e9f1.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/c66a64ca-cb0d-4acc-9d05-535b5bbb8c96.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/c66a64ca-cb0d-4acc-9d05-535b5bbb8c96.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/c984c74e-2f06-4aba-a64b-2bb928b2929e.md: -------------------------------------------------------------------------------- 1 | 2 | # Working with SpreadsheetML documents (Open XML SDK) 3 | **Last modified:** January 13, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides conceptual topics for working with SpreadsheetML documents. 8 | 9 | 10 | ## In this section 11 | [Structure of a SpreadsheetML document (Open XML SDK)](3b35a153-c8ff-4dc7-96d5-02c515f31770.md) 12 | 13 | [Working with the calculation chain (Open XML SDK)](ffdf5bd3-53f5-4f48-8946-11a0287fb107.md) 14 | 15 | [Working with conditional formatting (Open XML SDK)](b6f5afca-5feb-4003-b803-55dd2f9bf6d2.md) 16 | 17 | [Working with formulas (Open XML SDK)](17abd341-abe9-4eee-9bb3-27fded0b04d2.md) 18 | 19 | [Working with PivotTables (Open XML SDK)](96697c37-3fa7-4814-85b6-657439435ce1.md) 20 | 21 | [Working with the shared string table (Open XML SDK)](36664cc7-30ef-4e9b-b569-846a9e404219.md) 22 | 23 | [Working with sheets (Open XML SDK)](119a7eb6-9a02-4914-b651-9ba090bf7994.md) 24 | 25 | [Working with SpreadsheetML tables (Open XML SDK)](7b72277f-3c5e-43ba-bbd8-7467cf532c95.md) 26 | 27 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/cbb4547e-45fa-48ee-872e-8727beec6dfa.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Search and replace text in a document part (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Packages and Document Parts](#sectionSection1) 10 | 11 | [Getting a WordprocessingDocument Object](#sectionSection2) 12 | 13 | [How the Sample Code Works](#sectionSection3) 14 | 15 | [Sample Code](#sectionSection4) 16 | 17 | 18 | 19 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically search and replace a text value in a word processing document. 20 | 21 | The following assembly directives are required to compile the code in this topic. 22 | 23 | 24 | ```C# 25 | using System.IO; 26 | using System.Text.RegularExpressions; 27 | using DocumentFormat.OpenXml.Packaging; 28 | 29 | ``` 30 | 31 | 32 | 33 | 34 | ```VB.net 35 | Imports System.IO 36 | Imports System.Text.RegularExpressions 37 | Imports DocumentFormat.OpenXml.Packaging 38 | 39 | ``` 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## Packages and Document Parts 49 | An Open XML document is stored as a package, whose format is defined by [ISO/IEC 29500-2](http://go.microsoft.com/fwlink/?LinkId=194337). The package can have multiple parts with relationships between them. The relationship between parts controls the category of the document. A document can be defined as a word-processing document if its package-relationship item contains a relationship to a main document part. If its package-relationship item contains a relationship to a presentation part it can be defined as a presentation document. If its package-relationship item contains a relationship to a workbook part, it is defined as a spreadsheet document. In this how-to topic, you will use a word-processing document package. 50 | 51 | 52 | 53 | 54 | 55 | 56 | ## Getting a WordprocessingDocument Object 57 | In the sample code, you start by opening the word processing file by instantiating the **WordprocessingDocument** class as shown in the following **using** statement. In the same statement, you open the word processing file_document_ by using the **Open** method, with the Boolean parameter set to **true** to enable editing the document. 58 | 59 | 60 | ```C# 61 | using (WordprocessingDocument wordDoc = 62 | WordprocessingDocument.Open(document, true)) 63 | { 64 | // Insert other code here. 65 | } 66 | ``` 67 | 68 | 69 | 70 | 71 | ```VB.net 72 | Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True) 73 | ' Insert other code here. 74 | End Using 75 | ``` 76 | 77 | 78 | 79 | The **using** statement provides a recommended alternative to the typical .Open, .Save, .Close sequence. It ensures that the **Dispose** method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing brace is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this case_wordDoc_. Because the **WordprocessingDocument** class in the Open XML SDK automatically saves and closes the object as part of its **System.IDisposable** implementation, and because **Dispose** is automatically called when you exit the block, you do not have to explicitly call **Save** and **Close**-as long as you use **using**. 80 | 81 | 82 | 83 | 84 | 85 | 86 | ## How the Sample Code Works 87 | After you have opened the file for editing, you read it by using a **StreamReader** object. 88 | 89 | 90 | ```C# 91 | using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream())) 92 | { 93 | docText = sr.ReadToEnd(); 94 | } 95 | 96 | ``` 97 | 98 | 99 | 100 | 101 | ```VB.net 102 | Dim sr As StreamReader = New StreamReader(wordDoc.MainDocumentPart.GetStream) 103 | 104 | using (sr) 105 | docText = sr.ReadToEnd 106 | End using 107 | 108 | ``` 109 | 110 | 111 | 112 | The code then creates a regular expression object that contains the string "Hello world!" It then replaces the text value with the text "Hi Everyone!." For more information about regular expressions, see [Regular Expressions](http://msdn.microsoft.com/en-us/library/hs600312.aspx) 113 | 114 | 115 | ```C# 116 | Regex regexText = new Regex("Hello world!"); 117 | docText = regexText.Replace(docText, "Hi Everyone!"); 118 | 119 | ``` 120 | 121 | 122 | 123 | 124 | ```VB.net 125 | Dim regexText As Regex = New Regex("Hello world!") 126 | docText = regexText.Replace(docText, "Hi Everyone!") 127 | 128 | ``` 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | ## Sample Code 138 | The following code example shows how to use a regular expression to search and replace the text value, "Hello world!" stored in a word processing file named "MyPkg8.docx," with the value "Hi Everyone!". To call the method **SearchAndReplace**, you can use the following example. 139 | 140 | 141 | ```C# 142 | SearchAndReplace(@"C:\Users\Public\Documents\MyPkg8.docx"); 143 | 144 | ``` 145 | 146 | 147 | 148 | 149 | ```VB.net 150 | SearchAndReplace("C:\Users\Public\Documents\MyPkg8.docx") 151 | 152 | ``` 153 | 154 | 155 | 156 | After running the program, you can inspect the file to see the change in the text, "Hello world!" 157 | 158 | The following is the complete sample code in both C# and Visual Basic. 159 | 160 | 161 | ```C# 162 | // To search and replace content in a document part. 163 | public static void SearchAndReplace(string document) 164 | { 165 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) 166 | { 167 | string docText = null; 168 | using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream())) 169 | { 170 | docText = sr.ReadToEnd(); 171 | } 172 | 173 | Regex regexText = new Regex("Hello world!"); 174 | docText = regexText.Replace(docText, "Hi Everyone!"); 175 | 176 | using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create))) 177 | { 178 | sw.Write(docText); 179 | } 180 | } 181 | } 182 | ``` 183 | 184 | 185 | 186 | 187 | ```VB.net 188 | ' To search and replace content in a document part. 189 | Public Sub SearchAndReplace(ByVal document As String) 190 | Dim wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True) 191 | using (wordDoc) 192 | Dim docText As String = Nothing 193 | Dim sr As StreamReader = New StreamReader(wordDoc.MainDocumentPart.GetStream) 194 | 195 | using (sr) 196 | docText = sr.ReadToEnd 197 | End using 198 | 199 | Dim regexText As Regex = New Regex("Hello world!") 200 | docText = regexText.Replace(docText, "Hi Everyone!") 201 | Dim sw As StreamWriter = New StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create)) 202 | 203 | using (sw) 204 | sw.Write(docText) 205 | End using 206 | End using 207 | End Sub 208 | ``` 209 | 210 | 211 | 212 | 213 | ## See also 214 | 215 | #### Other resources 216 | 217 | 218 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 219 | 220 | [Regular Expressions](http://msdn.microsoft.com/en-us/library/hs600312.aspx) 221 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/cfb75725-f3a7-43c0-85f4-7bb4c3f448ca.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/cfb75725-f3a7-43c0-85f4-7bb4c3f448ca.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/d4ef73a6-888a-4476-9e21-4df76782127f.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/d4ef73a6-888a-4476-9e21-4df76782127f.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/d57e9b7d-b271-4c8d-998f-b7ca3eb6c850.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/d57e9b7d-b271-4c8d-998f-b7ca3eb6c850.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/d6daf04e-3e45-4570-a184-8f0449c7ab91.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/d6daf04e-3e45-4570-a184-8f0449c7ab91.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/d7575014-8187-4e55-bafa-15bc317bf8c8.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/d7575014-8187-4e55-bafa-15bc317bf8c8.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/d7f0f1d3-bcf9-40b5-aaa4-4a08d862ac8e.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/d7f0f1d3-bcf9-40b5-aaa4-4a08d862ac8e.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/dabc2fad-9ef8-4aee-9d77-ebec147b0e24.md: -------------------------------------------------------------------------------- 1 | 2 | # [Class library reference] 3 | {insert summary} 4 | 5 | _**Applies to:** Open XML_ 6 | 7 | {insert introductory content} 8 | 9 | 10 | ## {insert section title text} 11 | {insert body text} 12 | 13 | 14 | ### {insert subsection title text} 15 | {insert body text} 16 | 17 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/dd28d239-42be-42a9-893e-b65338fe184e.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Parse and read a large spreadsheet document (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Getting a SpreadsheetDocument Object](#sectionSection1) 10 | 11 | [Approaches to Parsing Open XML Files](#sectionSection2) 12 | 13 | [Sample Code](#sectionSection3) 14 | 15 | 16 | 17 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to programmatically read a large Excel file. For more information about the basic structure of a **SpreadsheetML** document, see [Structure of a SpreadsheetML document (Open XML SDK)](3b35a153-c8ff-4dc7-96d5-02c515f31770.md). 18 | 19 | You must use the following **using** directives or **Imports** statements to compile the code in this topic. 20 | 21 | 22 | ```C# 23 | using System; 24 | using System.Linq; 25 | using DocumentFormat.OpenXml; 26 | using DocumentFormat.OpenXml.Packaging; 27 | using DocumentFormat.OpenXml.Spreadsheet; 28 | 29 | ``` 30 | 31 | 32 | 33 | 34 | ```VB.net 35 | Imports System 36 | Imports System.Linq 37 | Imports DocumentFormat.OpenXml 38 | Imports DocumentFormat.OpenXml.Packaging 39 | Imports DocumentFormat.OpenXml.Spreadsheet 40 | 41 | ``` 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ## Getting a SpreadsheetDocument Object 51 | In the Open XML SDK, the **SpreadsheetDocument** class represents an Excel document package. To open and work with an Excel document, you create an instance of the **SpreadsheetDocument** class from the document. After you create this instance, you can use it to obtain access to the main workbook part that contains the worksheets. The content in the document is represented in the package as XML using **SpreadsheetML** markup. 52 | 53 | To create the class instance, you call one of the overloads of the **Open()** method. The following code sample shows how to use the **Open(String, Boolean)** overload. The first parameter takes a string that represents the full path to the document to open. The second parameter takes a value of **true** or **false** and represents whether or not you want the file to be opened for editing. In this example, the parameter is **false** because the document is opened as read-only. 54 | 55 | 56 | ```C# 57 | // Open the document for editing. 58 | using (SpreadsheetDocument spreadsheetDocument = 59 | SpreadsheetDocument.Open(fileName, false)) 60 | { 61 | // Code removed here. 62 | } 63 | ``` 64 | 65 | 66 | 67 | 68 | ```VB.net 69 | ' Open the document for editing. 70 | Using spreadsheetDocument As SpreadsheetDocument = _ 71 | SpreadsheetDocument.Open(filename, False) 72 | ' Code removed here. 73 | End Using 74 | ``` 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | ## Approaches to Parsing Open XML Files 84 | The Open XML SDK provides two approaches to parsing Open XML files. You can use the SDK Document Object Model (DOM), or the Simple API for XML (SAX) reading and writing features. The SDK DOM is designed to make it easy to query and parse Open XML files by using strongly-typed classes. However, the DOM approach requires loading entire Open XML parts into memory, which can cause an Out of Memory exception when you are working with really large files. Using the SAX approach, you can employ an OpenXMLReader to read the XML in the file one element at a time, without having to load the entire file into memory. Consider using SAX when you need to handle very large files. 85 | 86 | The following code segment is used to read a very large Excel file using the DOM approach. 87 | 88 | 89 | ```C# 90 | WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; 91 | WorksheetPart worksheetPart = workbookPart.WorksheetParts.First(); 92 | SheetData sheetData = worksheetPart.Worksheet.Elements().First(); 93 | string text; 94 | foreach (Row r in sheetData.Elements()) 95 | { 96 | foreach (Cell c in r.Elements()) 97 | { 98 | text = c.CellValue.Text; 99 | Console.Write(text + " "); 100 | } 101 | } 102 | ``` 103 | 104 | 105 | 106 | 107 | ```VB.net 108 | Dim workbookPart As WorkbookPart = spreadsheetDocument.WorkbookPart 109 | Dim worksheetPart As WorksheetPart = workbookPart.WorksheetParts.First() 110 | Dim sheetData As SheetData = worksheetPart.Worksheet.Elements(Of SheetData)().First() 111 | Dim text As String 112 | For Each r As Row In sheetData.Elements(Of Row)() 113 | For Each c As Cell In r.Elements(Of Cell)() 114 | text = c.CellValue.Text 115 | Console.Write(text & " ") 116 | Next 117 | Next 118 | ``` 119 | 120 | 121 | 122 | The following code segment performs an identical task to the preceding sample (reading a very large Excel file), but uses the SAX approach. This is the recommended approach for reading very large files. 123 | 124 | 125 | ```C# 126 | WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; 127 | WorksheetPart worksheetPart = workbookPart.WorksheetParts.First(); 128 | 129 | OpenXmlReader reader = OpenXmlReader.Create(worksheetPart); 130 | string text; 131 | while (reader.Read()) 132 | { 133 | if (reader.ElementType == typeof(CellValue)) 134 | { 135 | text = reader.GetText(); 136 | Console.Write(text + " "); 137 | } 138 | } 139 | ``` 140 | 141 | 142 | 143 | 144 | ```VB.net 145 | Dim workbookPart As WorkbookPart = spreadsheetDocument.WorkbookPart 146 | Dim worksheetPart As WorksheetPart = workbookPart.WorksheetParts.First() 147 | 148 | Dim reader As OpenXmlReader = OpenXmlReader.Create(worksheetPart) 149 | Dim text As String 150 | While reader.Read() 151 | If reader.ElementType = GetType(CellValue) Then 152 | text = reader.GetText() 153 | Console.Write(text & " ") 154 | End If 155 | End While 156 | ``` 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | ## Sample Code 166 | You can imagine a scenario where you work for a financial company that handles very large Excel spreadsheets. Those spreadsheets are updated daily by analysts and can easily grow to sizes exceeding hundreds of megabytes. You need a solution to read and extract relevant data from every spreadsheet. The following code example contains two methods that correspond to the two approaches, DOM and SAX. The latter technique will avoid memory exceptions when using very large files. To try them, you can call them in your code one after the other or you can call each method separately by commenting the call to the one you would like to exclude. 167 | 168 | 169 | ```C# 170 | String fileName = @"C:\Users\Public\Documents\BigFile.xlsx"; 171 | // Comment one of the following lines to test the method separately. 172 | ReadExcelFileDOM(fileName); // DOM 173 | ReadExcelFileSAX(fileName); // SAX 174 | 175 | ``` 176 | 177 | 178 | 179 | 180 | ```VB.net 181 | Dim fileName As String = "C:\Users\Public\Documents\BigFile.xlsx" 182 | ' Comment one of the following lines to test each method separately. 183 | ReadExcelFileDOM(fileName) ' DOM 184 | ReadExcelFileSAX(fileName) ' SAX 185 | 186 | ``` 187 | 188 | 189 | 190 | The following is the complete code sample in both C# and Visual Basic. 191 | 192 | 193 | ```C# 194 | // The DOM approach. 195 | // Note that the code below works only for cells that contain numeric values. 196 | // 197 | static void ReadExcelFileDOM(string fileName) 198 | { 199 | using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(fileName, false)) 200 | { 201 | WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; 202 | WorksheetPart worksheetPart = workbookPart.WorksheetParts.First(); 203 | SheetData sheetData = worksheetPart.Worksheet.Elements().First(); 204 | string text; 205 | foreach (Row r in sheetData.Elements()) 206 | { 207 | foreach (Cell c in r.Elements()) 208 | { 209 | text = c.CellValue.Text; 210 | Console.Write(text + " "); 211 | } 212 | } 213 | Console.WriteLine(); 214 | Console.ReadKey(); 215 | } 216 | } 217 | 218 | // The SAX approach. 219 | static void ReadExcelFileSAX(string fileName) 220 | { 221 | using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(fileName, false)) 222 | { 223 | WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; 224 | WorksheetPart worksheetPart = workbookPart.WorksheetParts.First(); 225 | 226 | OpenXmlReader reader = OpenXmlReader.Create(worksheetPart); 227 | string text; 228 | while (reader.Read()) 229 | { 230 | if (reader.ElementType == typeof(CellValue)) 231 | { 232 | text = reader.GetText(); 233 | Console.Write(text + " "); 234 | } 235 | } 236 | Console.WriteLine(); 237 | Console.ReadKey(); 238 | } 239 | } 240 | 241 | 242 | ``` 243 | 244 | 245 | 246 | 247 | ```VB.net 248 | ' The DOM approach. 249 | ' Note that the this code works only for cells that contain numeric values. 250 | 251 | 252 | Private Sub ReadExcelFileDOM(ByVal fileName As String) 253 | Using spreadsheetDocument As SpreadsheetDocument = SpreadsheetDocument.Open(fileName, False) 254 | Dim workbookPart As WorkbookPart = spreadsheetDocument.WorkbookPart 255 | Dim worksheetPart As WorksheetPart = workbookPart.WorksheetParts.First() 256 | Dim sheetData As SheetData = worksheetPart.Worksheet.Elements(Of SheetData)().First() 257 | Dim text As String 258 | For Each r As Row In sheetData.Elements(Of Row)() 259 | For Each c As Cell In r.Elements(Of Cell)() 260 | text = c.CellValue.Text 261 | Console.Write(text & " ") 262 | Next 263 | Next 264 | Console.WriteLine() 265 | Console.ReadKey() 266 | End Using 267 | End Sub 268 | 269 | ' The SAX approach. 270 | Private Sub ReadExcelFileSAX(ByVal fileName As String) 271 | Using spreadsheetDocument As SpreadsheetDocument = SpreadsheetDocument.Open(fileName, False) 272 | Dim workbookPart As WorkbookPart = spreadsheetDocument.WorkbookPart 273 | Dim worksheetPart As WorksheetPart = workbookPart.WorksheetParts.First() 274 | 275 | Dim reader As OpenXmlReader = OpenXmlReader.Create(worksheetPart) 276 | Dim text As String 277 | While reader.Read() 278 | If reader.ElementType = GetType(CellValue) Then 279 | text = reader.GetText() 280 | Console.Write(text & " ") 281 | End If 282 | End While 283 | Console.WriteLine() 284 | Console.ReadKey() 285 | End Using 286 | End Sub 287 | ``` 288 | 289 | 290 | 291 | 292 | ## See also 293 | 294 | #### Concepts 295 | 296 | 297 | [Structure of a SpreadsheetML document (Open XML SDK)](3b35a153-c8ff-4dc7-96d5-02c515f31770.md) 298 | #### Other resources 299 | 300 | 301 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 302 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/dd42a9a3-5c16-4cab-ad6d-506cf822ec7a.md: -------------------------------------------------------------------------------- 1 | 2 | # Introduction to markup compatibility (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Introduction](#sectionSection0) 10 | 11 | [What is Markup Compatibility?](#sectionSection1) 12 | 13 | [Markup Compatibility in the Open XML File Formats Specification](#sectionSection2) 14 | 15 | [Open XML SDK 2.5 Support for Markup Compatibility](#sectionSection3) 16 | 17 | [Setting the stage when you Open](#sectionSection4) 18 | 19 | [What Happens During Preprocessing](#sectionSection5) 20 | 21 | [Understanding Process Mode](#sectionSection6) 22 | 23 | [Setting the Target File Format Version ](#sectionSection7) 24 | 25 | 26 | 27 | This topic introduces the markup compatibility features included in the Open XML SDK 2.5 for Office. 28 | 29 | 30 | 31 | 32 | 33 | 34 | ## Introduction 35 | Suppose you have a Microsoft Word 2013 document that employs a feature introduced in Microsoft Office 2013. When you open that document in Microsoft Word 2010, an earlier version, what should happen? Ideally, you want the document to remain interoperable with Word 2010, even though Word 2010 will not understand the new feature. 36 | 37 | Consider also what should happen if you open that document in a hypothetical later version of Office. Here too, you want the document to work as expected. That is, you want the later version of Office to understand and support a feature employed in a document produced by Word 2013. 38 | 39 | Open XML anticipates these scenarios. The Office Open XML File Formats specification describes facilities for achieving the above desired outcomes in [ECMA-376, Second Edition, Part 3 - Markup Compatibility and Extensibility](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-376,%20Second%20Edition,%20Part%203%20-%20Markup%20Compatibility%20and%20Extensibility.zip). 40 | 41 | The Open XML SDK 2.5 supports markup compatibility in a way that makes it easy for you to achieve the above desired outcomes for and Office 2013 without having to necessarily become an expert in the specification details. 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## What is Markup Compatibility? 49 | Open XML defines formats for word-processing, spreadsheet and presentation documents in the form of specific markup languages, namely WordprocessingML, SpreadsheetML, and PresentationML. With respect to the Open XML file formats, markup compatibility is the ability for a document expressed in one of the above markup languages to facilitate interoperability between applications, or versions of an application, with different feature sets. This is supported through the use of a defined set of XML elements and attributes in the Markup Compatibility namespace of the Open XML specification. Notice that while the markup is supported in the document format, markup producers and consumers, such as Microsoft Word, must support it as well. In other words, interoperability is a function of support both in the file format and by applications. 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | ## Markup Compatibility in the Open XML File Formats Specification 59 | Markup compatibility is discussed in [ECMA-376, Second Edition, Part 3 - Markup Compatibility and Extensibility](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-376,%20Second%20Edition,%20Part%203%20-%20Markup%20Compatibility%20and%20Extensibility.zip), which is recommended reading to understand markup compatibility. The specification defines XML attributes to express compatibility rules, and XML elements to specify alternate content. For example, the **Ignorable** attribute specifies namespaces that can be ignored when they are not understood by the consuming application. Alternate-Content elements specify markup alternatives that can be chosen by an application at run time. For example, Word 2013 can choose only the markup alternative that it recognizes. The complete list of compatibility-rule attributes and alternate-content elements and their details can be found in the specification. 60 | 61 | 62 | 63 | 64 | 65 | 66 | ## Open XML SDK 2.5 Support for Markup Compatibility 67 | The work that the Open XML SDK 2.5 does for markup compatibility is detailed and subtle. However, the goal can be summarized as: using settings that you assign when you open a document, preprocess the document to: 68 | 69 | 70 | 1. Filter or remove any elements from namespaces that will not be understood (for example, Office 2013 document opened in Office 2010 context) 71 | 72 | 73 | 74 | 2. Process any markup compatibility elements and attributes as specified in the Open XML specification. 75 | 76 | 77 | 78 | 79 | The preprocessing performed is in accordance with ECMA-376, Second Edition: Part 3.13. 80 | 81 | The Open XML SDK 2.5 support for markup compatibility comes primarily in the form of two classes and in the manner in which content is preprocessed in accordance with ECMA-376, Second Edition. The two classes are **OpenSettings** and **MarkupCompatibilityProcessSettings**. Use the former to provide settings that apply to SDK behavior overall. Use the latter to supply one part of those settings, specifically those that apply to markup compatibility. 82 | 83 | 84 | 85 | 86 | 87 | 88 | ## Setting the stage when you Open 89 | When you open a document using the Open XML SDK 2.5, you have the option of using an overload with a signature that accepts an instance of the **OpenSettings** class as a parameter. You use the open settings class to provide certain important settings that govern the behavior of the SDK. One set of settings in particular, stored in the **MarkupCompatibilityProcessSettings** property, determines how markup compatibility elements and attributes are processed. You set the property to an instance of the **MarkupCompatibilityProcessSettings** class prior to opening a document. 90 | 91 | The class has the following properties: 92 | 93 | 94 | - **ProcessMode** - Determines the parts that are preprocessed. 95 | 96 | 97 | - **TargetFileFormatVersions** - Specifies the context that applies to preprocessing. 98 | 99 | 100 | 101 | By default, documents are not preprocessed. If however you do specify open settings and provide markup compatibility process settings, then the document is preprocessed in accordance with those settings. 102 | 103 | The following code example demonstrates how to call the Open method with an instance of the open settings class as a parameter. Notice that the **ProcessMode** and **TargetFileFormatVersions** properties are initialized as part of the **MarkupCompatiblityProcessSettings** constructor. 104 | 105 | 106 | ```C# 107 | // Create instance of OpenSettings 108 | OpenSettings openSettings = new OpenSettings(); 109 | 110 | // Add the MarkupCompatibilityProcessSettings 111 | openSettings.MarkupCompatibilityProcessSettings = 112 | new MarkupCompatibilityProcessSettings( 113 | MarkupCompatibilityProcessMode.ProcessAllParts, 114 | FileFormatVersions.Office2007); 115 | 116 | // Open the document with OpenSettings 117 | using (WordprocessingDocument wordDocument = 118 | WordprocessingDocument.Open(filename, 119 | true, 120 | openSettings)) 121 | { 122 | // ... more code here 123 | } 124 | ``` 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | ## What Happens During Preprocessing 134 | During preprocessing, the Open XML SDK 2.5 removes elements and attributes in the markup compatibility namespace, removing the contents of unselected alternate-content elements, and interpreting compatibility-rule attributes as appropriate. This work is guided by the process mode and target file format versions properties. 135 | 136 | The **ProcessMode** property determines the parts to be preprocessed. The content in_those_ parts is filtered to contain only elements that are understood by the application version indicated in the **TargetFileFormatVersions** property. 137 | 138 | 139 | **Caution** Preprocessing affects what gets saved. When you save a file, the only markup that is saved is that which remains after preprocessing. 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | ## Understanding Process Mode 148 | The process mode specifies which document parts should be preprocessed. You set this property to a member of the **MarkupCompatibilityProcessMode** enumeration. The default value, **NoProcess**, indicates that no preprocessing is performed. Your application must be able to understand and handle any elements and attributes present in the document markup, including any of the elements and attributes in the Markup Compatibility namespace. 149 | 150 | You might want to work on specific document parts while leaving the rest untouched. For example, you might want to ensure minimal modification to the file. In that case, specify **ProcessLoadedPartsOnly** for the process mode. With this setting, preprocessing and the associated filtering is only applied to the loaded document parts, not the entire document. 151 | 152 | Finally, there is **ProcessAllParts**, which specifies what the name implies. When you choose this value, the entire document is preprocessed. 153 | 154 | 155 | 156 | 157 | 158 | 159 | ## Setting the Target File Format Version 160 | The target file format versions property lets you choose to process markup compatibility content in either Office 2010 or Office 2013 context. Set the **TargetFileFormatVersions** property to a member of the **FileFormatVersions** enumeration. 161 | 162 | The default value, **Office2010**, means the SDK will assume that namespaces defined in Office 2010 are understood, but not namespaces defined in Office 2013. Thus, during preprocessing, the SDK will ignore the namespaces defined in Office 2013 and choose the Office 2010 compatible alternate-content. 163 | 164 | When you set the target file format versions property to **Office2013**, the Open XML SDK 2.5 assumes that all of the namespaces defined in Office 2010 and Office 2013 are understood, does not ignore any content defined under Office 2013, and will choose the Office 2013 compatible alternate-content. 165 | 166 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/debad542-5915-45ad-a71c-eeb95b40ec1a.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/debad542-5915-45ad-a71c-eeb95b40ec1a.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/e3adae2b-c7e8-45f4-b1fc-93d937f4b3b1.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/e3adae2b-c7e8-45f4-b1fc-93d937f4b3b1.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/e4e5a2e5-a97e-47b9-a263-6723bd4230a1.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/e4e5a2e5-a97e-47b9-a263-6723bd4230a1.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/e5e9c6ba-b422-4639-bb8c-6da521307f13.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/e5e9c6ba-b422-4639-bb8c-6da521307f13.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/ec83a076-9d71-49d1-915f-e7090f74c13a.md: -------------------------------------------------------------------------------- 1 | 2 | # How to: Add a new document part to a package (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | **In this article** 8 | 9 | [Packages and Document Parts](#sectionSection1) 10 | 11 | [Getting a WordprocessingDocument Object](#sectionSection2) 12 | 13 | [Basic Structure of a WordProcessingML Document](#sectionSection3) 14 | 15 | [How the Sample Code Works](#sectionSection4) 16 | 17 | [Sample Code](#sectionSection5) 18 | 19 | 20 | 21 | This topic shows how to use the classes in the Open XML SDK 2.5 for Office to add a document part (file) to a word processing document programmatically. 22 | 23 | The following assembly directives are required to compile the code in this topic. 24 | 25 | 26 | ```C# 27 | using System.IO; 28 | using DocumentFormat.OpenXml.Packaging; 29 | ``` 30 | 31 | 32 | 33 | 34 | ```VB.net 35 | Imports System.IO 36 | Imports DocumentFormat.OpenXml.Packaging 37 | ``` 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ## Packages and Document Parts 47 | An Open XML document is stored as a package, whose format is defined by [ISO/IEC 29500-2](http://go.microsoft.com/fwlink/?LinkId=194337). The package can have multiple parts with relationships between them. The relationship between parts controls the category of the document. A document can be defined as a word-processing document if its package-relationship item contains a relationship to a main document part. If its package-relationship item contains a relationship to a presentation part it can be defined as a presentation document. If its package-relationship item contains a relationship to a workbook part, it is defined as a spreadsheet document. In this how-to topic, you will use a word-processing document package. 48 | 49 | 50 | 51 | 52 | 53 | 54 | ## Getting a WordprocessingDocument Object 55 | The code starts with opening a package file by passing a file name to one of the overloaded **Open()** methods of the **DocumentFormat.OpenXml.Packaging.WordprocessingDocument** that takes a string and a Boolean value that specifies whether the file should be opened for editing or for read-only access. In this case, the Boolean value is **true** specifying that the file should be opened in read/write mode. 56 | 57 | 58 | ```C# 59 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) 60 | { 61 | // Insert other code here. 62 | } 63 | ``` 64 | 65 | 66 | 67 | 68 | ```VB.net 69 | Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True) 70 | ' Insert other code here. 71 | End Using 72 | ``` 73 | 74 | 75 | 76 | The **using** statement provides a recommended alternative to the typical .Create, .Save, .Close sequence. It ensures that the **Dispose** method (internal method used by the Open XML SDK to clean up resources) is automatically called when the closing brace is reached. The block that follows the **using** statement establishes a scope for the object that is created or named in the **using** statement, in this case **wordDoc**. Because the **WordprocessingDocument** class in the Open XML SDK automatically saves and closes the object as part of its **System.IDisposable** implementation, and because the **Dispose** method is automatically called when you exit the block; you do not have to explicitly call **Save** and **Close**-as long as you use **using**. 77 | 78 | 79 | 80 | 81 | 82 | 83 | ## Basic Structure of a WordProcessingML Document 84 | The basic document structure of a **WordProcessingML** document consists of the **document** and **body** elements, followed by one or more block level elements such as **p**, which represents a paragraph. A paragraph contains one or more **r** elements. The **r** stands for run, which is a region of text with a common set of properties, such as formatting. A run contains one or more **t** elements. The **t** element contains a range of text. The **WordprocessingML** markup for the document that the sample code creates is shown in the following code example. 85 | 86 | 87 | ```XML 88 | 89 | 90 | 91 | 92 | Create text in body - CreateWordprocessingDocument 93 | 94 | 95 | 96 | 97 | ``` 98 | 99 | 100 | 101 | Using the Open XML SDK 2.5, you can create document structure and content using strongly-typed classes that correspond to **WordprocessingML** elements. You can find these classes in the **DocumentFormat.OpenXml.Wordprocessing** namespace. The following table lists the class names of the classes that correspond to the **document**, **body**, **p**, **r**, and **t** elements, 102 | 103 | 104 | **** 105 | 106 |

WordprocessingML Element

Open XML SDK 2.5 Class

Description

document

Document

The root element for the main document part.

body

Body

The container for the block level structures such as paragraphs, tables, annotations, and others specified in the ISO/IEC 29500 specification.

p

Paragraph

A paragraph.

r

Run

A run.

t

Text

A range of text.

107 |
108 | 109 | 110 | 111 | 112 | ## How the Sample Code Works 113 | After opening the document for editing, in the **using** statement, as a **WordprocessingDocument** object, the code creates a reference to the **MainDocumentPart** part and adds a new custom XML part. It then reads the contents of the external file that contains the custom XML and writes it to the **CustomXmlPart** part. 114 | 115 | 116 | **Note** To use the new document part in the document, add a link to the document part in the relationship part for the new part. 117 | 118 | 119 | 120 | ```C# 121 | MainDocumentPart mainPart = wordDoc.MainDocumentPart; 122 | CustomXmlPart myXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml); 123 | 124 | using (FileStream stream = new FileStream(fileName, FileMode.Open)) 125 | { 126 | myXmlPart.FeedData(stream); 127 | } 128 | ``` 129 | 130 | 131 | 132 | 133 | ```VB.net 134 | Dim mainPart As MainDocumentPart = wordDoc.MainDocumentPart 135 | 136 | Dim myXmlPart As CustomXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml) 137 | 138 | Using stream As New FileStream(fileName, FileMode.Open) 139 | myXmlPart.FeedData(stream) 140 | End Using 141 | ``` 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | ## Sample Code 151 | The following code adds a new document part that contains custom XML from an external file and then populates the part. To call the AddCustomXmlPart method in your program, you can use the following example that modifies the file "myPkg2.docx" by adding a new document part to it. 152 | 153 | 154 | ```C# 155 | string document = @"C:\Users\Public\Documents\myPkg2.docx"; 156 | string fileName = @"C:\Users\Public\Documents\myXML.xml"; 157 | AddNewPart(document, fileName); 158 | 159 | ``` 160 | 161 | 162 | 163 | 164 | ```VB.net 165 | Dim document As String = "C:\Users\Public\Documents\myPkg2.docx" 166 | Dim fileName As String = "C:\Users\Public\Documents\myXML.xml" 167 | AddNewPart(document, fileName) 168 | 169 | ``` 170 | 171 | 172 | 173 | 174 | **Note** Before you run the program, change the Word file extension from .docx to .zip, and view the content of the zip file. Then change the extension back to .docx and run the program. After running the program, change the file extension again to .zip and view its content. You will see an extra folder named "customXML." This folder contains the XML file that represents the added part 175 | 176 | 177 | Following is the complete code example in both C# and Visual Basic. 178 | 179 | 180 | ```C# 181 | // To add a new document part to a package. 182 | public static void AddNewPart(string document, string fileName) 183 | { 184 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) 185 | { 186 | MainDocumentPart mainPart = wordDoc.MainDocumentPart; 187 | 188 | CustomXmlPart myXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml); 189 | 190 | using (FileStream stream = new FileStream(fileName, FileMode.Open)) 191 | { 192 | myXmlPart.FeedData(stream); 193 | } 194 | } 195 | } 196 | 197 | ``` 198 | 199 | 200 | 201 | 202 | ```VB.net 203 | ' To add a new document part to a package. 204 | Public Sub AddNewPart(ByVal document As String, ByVal fileName As String) 205 | Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True) 206 | Dim mainPart As MainDocumentPart = wordDoc.MainDocumentPart 207 | 208 | Dim myXmlPart As CustomXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml) 209 | 210 | Using stream As New FileStream(fileName, FileMode.Open) 211 | myXmlPart.FeedData(stream) 212 | End Using 213 | End Using 214 | End Sub 215 | ``` 216 | 217 | 218 | 219 | 220 | ## See also 221 | 222 | #### Other resources 223 | 224 | 225 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 226 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/edbe267a-ced9-43fd-a702-fd0165cb3438.md: -------------------------------------------------------------------------------- 1 | 2 | # Packages and general (Open XML SDK) 3 | **Last modified:** July 27, 2012 4 | 5 | _**Applies to:** Office 2013 | Open XML_ 6 | 7 | This section provides how-to topics for working with documents and packages using the Open XML SDK 2.5. 8 | 9 | 10 | ## In this section 11 | [How to: Add a new document part that receives a relationship ID to a package (Open XML SDK)](c9b2ce55-548c-4443-8d2e-08fe1f06b7d7.md) 12 | 13 | [How to: Add a new document part to a package (Open XML SDK)](ec83a076-9d71-49d1-915f-e7090f74c13a.md) 14 | 15 | [How to: Copy the contents of an Open XML package part to a document part in a different package (Open XML SDK)](7dbfd93c-a9e3-4465-9b57-4a043b07b807.md) 16 | 17 | [How to: Create a package (Open XML SDK)](fe261589-7b04-47df-8ee9-26b444e587b0.md) 18 | 19 | [How to: Get the contents of a document part from a package (Open XML SDK)](b0d3d890-431a-4838-89dc-1f0dccd5dcd0.md) 20 | 21 | [How to: Remove a document part from a package (Open XML SDK)](b3890e64-51d1-4643-8d07-2c9d8e060000.md) 22 | 23 | [How to: Replace the theme part in a word processing document (Open XML SDK)](cfb75725-f3a7-43c0-85f4-7bb4c3f448ca.md) 24 | 25 | [How to: Search and replace text in a document part (Open XML SDK)](cbb4547e-45fa-48ee-872e-8727beec6dfa.md) 26 | 27 | 28 | ## Related sections 29 | [How do I... (Open XML SDK)](b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md) 30 | 31 | [Getting started with the Open XML SDK 2.5 for Office](7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md) 32 | 33 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/ee6c905b-26c5-4aed-a414-9aa826364a23.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/ee6c905b-26c5-4aed-a414-9aa826364a23.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/ef817bef-27cd-4c2a-acf3-b7bba17e6e1e.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/ef817bef-27cd-4c2a-acf3-b7bba17e6e1e.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/f6a9ae68-7989-4208-97f5-3c945137a0ab.md: -------------------------------------------------------------------------------- 1 | 2 | # Welcome to the Open XML SDK 2.5 for Office 3 | This content set provides documentation and guidance for the strongly-typed classes in the Open XML SDK 2.5 for Office. 4 | 5 | **Last modified:** April 09, 2013 6 | 7 | _**Applies to:** Office 2013 | Open XML_ 8 | 9 | The SDK is built on the **System.IO.Packaging** API and provides strongly-typed classes to manipulate documents that adhere to the Office Open XML File Formats Specification. The Office Open XML File Formats specification is an open, international, [ECMA-376, Second Edition](http://www.ecma-international.org/publications/standards/Ecma-376.htm) and [ISO/IEC 29500](http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=51463) standard. The Open XML file formats are useful for developers because they are an open standard and are based on well-known technologies: ZIP and XML. 10 | 11 | The Open XML SDK 2.5 simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. The Open XML SDK 2.5 encapsulates many common tasks that developers perform on Open XML packages, so that you can perform complex operations with just a few lines of code. 12 | 13 | Portions of ISO/IEC 29500:20081 are referenced in the SDK. 14 | 15 | 16 | ## In This Section 17 | [Getting started with the Open XML SDK 2.5 for Office](7b729dda-bbb6-437e-93d6-7bfe7b8183fa.md) 18 | 19 | [Understanding the Open XML file formats](ada81388-9ed2-43f4-ab2c-2bb82f711e90.md) 20 | 21 | [How do I... (Open XML SDK)](b5cc0e8d-da79-482a-81fa-f18c18d29f6c.md) 22 | 23 | [Open XML SDK 2.5 class library reference](http://msdn.microsoft.com/library/36c8a76e-ce1b-5959-7e85-5d77db7f46d6(Office.15).aspx) 24 | 25 | 26 | ## Additional Resources 27 | 28 | - [Open XML SDK 2.5 for Microsoft Office](http://www.microsoft.com/en-us/download/details.aspx?id=30425) 29 | 30 | 31 | - [Microsoft Office Developer Center](http://msdn.microsoft.com/en-us/office/default.aspx) 32 | 33 | 34 | - [XML in Office](http://msdn.microsoft.com/en-us/office/aa905546.aspx) 35 | 36 | 37 | - [Open XML SDK copyright notice](http://msdn.microsoft.com/library/6165f4ad-2e4d-4852-921a-087782af364d(Office.15).aspx) 38 | 39 | 40 | - [Accessibility Features in the Microsoft Office System](http://go.microsoft.com/fwlink/?LinkID=35092&clcid=0x409) 41 | 42 | 43 | - [Document Conventions in Office Developer Documentation](http://msdn.microsoft.com/en-us/office/aa905365.aspx) 44 | 45 | 46 | 47 | 1© ISO/IEC2900:2008. This material is reproduced from ISO/IEC 29500:2008 with permission of the American National Standards Institute (ANSI) on behalf of ISO. 48 | 49 | -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/fb4b293c-9a23-44b7-8af6-afe5fac6611a.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/fb4b293c-9a23-44b7-8af6-afe5fac6611a.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/fdb29547-c295-4e7d-9fc5-d86d8d8c2967.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/fdb29547-c295-4e7d-9fc5-d86d8d8c2967.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/fe780fcd-ed8f-4ee1-938e-cf3bb358ccae.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/fe780fcd-ed8f-4ee1-938e-cf3bb358ccae.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/ffdf5bd3-53f5-4f48-8946-11a0287fb107.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/ffdf5bd3-53f5-4f48-8946-11a0287fb107.md -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/OpenXMLCon_HowToConvertDOCMtoDOCX_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/OpenXMLCon_HowToConvertDOCMtoDOCX_Fig1.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/OpenXmlCon_CreateCharacterStyle_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/OpenXmlCon_CreateCharacterStyle_Fig1.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/OpenXmlCon_HowToReplaceStyles_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/OpenXmlCon_HowToReplaceStyles_Fig1.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/OpenXmlCon_HowToSetCustomPropertyFig2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/OpenXmlCon_HowToSetCustomPropertyFig2.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/OpenXmlCon_HowToSetCustomProperty_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/OpenXmlCon_HowToSetCustomProperty_Fig1.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/a-theme01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/a-theme01.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/odc_oxml_ppt_documentstructure_fig01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/odc_oxml_ppt_documentstructure_fig01.jpg -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/odc_oxml_ppt_documentstructure_fig02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/odc_oxml_ppt_documentstructure_fig02.jpg -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/odc_oxml_wd_documentstructure_fig01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/odc_oxml_wd_documentstructure_fig01.jpg -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/odc_oxml_xl_documentstructure_fig01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/odc_oxml_xl_documentstructure_fig01.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/odc_oxml_xl_documentstructure_fig02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/odc_oxml_xl_documentstructure_fig02.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/w-comment01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/w-comment01.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/w-delparagraphs01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/w-delparagraphs01.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/w-delparagraphs02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/w-delparagraphs02.gif -------------------------------------------------------------------------------- /en-us/OpenXMLCon/articles/images/w-headerref01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/en-us/OpenXMLCon/articles/images/w-headerref01.gif -------------------------------------------------------------------------------- /rest-api/android/images/O365APIs_RunningApp1-50Percent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/rest-api/android/images/O365APIs_RunningApp1-50Percent.png -------------------------------------------------------------------------------- /rest-api/android/images/O365APIs_RunningApp2-50Percent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/rest-api/android/images/O365APIs_RunningApp2-50Percent.png -------------------------------------------------------------------------------- /rest-api/android/images/O365APIs_RunningApp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/rest-api/android/images/O365APIs_RunningApp3.png -------------------------------------------------------------------------------- /rest-api/android/images/O365APIs_RunningApp4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/rest-api/android/images/O365APIs_RunningApp4.png -------------------------------------------------------------------------------- /rest-api/android/images/O365APIs_RunningApp5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-content/fa0cbad0e7849beabb5a089234a61ac8f69db0f1/rest-api/android/images/O365APIs_RunningApp5.png -------------------------------------------------------------------------------- /rest-api/ios/setup-ios.md: -------------------------------------------------------------------------------- 1 | # Get setup 2 | 3 | If you haven't already, let's get setup: 4 | 5 | 1. Get [Xcode](https://developer.apple.com/xcode/downloads/) 6 | 2. Get an [Office 365 Developer Account](#https://portal.office.com/Signup/Signup.aspx?OfferId=467eab54-127b-42d3-b046-3844b860bebf&dl=O365_BUSINESS_PREMIUM&alo=1&lc=1033&ali=1#0), to access the Office 365 APIs. 7 | 3. Install and setup [CocoaPods](http://cocoapods.org/) dependency manager by running the following commands: 8 | 9 | ``` 10 | sudo gem install cocoapods 11 | pod setup 12 | ``` 13 | 14 | If the install and setup were successful, you should see the message **Setup completed** in Terminal. 15 | 16 | **Note**: These commands only needs to be run once. 17 | 18 | 19 | 4. If you'd like, download the [Office 365 SDK for iOS](https://github.com/OfficeDev/Office-365-SDK-for-iOS), otherwise, we'll take care of this in a bit. --------------------------------------------------------------------------------