如何使用带有c#的OpenXML Format SDK从具有格式的单词中读取数据? [英] How do I read data from a word with format using the OpenXML Format SDK with c#?

查看:66
本文介绍了如何使用带有c#的OpenXML Format SDK从具有格式的单词中读取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码行从docx文件中获取字符串.我可以读取字符串,但不能读取格式.如何读取具有格式的docx数据.

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;
    }

感谢您的快速回复.

推荐答案

OpenXML格式-一种基于XML的格式,可以访问Office文档的全部内容,例如MS Word,Excel,PowerPoint等.对这种格式进行编程,您可以下载并安装 OpenXML SDK 2.0工具包

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

一旦安装了此程序,就可以查看OpenXML文件(docx等),并查看XML的外观以及如何在C#中对其进行编程.您可以在Open XML SDK 2.0生产率工具(这是Open XML SDK 2.0的一部分)中看到的所有内容.请参见下面的屏幕截图:

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:

链接到Eric White博客,可能有助于阅读有关OpenXML使用的信息:

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

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

希望有帮助!

这篇关于如何使用带有c#的OpenXML Format SDK从具有格式的单词中读取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆