简体   繁体   中英

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

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.

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:

Hope that helps!

打开XML SDK 2.0生产力工具

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM