├── .gitattributes ├── docs ├── includes │ ├── iso-iec-29500-version.md │ ├── iso-iec-29500-link.md │ ├── iso-iec-29500-2-link.md │ ├── addinsnote.md │ ├── presentation │ │ └── using-statement.md │ ├── word │ │ ├── packages-and-document-parts.md │ │ ├── using-statement.md │ │ └── structure.md │ └── spreadsheet │ │ └── open-spreadsheet.md ├── breadcrumb │ └── toc.yml ├── media │ ├── Octocat.png │ ├── a-theme01.gif │ ├── w-comment01.gif │ ├── w-headerref01.gif │ ├── w-delparagraphs01.gif │ ├── w-delparagraphs02.gif │ ├── feature-debug-view.png │ ├── custom-property-menu.png │ ├── OpenXmlCon_HowToReplaceStyles_Fig1.gif │ ├── OpenXmlCon_CreateCharacterStyle_Fig1.gif │ ├── OpenXmlCon_HowToSetCustomPropertyFig2.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 │ ├── OpenXMLCon_HowToConvertDOCMtoDOCX_Fig1.gif │ └── OpenXmlCon_HowToSetCustomProperty_Fig1.gif ├── open-xml-sdk-design-considerations.md ├── docfx.json ├── general │ ├── overview.md │ └── diagnosticids.md ├── spreadsheet │ ├── how-to-insert-a-new-worksheet-into-a-spreadsheet.md │ └── how-to-get-worksheet-information-from-a-package.md ├── getting-started.md └── word │ └── how-to-validate-a-word-processing-document.md ├── samples ├── word │ ├── validate │ │ ├── cs │ │ │ └── validate_cs.csproj │ │ └── vb │ │ │ └── validate_vb.vbproj │ ├── add_tables │ │ ├── cs │ │ │ └── add_tables_cs.csproj │ │ └── vb │ │ │ └── add_tables_vb.vbproj │ ├── extract_styles │ │ ├── cs │ │ │ └── extract_styles_cs.csproj │ │ └── vb │ │ │ └── extract_styles_vb.vbproj │ ├── insert_a_table │ │ ├── cs │ │ │ └── insert_a_table_cs.csproj │ │ └── vb │ │ │ └── insert_a_table_vb.vbproj │ ├── create_a_package │ │ ├── cs │ │ │ ├── create_a_package_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── create_a_package_vb.vbproj │ │ │ └── Program.vb │ ├── insert_a_comment │ │ ├── cs │ │ │ └── insert_a_comment_cs.csproj │ │ └── vb │ │ │ └── insert_a_comment_vb.vbproj │ ├── insert_a_picture │ │ ├── cs │ │ │ └── insert_a_picture_cs.csproj │ │ └── vb │ │ │ └── insert_a_picture_vb.vbproj │ ├── open_from_a_stream │ │ ├── cs │ │ │ ├── open_from_a_stream_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── open_from_a_stream_vb.vbproj │ │ │ └── Program.vb │ ├── remove_hidden_text │ │ ├── cs │ │ │ ├── remove_hidden_text_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── remove_hidden_text_vb.vbproj │ │ │ └── Program.vb │ ├── replace_the_header │ │ ├── cs │ │ │ └── replace_the_header_cs.csproj │ │ └── vb │ │ │ ├── replace_the_header_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_comments │ │ ├── cs │ │ │ ├── retrieve_comments_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── retrieve_comments_vb.vbproj │ │ │ └── Program.vb │ ├── working_with_runs │ │ ├── cs │ │ │ ├── working_with_runs_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── working_with_runs_vb.vbproj │ │ │ └── Program.vb │ ├── change_text_a_table │ │ ├── cs │ │ │ ├── change_text_a_table_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── change_text_a_table_vb.vbproj │ │ │ └── Program.vb │ ├── open_and_add_text_to │ │ ├── cs │ │ │ ├── open_and_add_text_to_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── open_and_add_text_to_vb.vbproj │ │ │ └── Program.vb │ ├── insert_table_in_doc │ │ ├── cs │ │ │ ├── insert_table_in_doc_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ └── insert_table_in_doc_vb.vbproj │ ├── replace_text_with_sax │ │ ├── cs │ │ │ └── replace_text_with_sax_cs.csproj │ │ └── vb │ │ │ └── replace_text_with_sax_vb.vbproj │ ├── replace_the_theme_part │ │ ├── cs │ │ │ ├── replace_the_theme_part_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── replace_the_theme_part_vb.vbproj │ │ │ └── Program.vb │ ├── set_a_custom_property │ │ ├── cs │ │ │ └── set_a_custom_property_cs.csproj │ │ └── vb │ │ │ └── set_a_custom_property_vb.vbproj │ ├── working_with_paragraphs │ │ ├── cs │ │ │ ├── working_with_paragraphs_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── working_with_paragraphs_vb.vbproj │ │ │ └── Program.vb │ ├── working_with_tables │ │ ├── cs │ │ │ └── working_with_tables_cs.csproj │ │ └── vb │ │ │ └── working_with_tables_vb.vbproj │ ├── open_for_read_only_access │ │ ├── cs │ │ │ └── open_for_read_only_access_cs.csproj │ │ └── vb │ │ │ └── open_for_read_only_access_vb.vbproj │ ├── replace_the_styles_parts │ │ ├── cs │ │ │ └── replace_the_styles_parts_cs.csproj │ │ └── vb │ │ │ └── replace_the_styles_parts_vb.vbproj │ ├── add_a_new_part_to_a_package │ │ ├── cs │ │ │ ├── add_a_new_part_to_a_package_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── add_a_new_part_to_a_package_vb.vbproj │ │ │ └── Program.vb │ ├── apply_a_style_to_a_paragraph │ │ ├── cs │ │ │ └── apply_a_style_to_a_paragraph_cs.csproj │ │ └── vb │ │ │ └── apply_a_style_to_a_paragraph_vb.vbproj │ ├── change_the_print_orientation │ │ ├── cs │ │ │ └── change_the_print_orientation_cs.csproj │ │ └── vb │ │ │ └── change_the_print_orientation_vb.vbproj │ ├── remove_a_part_from_a_package │ │ ├── cs │ │ │ ├── remove_a_part_from_a_package_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── remove_a_part_from_a_package_vb.vbproj │ │ │ └── Program.vb │ ├── set_the_font_for_a_text_run │ │ ├── cs │ │ │ ├── set_the_font_for_a_text_run_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── set_the_font_for_a_text_run_vb.vbproj │ │ │ └── Program.vb │ ├── accept_all_revisions │ │ ├── cs │ │ │ ├── accept_all_revisions_cs.csproj │ │ │ └── accept_all_revisions_cs.sln │ │ └── vb │ │ │ ├── accept_all_revisions_vb.vbproj │ │ │ └── accept_all_revisions_vb.sln │ ├── remove_the_headers_and_footers │ │ ├── cs │ │ │ └── remove_the_headers_and_footers_cs.csproj │ │ └── vb │ │ │ └── remove_the_headers_and_footers_vb.vbproj │ ├── search_and_replace_text_a_part │ │ ├── cs │ │ │ ├── search_and_replace_text_a_part_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── search_and_replace_text_a_part_vb.vbproj │ │ │ └── Program.vb │ ├── create_and_add_a_character_style │ │ ├── cs │ │ │ └── create_and_add_a_character_style_cs.csproj │ │ └── vb │ │ │ └── create_and_add_a_character_style_vb.vbproj │ ├── create_and_add_a_paragraph_style │ │ ├── cs │ │ │ └── create_and_add_a_paragraph_style_cs.csproj │ │ └── vb │ │ │ └── create_and_add_a_paragraph_style_vb.vbproj │ ├── create_by_providing_a_file_name │ │ ├── cs │ │ │ ├── create_by_providing_a_file_name_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── create_by_providing_a_file_name_vb.vbproj │ │ │ └── Program.vb │ ├── structure_of_a_wordprocessingml │ │ ├── cs │ │ │ ├── structure_of_a_wordprocessingml_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── structure_of_a_wordprocessingml_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_application_property_values │ │ ├── cs │ │ │ ├── retrieve_application_property_values_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── retrieve_application_property_values_vb.vbproj │ │ │ └── Program.vb │ ├── delete_comments_by_all_or_a_specific_author │ │ ├── cs │ │ │ └── delete_comments_by_all_or_a_specific_author_cs.csproj │ │ └── vb │ │ │ └── delete_comments_by_all_or_a_specific_author_vb.vbproj │ ├── get_the_contents_of_a_part_from_a_package │ │ ├── cs │ │ │ ├── get_the_contents_of_a_part_from_a_package_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── get_the_contents_of_a_part_from_a_package_vb.vbproj │ │ │ └── Program.vb │ ├── convert_from_the_docm_to_the_docx_file_format │ │ ├── cs │ │ │ ├── convert_from_the_docm_to_the_docx_file_format_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── convert_from_the_docm_to_the_docx_file_format_vb.vbproj │ │ │ └── Program.vb │ ├── add_a_new_part_that_receives_a_relationship_id_to_a_package │ │ ├── cs │ │ │ ├── add_a_new_part_that_receives_a_relationship_id_to_a_package_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ └── add_a_new_part_that_receives_a_relationship_id_to_a_package_vb.vbproj │ └── copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif │ │ ├── cs │ │ ├── copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif_cs.csproj │ │ └── Program.cs │ │ └── vb │ │ ├── copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif_vb.vbproj │ │ └── Program.vb ├── presentation │ ├── add_video │ │ ├── cs │ │ │ └── add_video_cs.csproj │ │ └── vb │ │ │ └── add_video_vb.vbproj │ ├── add_comment │ │ ├── cs │ │ │ └── add_comment_cs.csproj │ │ └── vb │ │ │ └── add_comment_vb.vbproj │ ├── add_transition │ │ ├── cs │ │ │ └── add_transition_cs.csproj │ │ └── vb │ │ │ └── add_transition_vb.vbproj │ ├── apply_a_theme_to │ │ ├── cs │ │ │ └── apply_a_theme_to_cs.csproj │ │ └── vb │ │ │ └── apply_a_theme_to_vb.vbproj │ ├── delete_a_slide_from │ │ ├── cs │ │ │ └── delete_a_slide_from_cs.csproj │ │ └── vb │ │ │ └── delete_a_slide_from_vb.vbproj │ ├── insert_a_new_slideto │ │ ├── cs │ │ │ └── insert_a_new_slideto_cs.csproj │ │ └── vb │ │ │ └── insert_a_new_slideto_vb.vbproj │ ├── get_all_the_text_a_slide │ │ ├── cs │ │ │ └── get_all_the_text_a_slide_cs.csproj │ │ └── vb │ │ │ └── get_all_the_text_a_slide_vb.vbproj │ ├── open_for_read_only_access │ │ ├── cs │ │ │ ├── open_for_read_only_access_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ └── open_for_read_only_access_vb.vbproj │ ├── working_with_presentations │ │ ├── cs │ │ │ ├── working_with_presentations_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── working_with_presentations_vb.vbproj │ │ │ └── Program.vb │ ├── working_with_slide_layouts │ │ ├── cs │ │ │ ├── working_with_slide_layouts_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── working_with_slide_layouts_vb.vbproj │ │ │ └── Program.vb │ ├── get_all_the_text_all_slides │ │ ├── cs │ │ │ └── get_all_the_text_all_slides_cs.csproj │ │ └── vb │ │ │ └── get_all_the_text_all_slides_vb.vbproj │ ├── retrieve_the_number_of_slides │ │ ├── cs │ │ │ ├── retrieve_the_number_of_slides_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── retrieve_the_number_of_slides_vb.vbproj │ │ │ └── Program.vb │ ├── create_by_providing_a_file_name │ │ ├── cs │ │ │ └── create_by_providing_a_file_name_cs.csproj │ │ └── vb │ │ │ └── create_by_providing_a_file_name_vb.vbproj │ ├── get_all_the_external_hyperlinks │ │ ├── cs │ │ │ ├── get_all_the_external_hyperlinks_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── get_all_the_external_hyperlinks_vb.vbproj │ │ │ └── Program.vb │ ├── move_a_slide_to_a_new_position │ │ ├── cs │ │ │ └── move_a_slide_to_a_new_position_cs.csproj │ │ └── vb │ │ │ └── move_a_slide_to_a_new_position_vb.vbproj │ ├── change_the_fill_color_of_a_shape │ │ ├── cs │ │ │ └── change_the_fill_color_of_a_shape_cs.csproj │ │ └── vb │ │ │ └── change_the_fill_color_of_a_shape_vb.vbproj │ ├── get_the_titles_of_all_the_slides │ │ ├── cs │ │ │ └── get_the_titles_of_all_the_slides_cs.csproj │ │ └── vb │ │ │ └── get_the_titles_of_all_the_slides_vb.vbproj │ ├── working_with_handout_master_slides │ │ ├── cs │ │ │ └── working_with_handout_master_slides_cs.csproj │ │ └── vb │ │ │ └── working_with_handout_master_slides_vb.vbproj │ ├── working_with_presentation_slides │ │ ├── cs │ │ │ ├── working_with_presentation_slides_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── working_with_presentation_slides_vb.vbproj │ │ │ └── Program.vb │ ├── reply_to_comment │ │ ├── cs │ │ │ ├── Program.cs │ │ │ └── reply_to_comment_cs.csproj │ │ └── vb │ │ │ ├── Program.vb │ │ │ └── reply_to_comment_vb.vbproj │ ├── add_audio │ │ ├── cs │ │ │ └── add_audio_cs.csproj │ │ └── vb │ │ │ └── add_audio_vb.vbproj │ ├── move_a_paragraph_from_one_presentation_to_another │ │ ├── cs │ │ │ └── move_a_paragraph_from_one_presentation_to_another_cs.csproj │ │ └── vb │ │ │ └── move_a_paragraph_from_one_presentation_to_another_vb.vbproj │ ├── delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio │ │ ├── cs │ │ │ └── delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio_cs.csproj │ │ └── vb │ │ │ └── delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio_vb.vbproj │ └── working_with_notes_slides │ │ ├── cs │ │ └── working_with_notes_slides_cs.csproj │ │ └── vb │ │ └── working_with_notes_slides_vb.vbproj ├── spreadsheet │ ├── add_custom_ui │ │ ├── cs │ │ │ ├── add_custom_ui_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── add_custom_ui_vb.vbproj │ │ │ └── Program.vb │ ├── structure_ofml │ │ ├── cs │ │ │ ├── structure_ofml_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── structure_ofml_vb.vbproj │ │ │ └── Program.vb │ ├── insert_a_chartto │ │ ├── cs │ │ │ └── insert_a_chartto_cs.csproj │ │ └── vb │ │ │ └── insert_a_chartto_vb.vbproj │ ├── open_from_a_stream │ │ ├── cs │ │ │ ├── open_from_a_stream_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── open_from_a_stream_vb.vbproj │ │ │ └── Program.vb │ ├── working_with_sheets │ │ ├── cs │ │ │ ├── working_with_sheets_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ └── working_with_sheets_vb.vbproj │ ├── get_a_column_heading │ │ ├── cs │ │ │ └── get_a_column_heading_cs.csproj │ │ └── vb │ │ │ └── get_a_column_heading_vb.vbproj │ ├── insert_a_new_worksheet │ │ ├── cs │ │ │ ├── insert_a_new_worksheet_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── insert_a_new_worksheet_vb.vbproj │ │ │ └── Program.vb │ ├── insert_textto_a_cell │ │ ├── cs │ │ │ └── insert_textto_a_cell_cs.csproj │ │ └── vb │ │ │ └── insert_textto_a_cell_vb.vbproj │ ├── delete_text_from_a_cell │ │ ├── cs │ │ │ └── delete_text_from_a_cell_cs.csproj │ │ └── vb │ │ │ └── delete_text_from_a_cell_vb.vbproj │ ├── merge_two_adjacent_cells │ │ ├── cs │ │ │ └── merge_two_adjacent_cells_cs.csproj │ │ └── vb │ │ │ └── merge_two_adjacent_cells_vb.vbproj │ ├── open_for_read_only_access │ │ ├── cs │ │ │ ├── open_for_read_only_access_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── open_for_read_only_access_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_the_values_of_cells │ │ ├── cs │ │ │ └── retrieve_the_values_of_cells_cs.csproj │ │ └── vb │ │ │ └── retrieve_the_values_of_cells_vb.vbproj │ ├── create_by_providing_a_file_name │ │ ├── cs │ │ │ ├── create_by_providing_a_file_name_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── create_by_providing_a_file_name_vb.vbproj │ │ │ └── Program.vb │ ├── parse_and_read_a_large_spreadsheet │ │ ├── cs │ │ │ ├── parse_and_read_a_large_spreadsheet_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── parse_and_read_a_large_spreadsheet_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_a_list_of_the_worksheets │ │ ├── cs │ │ │ ├── retrieve_a_list_of_the_worksheets_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── retrieve_a_list_of_the_worksheets_vb.vbproj │ │ │ └── Program.vb │ ├── calculate_the_sum_of_a_range_of_cells │ │ ├── cs │ │ │ └── calculate_the_sum_of_a_range_of_cells_cs.csproj │ │ └── vb │ │ │ └── calculate_the_sum_of_a_range_of_cells_vb.vbproj │ ├── get_worksheetformation_from_a_package │ │ ├── cs │ │ │ ├── get_worksheetformation_from_a_package_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── get_worksheetformation_from_a_package_vb.vbproj │ │ │ └── Program.vb │ ├── working_with_the_shared_string_table │ │ ├── cs │ │ │ ├── working_with_the_shared_string_table_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── working_with_the_shared_string_table_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_a_dictionary_of_all_named_ranges │ │ ├── cs │ │ │ ├── retrieve_a_dictionary_of_all_named_ranges_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── retrieve_a_dictionary_of_all_named_ranges_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_a_list_of_the_hidden_worksheets │ │ ├── cs │ │ │ ├── retrieve_a_list_of_the_hidden_worksheets_cs.csproj │ │ │ └── Program.cs │ │ └── vb │ │ │ ├── retrieve_a_list_of_the_hidden_worksheets_vb.vbproj │ │ │ └── Program.vb │ ├── retrieve_a_list_of_the_hidden_rows_or_columns │ │ ├── cs │ │ │ └── retrieve_a_list_of_the_hidden_rows_or_columns_cs.csproj │ │ └── vb │ │ │ └── retrieve_a_list_of_the_hidden_rows_or_columns_vb.vbproj │ └── copy_worksheet_with_sax │ │ ├── vb │ │ └── copy_worksheet_with_sax_vb.vbproj │ │ └── cs │ │ └── copy_worksheet_with_sax_cs.csproj ├── migrate-sample.ps1 ├── .editorconfig ├── Directory.Build.targets ├── Directory.Build.props ├── tools │ └── migrator │ │ └── migrator.csproj ├── add-sample.ps1 └── README.md ├── .openpublishing.redirection.json ├── .github └── workflows │ ├── samples.yml │ └── auto-publish.yml ├── .openpublishing.build.ps1 ├── README.md ├── LICENSE-CODE ├── ThirdPartyNotices └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | *.cs -text 2 | *.vb -text -------------------------------------------------------------------------------- /docs/includes/iso-iec-29500-version.md: -------------------------------------------------------------------------------- 1 | ISO/IEC 29500: 2016 -------------------------------------------------------------------------------- /samples/word/validate/cs/validate_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/validate/vb/validate_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/add_tables/cs/add_tables_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/add_tables/vb/add_tables_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/add_video/cs/add_video_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/add_video/vb/add_video_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/includes/iso-iec-29500-link.md: -------------------------------------------------------------------------------- 1 | [ISO/IEC 29500](https://www.iso.org/standard/71691.html) -------------------------------------------------------------------------------- /samples/word/extract_styles/cs/extract_styles_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/extract_styles/vb/extract_styles_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_a_table/cs/insert_a_table_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_a_table/vb/insert_a_table_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/breadcrumb/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Office 2 | tocHref: /office/ 3 | topicHref: /office/index 4 | -------------------------------------------------------------------------------- /docs/includes/iso-iec-29500-2-link.md: -------------------------------------------------------------------------------- 1 | [ISO/IEC 29500-2](https://www.iso.org/standard/77818.html) -------------------------------------------------------------------------------- /samples/presentation/add_comment/cs/add_comment_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/presentation/add_comment/vb/add_comment_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/spreadsheet/add_custom_ui/cs/add_custom_ui_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/add_custom_ui/vb/add_custom_ui_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/structure_ofml/cs/structure_ofml_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/structure_ofml/vb/structure_ofml_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_a_package/cs/create_a_package_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_a_package/vb/create_a_package_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_a_comment/cs/insert_a_comment_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_a_comment/vb/insert_a_comment_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_a_picture/cs/insert_a_picture_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_a_picture/vb/insert_a_picture_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/open_from_a_stream/cs/open_from_a_stream_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/open_from_a_stream/vb/open_from_a_stream_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/remove_hidden_text/cs/remove_hidden_text_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/remove_hidden_text/vb/remove_hidden_text_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/replace_the_header/cs/replace_the_header_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/replace_the_header/vb/replace_the_header_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/retrieve_comments/cs/retrieve_comments_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/retrieve_comments/vb/retrieve_comments_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/working_with_runs/cs/working_with_runs_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/working_with_runs/vb/working_with_runs_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/Octocat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/Octocat.png -------------------------------------------------------------------------------- /samples/presentation/add_transition/cs/add_transition_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/presentation/add_transition/vb/add_transition_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/presentation/apply_a_theme_to/cs/apply_a_theme_to_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/apply_a_theme_to/vb/apply_a_theme_to_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/insert_a_chartto/cs/insert_a_chartto_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/insert_a_chartto/vb/insert_a_chartto_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/change_text_a_table/cs/change_text_a_table_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/change_text_a_table/vb/change_text_a_table_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/open_and_add_text_to/cs/open_and_add_text_to_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/open_and_add_text_to/vb/open_and_add_text_to_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/a-theme01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/a-theme01.gif -------------------------------------------------------------------------------- /samples/presentation/delete_a_slide_from/cs/delete_a_slide_from_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/delete_a_slide_from/vb/delete_a_slide_from_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/open_from_a_stream/cs/open_from_a_stream_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/open_from_a_stream/vb/open_from_a_stream_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/working_with_sheets/cs/working_with_sheets_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/working_with_sheets/vb/working_with_sheets_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/insert_table_in_doc/cs/insert_table_in_doc_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/word/insert_table_in_doc/vb/insert_table_in_doc_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/word/replace_text_with_sax/cs/replace_text_with_sax_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/word/replace_text_with_sax/vb/replace_text_with_sax_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/word/replace_the_theme_part/cs/replace_the_theme_part_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/replace_the_theme_part/vb/replace_the_theme_part_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/set_a_custom_property/cs/set_a_custom_property_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/set_a_custom_property/vb/set_a_custom_property_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/working_with_paragraphs/cs/working_with_paragraphs_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/working_with_paragraphs/vb/working_with_paragraphs_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/working_with_tables/cs/working_with_tables_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/word/working_with_tables/vb/working_with_tables_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/media/w-comment01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/w-comment01.gif -------------------------------------------------------------------------------- /samples/presentation/insert_a_new_slideto/cs/insert_a_new_slideto_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/insert_a_new_slideto/vb/insert_a_new_slideto_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/get_a_column_heading/cs/get_a_column_heading_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/get_a_column_heading/vb/get_a_column_heading_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/insert_a_new_worksheet/cs/insert_a_new_worksheet_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/insert_a_new_worksheet/vb/insert_a_new_worksheet_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/insert_textto_a_cell/cs/insert_textto_a_cell_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/insert_textto_a_cell/vb/insert_textto_a_cell_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/open_for_read_only_access/cs/open_for_read_only_access_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/open_for_read_only_access/vb/open_for_read_only_access_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/replace_the_styles_parts/cs/replace_the_styles_parts_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/replace_the_styles_parts/vb/replace_the_styles_parts_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/w-headerref01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/w-headerref01.gif -------------------------------------------------------------------------------- /samples/presentation/get_all_the_text_a_slide/cs/get_all_the_text_a_slide_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/get_all_the_text_a_slide/vb/get_all_the_text_a_slide_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/delete_text_from_a_cell/cs/delete_text_from_a_cell_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/delete_text_from_a_cell/vb/delete_text_from_a_cell_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/merge_two_adjacent_cells/cs/merge_two_adjacent_cells_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/merge_two_adjacent_cells/vb/merge_two_adjacent_cells_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/add_a_new_part_to_a_package/cs/add_a_new_part_to_a_package_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/add_a_new_part_to_a_package/vb/add_a_new_part_to_a_package_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/apply_a_style_to_a_paragraph/cs/apply_a_style_to_a_paragraph_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/apply_a_style_to_a_paragraph/vb/apply_a_style_to_a_paragraph_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/change_the_print_orientation/cs/change_the_print_orientation_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/change_the_print_orientation/vb/change_the_print_orientation_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/remove_a_part_from_a_package/cs/remove_a_part_from_a_package_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/remove_a_part_from_a_package/vb/remove_a_part_from_a_package_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/set_the_font_for_a_text_run/cs/set_the_font_for_a_text_run_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/set_the_font_for_a_text_run/vb/set_the_font_for_a_text_run_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/w-delparagraphs01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/w-delparagraphs01.gif -------------------------------------------------------------------------------- /docs/media/w-delparagraphs02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/w-delparagraphs02.gif -------------------------------------------------------------------------------- /samples/presentation/open_for_read_only_access/cs/open_for_read_only_access_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/open_for_read_only_access/vb/open_for_read_only_access_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_presentations/cs/working_with_presentations_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_presentations/vb/working_with_presentations_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_slide_layouts/cs/working_with_slide_layouts_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_slide_layouts/vb/working_with_slide_layouts_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/open_for_read_only_access/cs/open_for_read_only_access_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/open_for_read_only_access/vb/open_for_read_only_access_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/accept_all_revisions/cs/accept_all_revisions_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /samples/word/accept_all_revisions/vb/accept_all_revisions_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /samples/word/remove_the_headers_and_footers/cs/remove_the_headers_and_footers_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/remove_the_headers_and_footers/vb/remove_the_headers_and_footers_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/search_and_replace_text_a_part/cs/search_and_replace_text_a_part_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/search_and_replace_text_a_part/vb/search_and_replace_text_a_part_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/feature-debug-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/feature-debug-view.png -------------------------------------------------------------------------------- /samples/migrate-sample.ps1: -------------------------------------------------------------------------------- 1 | param($path) 2 | 3 | dotnet run --project "$PSScriptRoot\tools\migrator\migrator.csproj" -- $path -------------------------------------------------------------------------------- /samples/presentation/get_all_the_text_all_slides/cs/get_all_the_text_all_slides_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/get_all_the_text_all_slides/vb/get_all_the_text_all_slides_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/retrieve_the_number_of_slides/cs/retrieve_the_number_of_slides_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/retrieve_the_number_of_slides/vb/retrieve_the_number_of_slides_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_the_values_of_cells/cs/retrieve_the_values_of_cells_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_the_values_of_cells/vb/retrieve_the_values_of_cells_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_and_add_a_character_style/cs/create_and_add_a_character_style_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_and_add_a_character_style/vb/create_and_add_a_character_style_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_and_add_a_paragraph_style/cs/create_and_add_a_paragraph_style_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_and_add_a_paragraph_style/vb/create_and_add_a_paragraph_style_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_by_providing_a_file_name/cs/create_by_providing_a_file_name_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/create_by_providing_a_file_name/vb/create_by_providing_a_file_name_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/structure_of_a_wordprocessingml/cs/structure_of_a_wordprocessingml_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/structure_of_a_wordprocessingml/vb/structure_of_a_wordprocessingml_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/custom-property-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/custom-property-menu.png -------------------------------------------------------------------------------- /samples/presentation/create_by_providing_a_file_name/cs/create_by_providing_a_file_name_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/create_by_providing_a_file_name/vb/create_by_providing_a_file_name_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/get_all_the_external_hyperlinks/cs/get_all_the_external_hyperlinks_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/get_all_the_external_hyperlinks/vb/get_all_the_external_hyperlinks_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/move_a_slide_to_a_new_position/cs/move_a_slide_to_a_new_position_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/move_a_slide_to_a_new_position/vb/move_a_slide_to_a_new_position_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/create_by_providing_a_file_name/cs/create_by_providing_a_file_name_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/create_by_providing_a_file_name/vb/create_by_providing_a_file_name_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CS8321: Local function is declared but never used 4 | dotnet_diagnostic.CS8321.severity = none 5 | -------------------------------------------------------------------------------- /samples/presentation/change_the_fill_color_of_a_shape/cs/change_the_fill_color_of_a_shape_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/change_the_fill_color_of_a_shape/vb/change_the_fill_color_of_a_shape_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/get_the_titles_of_all_the_slides/cs/get_the_titles_of_all_the_slides_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/get_the_titles_of_all_the_slides/vb/get_the_titles_of_all_the_slides_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_handout_master_slides/cs/working_with_handout_master_slides_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_handout_master_slides/vb/working_with_handout_master_slides_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_presentation_slides/cs/working_with_presentation_slides_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/working_with_presentation_slides/vb/working_with_presentation_slides_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/parse_and_read_a_large_spreadsheet/cs/parse_and_read_a_large_spreadsheet_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/parse_and_read_a_large_spreadsheet/vb/parse_and_read_a_large_spreadsheet_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_worksheets/cs/retrieve_a_list_of_the_worksheets_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_worksheets/vb/retrieve_a_list_of_the_worksheets_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/retrieve_application_property_values/cs/retrieve_application_property_values_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/retrieve_application_property_values/vb/retrieve_application_property_values_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/calculate_the_sum_of_a_range_of_cells/cs/calculate_the_sum_of_a_range_of_cells_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/calculate_the_sum_of_a_range_of_cells/vb/calculate_the_sum_of_a_range_of_cells_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/get_worksheetformation_from_a_package/cs/get_worksheetformation_from_a_package_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/get_worksheetformation_from_a_package/vb/get_worksheetformation_from_a_package_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/working_with_the_shared_string_table/cs/working_with_the_shared_string_table_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/working_with_the_shared_string_table/vb/working_with_the_shared_string_table_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/delete_comments_by_all_or_a_specific_author/cs/delete_comments_by_all_or_a_specific_author_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/delete_comments_by_all_or_a_specific_author/vb/delete_comments_by_all_or_a_specific_author_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/get_the_contents_of_a_part_from_a_package/cs/get_the_contents_of_a_part_from_a_package_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/get_the_contents_of_a_part_from_a_package/vb/get_the_contents_of_a_part_from_a_package_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_dictionary_of_all_named_ranges/cs/retrieve_a_dictionary_of_all_named_ranges_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_dictionary_of_all_named_ranges/vb/retrieve_a_dictionary_of_all_named_ranges_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_hidden_worksheets/cs/retrieve_a_list_of_the_hidden_worksheets_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_hidden_worksheets/vb/retrieve_a_list_of_the_hidden_worksheets_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/convert_from_the_docm_to_the_docx_file_format/cs/convert_from_the_docm_to_the_docx_file_format_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/convert_from_the_docm_to_the_docx_file_format/vb/convert_from_the_docm_to_the_docx_file_format_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/OpenXmlCon_HowToReplaceStyles_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/OpenXmlCon_HowToReplaceStyles_Fig1.gif -------------------------------------------------------------------------------- /docs/media/OpenXmlCon_CreateCharacterStyle_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/OpenXmlCon_CreateCharacterStyle_Fig1.gif -------------------------------------------------------------------------------- /docs/media/OpenXmlCon_HowToSetCustomPropertyFig2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/OpenXmlCon_HowToSetCustomPropertyFig2.gif -------------------------------------------------------------------------------- /docs/media/odc_oxml_ppt_documentstructure_fig01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/odc_oxml_ppt_documentstructure_fig01.jpg -------------------------------------------------------------------------------- /docs/media/odc_oxml_ppt_documentstructure_fig02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/odc_oxml_ppt_documentstructure_fig02.jpg -------------------------------------------------------------------------------- /docs/media/odc_oxml_wd_documentstructure_fig01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/odc_oxml_wd_documentstructure_fig01.jpg -------------------------------------------------------------------------------- /docs/media/odc_oxml_xl_documentstructure_fig01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/odc_oxml_xl_documentstructure_fig01.gif -------------------------------------------------------------------------------- /docs/media/odc_oxml_xl_documentstructure_fig02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/odc_oxml_xl_documentstructure_fig02.gif -------------------------------------------------------------------------------- /samples/presentation/reply_to_comment/cs/Program.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/samples/presentation/reply_to_comment/cs/Program.cs -------------------------------------------------------------------------------- /samples/presentation/reply_to_comment/vb/Program.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/samples/presentation/reply_to_comment/vb/Program.vb -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_hidden_rows_or_columns/cs/retrieve_a_list_of_the_hidden_rows_or_columns_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_hidden_rows_or_columns/vb/retrieve_a_list_of_the_hidden_rows_or_columns_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/media/OpenXMLCon_HowToConvertDOCMtoDOCX_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/OpenXMLCon_HowToConvertDOCMtoDOCX_Fig1.gif -------------------------------------------------------------------------------- /docs/media/OpenXmlCon_HowToSetCustomProperty_Fig1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/docs/media/OpenXmlCon_HowToSetCustomProperty_Fig1.gif -------------------------------------------------------------------------------- /samples/presentation/add_audio/cs/add_audio_cs.csproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/samples/presentation/add_audio/cs/add_audio_cs.csproj -------------------------------------------------------------------------------- /samples/presentation/add_audio/vb/add_audio_vb.vbproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/samples/presentation/add_audio/vb/add_audio_vb.vbproj -------------------------------------------------------------------------------- /samples/presentation/move_a_paragraph_from_one_presentation_to_another/cs/move_a_paragraph_from_one_presentation_to_another_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/move_a_paragraph_from_one_presentation_to_another/vb/move_a_paragraph_from_one_presentation_to_another_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/word/add_a_new_part_that_receives_a_relationship_id_to_a_package/cs/add_a_new_part_that_receives_a_relationship_id_to_a_package_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/add_a_new_part_that_receives_a_relationship_id_to_a_package/vb/add_a_new_part_that_receives_a_relationship_id_to_a_package_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif/cs/copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/word/copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif/vb/copy_the_contents_of_an_open_xml_package_part_to_a_part_a_dif_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/reply_to_comment/cs/reply_to_comment_cs.csproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/samples/presentation/reply_to_comment/cs/reply_to_comment_cs.csproj -------------------------------------------------------------------------------- /samples/presentation/reply_to_comment/vb/reply_to_comment_vb.vbproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/open-xml-docs/HEAD/samples/presentation/reply_to_comment/vb/reply_to_comment_vb.vbproj -------------------------------------------------------------------------------- /samples/presentation/delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio/cs/delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio_cs.csproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/presentation/delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio/vb/delete_all_the_comments_by_an_author_from_all_the_slides_a_presentatio_vb.vbproj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.openpublishing.redirection.json: -------------------------------------------------------------------------------- 1 | { 2 | "redirections": [ 3 | { 4 | "source_path": "docs/index.md", 5 | "redirect_url": "/office/open-xml/open-xml-sdk/", 6 | "redirect_document_id": false 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /samples/presentation/working_with_notes_slides/cs/working_with_notes_slides_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/presentation/working_with_notes_slides/vb/working_with_notes_slides_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | disable 5 | enable 6 | Nullable 7 | Exe 8 | 9 | -------------------------------------------------------------------------------- /samples/spreadsheet/copy_worksheet_with_sax/vb/copy_worksheet_with_sax_vb.vbproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | copy_worksheet_with_sax_vb 6 | net8.0 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/spreadsheet/copy_worksheet_with_sax/cs/copy_worksheet_with_sax_cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/includes/addinsnote.md: -------------------------------------------------------------------------------- 1 | > [!NOTE] 2 | > Interested in developing solutions that extend the Office experience across multiple platforms? Check out the new [Office Add-ins model](/office/dev/add-ins/overview/office-add-ins). Office Add-ins have a small footprint compared to VSTO Add-ins and solutions, and you can build them by using almost any web programming technology, such as HTML5, JavaScript, CSS3, and XML. 3 | -------------------------------------------------------------------------------- /samples/tools/migrator/migrator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | Nullable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.github/workflows/samples.yml: -------------------------------------------------------------------------------- 1 | name: Samples compilation 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v3 18 | with: 19 | dotnet-version: 8.x 20 | - name: Build 21 | run: dotnet build samples/samples.sln /p:TreatWarningsAsErrors=true 22 | -------------------------------------------------------------------------------- /docs/includes/presentation/using-statement.md: -------------------------------------------------------------------------------- 1 | With v3.0.0+ the method 2 | has been removed in favor of relying on the [using statement](/dotnet/csharp/language-reference/statements/using). 3 | This ensures that the method is automatically called 4 | when the closing brace is reached. The block that follows the `using` statement establishes a scope for the 5 | object that is created or named in the `using` statement, in this case 6 | -------------------------------------------------------------------------------- /samples/add-sample.ps1: -------------------------------------------------------------------------------- 1 | param($area, $name) 2 | 3 | # Basic normalization 4 | $name = $name.Replace("-", "_") 5 | 6 | $dir = "$PSScriptRoot\$area\$name\cs" 7 | $proj = "$dir\${name}_cs.csproj" 8 | mkdir $dir -ErrorAction Ignore 9 | echo "" > $proj 10 | echo "" > "$dir\Program.cs" 11 | dotnet sln add $proj --solution-folder $area 12 | 13 | $dir = "$PSScriptRoot\$area\$name\vb" 14 | $proj = "$dir\${name}_vb.vbproj" 15 | mkdir $dir -ErrorAction Ignore 16 | echo "" > $proj 17 | echo "Module Program ` 18 | Sub Main(args As String())` 19 | End Sub` 20 | End Module" > "$dir\Program.vb" 21 | dotnet sln add $proj --solution-folder $area 22 | -------------------------------------------------------------------------------- /samples/word/remove_a_part_from_a_package/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml.Packaging; 2 | 3 | RemovePart(args[0]); 4 | 5 | // 6 | // To remove a document part from a package. 7 | static void RemovePart(string document) 8 | { 9 | // 10 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) 11 | // 12 | { 13 | // 14 | MainDocumentPart? mainPart = wordDoc.MainDocumentPart; 15 | 16 | if (mainPart is not null && mainPart.DocumentSettingsPart is not null) 17 | { 18 | mainPart.DeletePart(mainPart.DocumentSettingsPart); 19 | } 20 | // 21 | } 22 | } 23 | // 24 | -------------------------------------------------------------------------------- /.openpublishing.build.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [string]$buildCorePowershellUrl = "https://opbuildstoragesandbox2.blob.core.windows.net/opps1container/.openpublishing.buildcore.ps1", 3 | [string]$parameters 4 | ) 5 | # Main 6 | $errorActionPreference = 'Stop' 7 | 8 | # Step-1 Download buildcore script to local 9 | echo "download build core script to local with source url: $buildCorePowershellUrl" 10 | $repositoryRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition 11 | $buildCorePowershellDestination = "$repositoryRoot\.openpublishing.buildcore.ps1" 12 | Invoke-WebRequest $buildCorePowershellUrl -OutFile "$buildCorePowershellDestination" 13 | 14 | # Step-2: Run build core 15 | echo "run build core script with parameters: $parameters" 16 | & "$buildCorePowershellDestination" "$parameters" 17 | exit $LASTEXITCODE -------------------------------------------------------------------------------- /docs/includes/word/packages-and-document-parts.md: -------------------------------------------------------------------------------- 1 | ## Packages and Document Parts 2 | 3 | An Open XML document is stored as a package, whose format is defined by 4 | [!include[ISO/IEC 29500 URL](../iso-iec-29500-link.md)]. The 5 | package can have multiple parts with relationships between them. The 6 | relationship between parts controls the category of the document. A 7 | document can be defined as a word-processing document if its 8 | package-relationship item contains a relationship to a main document 9 | part. If its package-relationship item contains a relationship to a 10 | presentation part it can be defined as a presentation document. If its 11 | package-relationship item contains a relationship to a workbook part, it 12 | is defined as a spreadsheet document. In this how-to topic, you will use 13 | a word-processing document package. -------------------------------------------------------------------------------- /samples/word/remove_a_part_from_a_package/vb/Program.vb: -------------------------------------------------------------------------------- 1 | Imports DocumentFormat.OpenXml.Packaging 2 | 3 | Module Program 4 | Sub Main(args As String()) 5 | RemovePart(args(0)) 6 | End Sub 7 | 8 | ' 9 | ' To remove a document part from a package. 10 | Sub RemovePart(document As String) 11 | ' 12 | Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True) 13 | ' 14 | ' 15 | Dim mainPart As MainDocumentPart = wordDoc.MainDocumentPart 16 | 17 | If mainPart IsNot Nothing AndAlso mainPart.DocumentSettingsPart IsNot Nothing Then 18 | mainPart.DeletePart(mainPart.DocumentSettingsPart) 19 | End If 20 | ' 21 | End Using 22 | End Sub 23 | ' 24 | End Module 25 | -------------------------------------------------------------------------------- /samples/word/structure_of_a_wordprocessingml/cs/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | using DocumentFormat.OpenXml.Packaging; 3 | using DocumentFormat.OpenXml.Wordprocessing; 4 | 5 | static void CreateWordDoc(string filepath, string msg) 6 | { 7 | using (WordprocessingDocument doc = WordprocessingDocument.Create(filepath, DocumentFormat.OpenXml.WordprocessingDocumentType.Document)) 8 | { 9 | // Add a main document part. 10 | MainDocumentPart mainPart = doc.AddMainDocumentPart(); 11 | 12 | // Create the document structure and add some text. 13 | mainPart.Document = new Document(); 14 | Body body = mainPart.Document.AppendChild(new Body()); 15 | Paragraph para = body.AppendChild(new Paragraph()); 16 | Run run = para.AppendChild(new Run()); 17 | 18 | // String msg contains the text from the msg parameter" 19 | run.AppendChild(new Text(msg)); 20 | } 21 | } 22 | // 23 | 24 | CreateWordDoc(args[0], args[1]); 25 | -------------------------------------------------------------------------------- /docs/includes/word/using-statement.md: -------------------------------------------------------------------------------- 1 | With v3.0.0+ the method 2 | has been removed in favor of relying on the [using statement](/dotnet/csharp/language-reference/statements/using). 3 | It ensures that the method is automatically called 4 | when the closing brace is reached. The block that follows the using 5 | statement establishes a scope for the object that is created or named in 6 | the using statement. Because the class in the Open XML SDK 7 | automatically saves and closes the object as part of its implementation, and because 8 | is automatically called when you 9 | exit the block, you do not have to explicitly call or 10 | as long as you use a `using` statement. -------------------------------------------------------------------------------- /samples/word/add_a_new_part_to_a_package/cs/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | using DocumentFormat.OpenXml.Packaging; 3 | using System.IO; 4 | 5 | // 6 | string document = args[0]; 7 | string fileName = args[1]; 8 | 9 | AddNewPart(args[0], args[1]); 10 | // 11 | 12 | // To add a new document part to a package. 13 | // 14 | static void AddNewPart(string document, string fileName) 15 | { 16 | // 17 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) 18 | // 19 | { 20 | // 21 | MainDocumentPart mainPart = wordDoc.MainDocumentPart ?? wordDoc.AddMainDocumentPart(); 22 | 23 | CustomXmlPart myXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml); 24 | 25 | using (FileStream stream = new FileStream(fileName, FileMode.Open)) 26 | { 27 | myXmlPart.FeedData(stream); 28 | } 29 | // 30 | } 31 | } 32 | // 33 | -------------------------------------------------------------------------------- /samples/word/working_with_paragraphs/vb/Program.vb: -------------------------------------------------------------------------------- 1 | ' 2 | Imports DocumentFormat.OpenXml.Packaging 3 | Imports DocumentFormat.OpenXml.Wordprocessing 4 | 5 | Module MyModule 6 | 7 | Sub Main(args As String()) 8 | WriteToWordDoc(args(0), args(1)) 9 | End Sub 10 | 11 | Public Sub WriteToWordDoc(ByVal filepath As String, ByVal txt As String) 12 | ' Open a WordprocessingDocument for editing using the filepath. 13 | Using wordprocessingDocument As WordprocessingDocument = 14 | WordprocessingDocument.Open(filepath, True) 15 | ' Assign a reference to the existing document body. 16 | Dim body As Body = wordprocessingDocument.MainDocumentPart.Document.Body 17 | 18 | ' Add a paragraph with some text. 19 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 20 | Dim run As Run = para.AppendChild(New Run()) 21 | run.AppendChild(New Text(txt)) 22 | End Using 23 | 24 | End Sub 25 | End Module 26 | ' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open XML documentation 2 | 3 | This repo is the source markdown for documentation published at /office/open-xml/open-xml-sdk. 4 | 5 | ## Contributing 6 | 7 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 8 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 9 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 10 | 11 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 12 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 13 | provided by the bot. You will only need to do this once across all repos using our CLA. 14 | 15 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 16 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 17 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 18 | -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_worksheets/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml.Packaging; 2 | using DocumentFormat.OpenXml.Spreadsheet; 3 | using System; 4 | 5 | // 6 | // 7 | Sheets? sheets = GetAllWorksheets(args[0]); 8 | // 9 | 10 | if (sheets is not null) 11 | { 12 | foreach (Sheet sheet in sheets) 13 | { 14 | Console.WriteLine(sheet.Name); 15 | } 16 | } 17 | // 18 | 19 | // Retrieve a List of all the sheets in a workbook. 20 | // The Sheets class contains a collection of 21 | // OpenXmlElement objects, each representing one of 22 | // the sheets. 23 | // 24 | static Sheets? GetAllWorksheets(string fileName) 25 | { 26 | // 27 | Sheets? theSheets = null; 28 | // 29 | 30 | // 31 | using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, false)) 32 | { 33 | // 34 | theSheets = document?.WorkbookPart?.Workbook.Sheets; 35 | // 36 | // 37 | } 38 | 39 | return theSheets; 40 | } 41 | // 42 | -------------------------------------------------------------------------------- /LICENSE-CODE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) Microsoft Corporation 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial 11 | portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 15 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 16 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 17 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /samples/word/accept_all_revisions/cs/accept_all_revisions_cs.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.12.35728.132 d17.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "accept_all_revisions_cs", "accept_all_revisions_cs.csproj", "{FDDDBEF7-7D8F-4623-95E9-5E30BB031414}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FDDDBEF7-7D8F-4623-95E9-5E30BB031414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {FDDDBEF7-7D8F-4623-95E9-5E30BB031414}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {FDDDBEF7-7D8F-4623-95E9-5E30BB031414}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {FDDDBEF7-7D8F-4623-95E9-5E30BB031414}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /samples/word/accept_all_revisions/vb/accept_all_revisions_vb.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.12.35728.132 d17.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "accept_all_revisions_vb", "accept_all_revisions_vb.vbproj", "{9B669D97-F249-4437-9314-6A7ABAC50451}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9B669D97-F249-4437-9314-6A7ABAC50451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9B669D97-F249-4437-9314-6A7ABAC50451}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9B669D97-F249-4437-9314-6A7ABAC50451}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9B669D97-F249-4437-9314-6A7ABAC50451}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /samples/word/retrieve_application_property_values/cs/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | using DocumentFormat.OpenXml.Packaging; 3 | using System; 4 | static void GetApplicationProperty(string fileName) 5 | { 6 | // 7 | using (WordprocessingDocument document = WordprocessingDocument.Open(fileName, false)) 8 | { 9 | // 10 | 11 | // 12 | if (document.ExtendedFilePropertiesPart is null) 13 | { 14 | throw new ArgumentNullException("ExtendedFilePropertiesPart is null."); 15 | } 16 | 17 | var props = document.ExtendedFilePropertiesPart.Properties; 18 | // 19 | 20 | // 21 | if (props.Company is not null) 22 | Console.WriteLine("Company = " + props.Company.Text); 23 | 24 | if (props.Lines is not null) 25 | Console.WriteLine("Lines = " + props.Lines.Text); 26 | 27 | if (props.Manager is not null) 28 | Console.WriteLine("Manager = " + props.Manager.Text); 29 | // 30 | } 31 | } 32 | // 33 | 34 | GetApplicationProperty(args[0]); 35 | -------------------------------------------------------------------------------- /.github/workflows/auto-publish.yml: -------------------------------------------------------------------------------- 1 | name: auto-publish 2 | run-name: Automatically publish documentation 3 | on: 4 | schedule: 5 | - cron: '45 23 * * WED' 6 | jobs: 7 | auto-publish: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | contents: write 11 | defaults: 12 | run: 13 | shell: bash 14 | working-directory: ./ 15 | steps: 16 | - name: Check out repository 17 | uses: actions/checkout@v4 18 | with: 19 | fetch-depth: 0 20 | - name: Check out main 21 | run: | 22 | echo "Checking out main branch" 23 | git config user.name github-actions 24 | git config user.email github-actions@github.com 25 | git checkout main 26 | - name: Check out live 27 | run: | 28 | echo "Checking out live branch" 29 | git checkout live 30 | - name: Merge from main into live 31 | run: | 32 | echo "Merging from main to live" 33 | git merge main 34 | - name: Push changes 35 | run: | 36 | echo "Pushing changes to live branch" 37 | git push origin live 38 | 39 | -------------------------------------------------------------------------------- /samples/word/create_by_providing_a_file_name/cs/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | using DocumentFormat.OpenXml; 3 | using DocumentFormat.OpenXml.Packaging; 4 | using DocumentFormat.OpenXml.Wordprocessing; 5 | 6 | // 7 | CreateWordprocessingDocument(args[0]); 8 | // 9 | 10 | // 11 | static void CreateWordprocessingDocument(string filepath) 12 | { 13 | // Create a document by supplying the filepath. 14 | // 15 | using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document)) 16 | { 17 | // 18 | // Add a main document part. 19 | MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); 20 | 21 | // Create the document structure and add some text. 22 | mainPart.Document = new Document(); 23 | Body body = mainPart.Document.AppendChild(new Body()); 24 | Paragraph para = body.AppendChild(new Paragraph()); 25 | Run run = para.AppendChild(new Run()); 26 | run.AppendChild(new Text("Create text in body - CreateWordprocessingDocument")); 27 | } 28 | // 29 | } 30 | -------------------------------------------------------------------------------- /samples/word/structure_of_a_wordprocessingml/vb/Program.vb: -------------------------------------------------------------------------------- 1 | ' 2 | Imports DocumentFormat.OpenXml.Packaging 3 | Imports DocumentFormat.OpenXml.Wordprocessing 4 | 5 | Module MyModule 6 | 7 | Sub Main(args As String()) 8 | CreateWordDoc(args(0), args(1)) 9 | End Sub 10 | 11 | Sub CreateWordDoc(filepath As String, msg As String) 12 | Using doc As WordprocessingDocument = WordprocessingDocument.Create(filepath, DocumentFormat.OpenXml.WordprocessingDocumentType.Document) 13 | ' Add a main document part. 14 | Dim mainPart As MainDocumentPart = doc.AddMainDocumentPart() 15 | 16 | ' Create the document structure and add some text. 17 | mainPart.Document = New Document() 18 | Dim body As Body = mainPart.Document.AppendChild(New Body()) 19 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 20 | Dim run As Run = para.AppendChild(New Run()) 21 | 22 | ' String msg contains the text from the msg parameter 23 | run.AppendChild(New Text(msg)) 24 | End Using 25 | End Sub 26 | End Module 27 | ' 28 | -------------------------------------------------------------------------------- /samples/word/working_with_runs/vb/Program.vb: -------------------------------------------------------------------------------- 1 | ' 2 | Imports DocumentFormat.OpenXml.Packaging 3 | Imports DocumentFormat.OpenXml.Wordprocessing 4 | 5 | Module MyModule 6 | 7 | Sub Main(args As String()) 8 | WriteToWordDoc(args(0), args(1)) 9 | End Sub 10 | 11 | Public Sub WriteToWordDoc(ByVal filepath As String, ByVal txt As String) 12 | ' Open a WordprocessingDocument for editing using the filepath. 13 | Using wordprocessingDocument As WordprocessingDocument = 14 | WordprocessingDocument.Open(filepath, True) 15 | ' Assign a reference to the existing document body. 16 | Dim body As Body = wordprocessingDocument.MainDocumentPart.Document.Body 17 | 18 | ' Add new text. 19 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 20 | Dim run As Run = para.AppendChild(New Run()) 21 | 22 | ' Apply bold formatting to the run. 23 | Dim runProperties As RunProperties = run.AppendChild(New RunProperties(New Bold())) 24 | run.AppendChild(New Text(txt)) 25 | End Using 26 | End Sub 27 | End Module 28 | ' -------------------------------------------------------------------------------- /ThirdPartyNotices: -------------------------------------------------------------------------------- 1 | ##Legal Notices 2 | Microsoft and any contributors grant you a license to the Microsoft documentation and other content 3 | in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode), 4 | see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the 5 | [LICENSE-CODE](LICENSE-CODE) file. 6 | 7 | Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation 8 | may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. 9 | The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. 10 | Microsoft's general trademark guidelines can be found at https://go.microsoft.com/fwlink/?LinkID=254653. 11 | 12 | Privacy information can be found at https://privacy.microsoft.com/ 13 | 14 | Microsoft and any contributors reserve all others rights, whether under their respective copyrights, patents, 15 | or trademarks, whether by implication, estoppel or otherwise. -------------------------------------------------------------------------------- /samples/word/working_with_runs/cs/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | using DocumentFormat.OpenXml.Packaging; 3 | using DocumentFormat.OpenXml.Wordprocessing; 4 | 5 | static void WriteToWordDoc(string filepath, string txt) 6 | { 7 | // Open a WordprocessingDocument for editing using the filepath. 8 | using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(filepath, true)) 9 | { 10 | // Assign a reference to the existing document body. 11 | MainDocumentPart mainDocumentPart = wordprocessingDocument.MainDocumentPart ?? wordprocessingDocument.AddMainDocumentPart(); 12 | mainDocumentPart.Document ??= new Document(); 13 | Body body = mainDocumentPart.Document.Body ?? mainDocumentPart.Document.AppendChild(new Body()); 14 | 15 | // Add new text. 16 | Paragraph para = body.AppendChild(new Paragraph()); 17 | Run run = para.AppendChild(new Run()); 18 | 19 | // Apply bold formatting to the run. 20 | RunProperties runProperties = run.AppendChild(new RunProperties(new Bold())); 21 | run.AppendChild(new Text(txt)); 22 | } 23 | } 24 | // 25 | WriteToWordDoc(args[0], args[1]); -------------------------------------------------------------------------------- /samples/word/add_a_new_part_to_a_package/vb/Program.vb: -------------------------------------------------------------------------------- 1 | Imports DocumentFormat.OpenXml.Packaging 2 | Imports System.IO 3 | 4 | Module Program 5 | Sub Main(args As String()) 6 | ' 7 | Dim document As String = args(0) 8 | Dim fileName As String = args(1) 9 | 10 | AddNewPart(document, fileName) 11 | ' 12 | End Sub 13 | 14 | ' To add a new document part to a package. 15 | ' 16 | Sub AddNewPart(document As String, fileName As String) 17 | ' 18 | Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True) 19 | ' 20 | ' 21 | Dim mainPart As MainDocumentPart = If(wordDoc.MainDocumentPart, wordDoc.AddMainDocumentPart()) 22 | 23 | Dim myXmlPart As CustomXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml) 24 | 25 | Using stream As New FileStream(fileName, FileMode.Open) 26 | myXmlPart.FeedData(stream) 27 | End Using 28 | ' 29 | End Using 30 | End Sub 31 | ' 32 | End Module 33 | 34 | -------------------------------------------------------------------------------- /samples/word/retrieve_comments/cs/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | using DocumentFormat.OpenXml.Packaging; 3 | using DocumentFormat.OpenXml.Wordprocessing; 4 | using System; 5 | 6 | static void GetCommentsFromDocument(string fileName) 7 | { 8 | // 9 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(fileName, false)) 10 | { 11 | if (wordDoc.MainDocumentPart is null || wordDoc.MainDocumentPart.WordprocessingCommentsPart is null) 12 | { 13 | throw new System.ArgumentNullException("MainDocumentPart and/or WordprocessingCommentsPart is null."); 14 | } 15 | // 16 | 17 | // 18 | WordprocessingCommentsPart commentsPart = wordDoc.MainDocumentPart.WordprocessingCommentsPart; 19 | 20 | if (commentsPart is not null && commentsPart.Comments is not null) 21 | { 22 | foreach (Comment comment in commentsPart.Comments.Elements()) 23 | { 24 | Console.WriteLine(comment.InnerText); 25 | } 26 | } 27 | // 28 | } 29 | } 30 | // 31 | 32 | GetCommentsFromDocument(args[0]); 33 | -------------------------------------------------------------------------------- /samples/word/set_the_font_for_a_text_run/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml.Packaging; 2 | using DocumentFormat.OpenXml.Wordprocessing; 3 | using System; 4 | using System.Linq; 5 | 6 | 7 | // Set the font for a text run. 8 | // 9 | static void SetRunFont(string fileName) 10 | { 11 | // Open a Wordprocessing document for editing. 12 | using (WordprocessingDocument package = WordprocessingDocument.Open(fileName, true)) 13 | { 14 | // 15 | // Set the font to Arial to the first Run. 16 | // Use an object initializer for RunProperties and rPr. 17 | RunProperties rPr = new RunProperties( 18 | new RunFonts() 19 | { 20 | Ascii = "Arial" 21 | }); 22 | // 23 | 24 | // 25 | if (package.MainDocumentPart is null) 26 | { 27 | throw new ArgumentNullException("MainDocumentPart is null."); 28 | } 29 | 30 | Run r = package.MainDocumentPart.Document.Descendants().First(); 31 | r.PrependChild(rPr); 32 | // 33 | } 34 | } 35 | // 36 | 37 | SetRunFont(args[0]); 38 | -------------------------------------------------------------------------------- /samples/spreadsheet/get_worksheetformation_from_a_package/vb/Program.vb: -------------------------------------------------------------------------------- 1 | Imports DocumentFormat.OpenXml 2 | Imports DocumentFormat.OpenXml.Packaging 3 | Imports DocumentFormat.OpenXml.Spreadsheet 4 | 5 | Module Program 6 | Sub Main(args As String()) 7 | GetSheetInfo(args(0)) 8 | End Sub 9 | 10 | ' 11 | Sub GetSheetInfo(fileName As String) 12 | ' Open file as read-only. 13 | Using mySpreadsheet As SpreadsheetDocument = SpreadsheetDocument.Open(fileName, False) 14 | ' 15 | Dim sheets As Sheets = mySpreadsheet.WorkbookPart?.Workbook?.Sheets 16 | ' 17 | 18 | If sheets IsNot Nothing Then 19 | ' For each sheet, display the sheet information. 20 | ' 21 | For Each sheet As OpenXmlElement In sheets 22 | For Each attr As OpenXmlAttribute In sheet.GetAttributes() 23 | Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value) 24 | Next 25 | Next 26 | ' 27 | End If 28 | End Using 29 | End Sub 30 | ' 31 | End Module 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /samples/spreadsheet/get_worksheetformation_from_a_package/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml.Packaging; 2 | using System; 3 | using OpenXmlAttribute = DocumentFormat.OpenXml.OpenXmlAttribute; 4 | using OpenXmlElement = DocumentFormat.OpenXml.OpenXmlElement; 5 | using Sheets = DocumentFormat.OpenXml.Spreadsheet.Sheets; 6 | 7 | GetSheetInfo(args[0]); 8 | 9 | // 10 | static void GetSheetInfo(string fileName) 11 | { 12 | // Open file as read-only. 13 | using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(fileName, false)) 14 | { 15 | // 16 | Sheets? sheets = mySpreadsheet.WorkbookPart?.Workbook?.Sheets; 17 | // 18 | 19 | if (sheets is not null) 20 | { 21 | // For each sheet, display the sheet information. 22 | // 23 | foreach (OpenXmlElement sheet in sheets) 24 | { 25 | foreach (OpenXmlAttribute attr in sheet.GetAttributes()) 26 | { 27 | Console.WriteLine("{0}: {1}", attr.LocalName, attr.Value); 28 | } 29 | } 30 | // 31 | } 32 | } 33 | } 34 | // 35 | 36 | -------------------------------------------------------------------------------- /samples/word/working_with_paragraphs/cs/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | using DocumentFormat.OpenXml.Packaging; 3 | using DocumentFormat.OpenXml.Wordprocessing; 4 | using System; 5 | 6 | 7 | static void WriteToWordDoc(string filepath, string txt) 8 | { 9 | // Open a WordprocessingDocument for editing using the filepath. 10 | using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(filepath, true)) 11 | { 12 | if (wordprocessingDocument is null) 13 | { 14 | throw new ArgumentNullException(nameof(wordprocessingDocument)); 15 | } 16 | // Assign a reference to the existing document body. 17 | MainDocumentPart mainDocumentPart = wordprocessingDocument.MainDocumentPart ?? wordprocessingDocument.AddMainDocumentPart(); 18 | mainDocumentPart.Document ??= new Document(); 19 | Body body = mainDocumentPart.Document.Body ?? mainDocumentPart.Document.AppendChild(new Body()); 20 | 21 | // Add a paragraph with some text. 22 | Paragraph para = body.AppendChild(new Paragraph()); 23 | Run run = para.AppendChild(new Run()); 24 | run.AppendChild(new Text(txt)); 25 | } 26 | } 27 | // 28 | 29 | WriteToWordDoc(args[0], args[1]); -------------------------------------------------------------------------------- /samples/word/search_and_replace_text_a_part/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml.Packaging; 2 | using System; 3 | using System.IO; 4 | using System.Text.RegularExpressions; 5 | 6 | // 7 | SearchAndReplace(args[0]); 8 | // 9 | 10 | // To search and replace content in a document part. 11 | // 12 | static void SearchAndReplace(string document) 13 | { 14 | // 15 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) 16 | // 17 | { 18 | string? docText = null; 19 | 20 | 21 | if (wordDoc.MainDocumentPart is null) 22 | { 23 | throw new ArgumentNullException("MainDocumentPart and/or Body is null."); 24 | } 25 | 26 | using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream())) 27 | { 28 | docText = sr.ReadToEnd(); 29 | } 30 | 31 | Regex regexText = new Regex("Hello World!"); 32 | docText = regexText.Replace(docText, "Hi Everyone!"); 33 | 34 | using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create))) 35 | { 36 | sw.Write(docText); 37 | } 38 | } 39 | } 40 | // 41 | -------------------------------------------------------------------------------- /docs/includes/spreadsheet/open-spreadsheet.md: -------------------------------------------------------------------------------- 1 | ## Getting a SpreadsheetDocument Object 2 | 3 | In the Open XML SDK, the class represents an 4 | Excel document package. To open and work with an Excel document, you 5 | create an instance of the `SpreadsheetDocument` class from the document. 6 | After you create the instance from the document, you can then obtain 7 | access to the main workbook part that contains the worksheets. The text 8 | in the document is represented in the package as XML using `SpreadsheetML` markup. 9 | 10 | To create the class instance from the document that you call one of the 11 | methods. Several are provided, each 12 | with a different signature. The sample code in this topic uses the @"DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open*?text=Open(String, Boolean)" method with a 13 | signature that requires two parameters. The first parameter takes a full 14 | path string that represents the document that you want to open. The 15 | second parameter is either `true` or `false` and represents whether you want the file to 16 | be opened for editing. Any changes that you make to the document will 17 | not be saved if this parameter is `false`. -------------------------------------------------------------------------------- /samples/word/set_the_font_for_a_text_run/vb/Program.vb: -------------------------------------------------------------------------------- 1 | Imports DocumentFormat.OpenXml.Packaging 2 | Imports DocumentFormat.OpenXml.Wordprocessing 3 | 4 | Module MyModule 5 | 6 | ' Set the font for a text run. 7 | ' 8 | Sub SetRunFont(fileName As String) 9 | ' Open a Wordprocessing document for editing. 10 | Using package As WordprocessingDocument = WordprocessingDocument.Open(fileName, True) 11 | ' 12 | ' Set the font to Arial to the first Run. 13 | ' Use an object initializer for RunProperties and rPr. 14 | Dim rPr As New RunProperties(New RunFonts() With { 15 | .Ascii = "Arial" 16 | }) 17 | ' 18 | 19 | ' 20 | If package.MainDocumentPart Is Nothing Then 21 | Throw New ArgumentNullException("MainDocumentPart is null.") 22 | End If 23 | 24 | Dim r As Run = package.MainDocumentPart.Document.Descendants(Of Run)().First() 25 | r.PrependChild(Of RunProperties)(rPr) 26 | ' 27 | End Using 28 | End Sub 29 | ' 30 | 31 | Sub Main(args As String()) 32 | SetRunFont(args(0)) 33 | End Sub 34 | 35 | End Module 36 | 37 | -------------------------------------------------------------------------------- /samples/word/get_the_contents_of_a_part_from_a_package/cs/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | using DocumentFormat.OpenXml.Packaging; 3 | using System; 4 | using System.IO; 5 | // 6 | string document = args[0]; 7 | GetCommentsFromDocument(document); 8 | // 9 | 10 | // To get the contents of a document part. 11 | // 12 | // 13 | static string GetCommentsFromDocument(string document) 14 | { 15 | string? comments = null; 16 | 17 | // 18 | using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, false)) 19 | // 20 | { 21 | if (wordDoc is null) 22 | { 23 | throw new ArgumentNullException(nameof(wordDoc)); 24 | } 25 | 26 | MainDocumentPart mainPart = wordDoc.MainDocumentPart ?? wordDoc.AddMainDocumentPart(); 27 | WordprocessingCommentsPart WordprocessingCommentsPart = mainPart.WordprocessingCommentsPart ?? mainPart.AddNewPart(); 28 | // 29 | 30 | // 31 | using (StreamReader streamReader = new StreamReader(WordprocessingCommentsPart.GetStream())) 32 | { 33 | comments = streamReader.ReadToEnd(); 34 | } 35 | } 36 | 37 | return comments; 38 | // 39 | } 40 | // 41 | -------------------------------------------------------------------------------- /samples/word/create_by_providing_a_file_name/vb/Program.vb: -------------------------------------------------------------------------------- 1 | Imports DocumentFormat.OpenXml 2 | Imports DocumentFormat.OpenXml.Packaging 3 | Imports DocumentFormat.OpenXml.Wordprocessing 4 | 5 | 6 | Module MyModule 7 | 8 | Sub Main(args As String()) 9 | ' 10 | CreateWordprocessingDocument(args(0)) 11 | ' 12 | End Sub 13 | 14 | ' 15 | Public Sub CreateWordprocessingDocument(ByVal filepath As String) 16 | ' Create a document by supplying the filepath. 17 | ' 18 | Using wordDocument As WordprocessingDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document) 19 | ' 20 | 21 | ' Add a main document part. 22 | Dim mainPart As MainDocumentPart = wordDocument.AddMainDocumentPart() 23 | 24 | ' Create the document structure and add some text. 25 | mainPart.Document = New Document() 26 | Dim body As Body = mainPart.Document.AppendChild(New Body()) 27 | Dim para As Paragraph = body.AppendChild(New Paragraph()) 28 | Dim run As Run = para.AppendChild(New Run()) 29 | run.AppendChild(New Text("Create text in body - CreateWordprocessingDocument")) 30 | End Using 31 | End Sub 32 | ' 33 | End Module -------------------------------------------------------------------------------- /samples/spreadsheet/retrieve_a_list_of_the_worksheets/vb/Program.vb: -------------------------------------------------------------------------------- 1 | Imports DocumentFormat.OpenXml.Packaging 2 | Imports DocumentFormat.OpenXml.Spreadsheet 3 | 4 | Module Program 5 | Sub Main(args As String()) 6 | ' 7 | ' 8 | Dim sheets As Sheets = GetAllWorksheets(args(0)) 9 | ' 10 | 11 | If sheets IsNot Nothing Then 12 | For Each sheet As Sheet In sheets 13 | Console.WriteLine(sheet.Name) 14 | Next 15 | End If 16 | ' 17 | End Sub 18 | 19 | ' Retrieve a List of all the sheets in a workbook. 20 | ' The Sheets class contains a collection of 21 | ' OpenXmlElement objects, each representing one of 22 | ' the sheets. 23 | ' 24 | Function GetAllWorksheets(fileName As String) As Sheets 25 | ' 26 | Dim theSheets As Sheets = Nothing 27 | ' 28 | 29 | ' 30 | Using document As SpreadsheetDocument = SpreadsheetDocument.Open(fileName, False) 31 | ' 32 | theSheets = document?.WorkbookPart?.Workbook.Sheets 33 | ' 34 | ' 35 | End Using 36 | 37 | Return theSheets 38 | End Function 39 | ' 40 | End Module 41 | -------------------------------------------------------------------------------- /samples/spreadsheet/structure_ofml/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml; 2 | using DocumentFormat.OpenXml.Packaging; 3 | using DocumentFormat.OpenXml.Spreadsheet; 4 | 5 | CreateSpreadsheetWorkbook(args[0]); 6 | // 7 | static void CreateSpreadsheetWorkbook(string filepath) 8 | { 9 | // Create a spreadsheet document by supplying the filepath. 10 | // By default, AutoSave = true, Editable = true, and Type = xlsx. 11 | using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(filepath, SpreadsheetDocumentType.Workbook)) 12 | { 13 | // Add a WorkbookPart to the document. 14 | WorkbookPart workbookPart = spreadsheetDocument.AddWorkbookPart(); 15 | workbookPart.Workbook = new Workbook(); 16 | 17 | // Add a WorksheetPart to the WorkbookPart. 18 | WorksheetPart worksheetPart = workbookPart.AddNewPart(); 19 | worksheetPart.Worksheet = new Worksheet(new SheetData()); 20 | 21 | // Add Sheets to the Workbook. 22 | Sheets sheets = workbookPart.Workbook.AppendChild(new Sheets()); 23 | 24 | // Append a new worksheet and associate it with the workbook. 25 | Sheet sheet = new Sheet() { Id = workbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "mySheet" }; 26 | sheets.Append(sheet); 27 | } 28 | } 29 | // 30 | -------------------------------------------------------------------------------- /samples/word/retrieve_comments/vb/Program.vb: -------------------------------------------------------------------------------- 1 | ' 2 | Imports DocumentFormat.OpenXml.Packaging 3 | Imports DocumentFormat.OpenXml.Wordprocessing 4 | 5 | Module Program 6 | Sub Main(args As String()) 7 | GetCommentsFromDocument(args(0)) 8 | End Sub 9 | 10 | Public Sub GetCommentsFromDocument(ByVal fileName As String) 11 | 12 | ' 13 | Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(fileName, False) 14 | 15 | If wordDoc.MainDocumentPart Is Nothing Or wordDoc.MainDocumentPart.WordprocessingCommentsPart Is Nothing Then 16 | Throw New ArgumentNullException("MainDocumentPart and/or WordprocessingCommentsPart is null.") 17 | End If 18 | ' 19 | 20 | ' 21 | Dim commentsPart As WordprocessingCommentsPart = wordDoc.MainDocumentPart.WordprocessingCommentsPart 22 | 23 | If commentsPart IsNot Nothing AndAlso commentsPart.Comments IsNot Nothing Then 24 | For Each comment As Comment In 25 | commentsPart.Comments.Elements(Of Comment)() 26 | Console.WriteLine(comment.InnerText) 27 | Next 28 | End If 29 | ' 30 | 31 | End Using 32 | End Sub 33 | End Module 34 | ' 35 | -------------------------------------------------------------------------------- /samples/spreadsheet/add_custom_ui/cs/Program.cs: -------------------------------------------------------------------------------- 1 | using DocumentFormat.OpenXml.Office.CustomUI; 2 | using DocumentFormat.OpenXml.Packaging; 3 | 4 | // 5 | string xml = 6 | @" 7 | 8 | 9 | 10 | 11 |