How do I read data from a word with format using the OpenXML Format SDK with c#?

馋奶兔 提交于 2019-12-08 09:56:48

问题


I used below lines of code for getting string from docx file. I can able to read string but not in format. how to read docx data with format.

    using (WordprocessingDocument myDocument = WordprocessingDocument.Open(docxFilePath, true))
    {
        Body body = myDocument.MainDocumentPart.Document.Body;
        string content = body.InnerText;
    }

Thanks for quick reply.


回答1:


OpenXML format - is an XML based format that provides the access to entire content of Office documents like MS Word, Excel, PowerPoint, etc. To understand better how to programming this format you could download and install The OpenXML SDK 2.0 Toolkit

Once you have this installed you will be able to look inside OpenXML files (docx, etc.) and see how XML looks like and how to programm this in C#. All of that you could see in Open XML SDK 2.0 Productivity Tool (which is a part of Open XML SDK 2.0). See the screenshot below:

Links to Eric White blogs, that might be helpful to read about OpenXML usage:

  • http://blogs.msdn.com/b/ericwhite/
  • http://ericwhite.com/blog/

Hope that helps!



来源:https://stackoverflow.com/questions/9477500/how-do-i-read-data-from-a-word-with-format-using-the-openxml-format-sdk-with-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!