我将如何使用下面的DocumentFormat.OpenXml -details从docx文件中提取数据

时间:2022-06-10 19:54:59

I have a Docx file created by adding the xml schema. I am giving you the link of the docx file .我将如何使用下面的DocumentFormat.OpenXml -details从docx文件中提取数据

我有一个通过添加xml架构创建的Docx文件。我给你docx文件的链接。

now I want to extract-- To,From,heading,body. Currently I am using the Library DocumentFormat.OpemXml. But didnt succeed. Can any one suggest me the steps .

现在我想提取 - To,From,heading,body。目前我正在使用Library DocumentFormat.OpemXml。但没有成功。可以任何人建议我的步骤。

2 个解决方案

#1


1  

This answer is late I know but after years reading this site I find myself in a position to help.

这个答案我知道的很晚,但经过多年阅读本网站,我发现自己有能力提供帮助。

As the previous answer stated it is just as simple as opening the file as a zip and examining the contents. This approach can be limiting if you ever intend to go beyond reading some simple data out.

正如之前的回答所说,它就像打开zip文件并检查内容一样简单。如果您打算超越阅读一些简单的数据,这种方法可能会受到限制。

If you haven't already, checkout the Open XML Productivity Tool from Microsoft. It is installed as part of the openxml sdk. It makes it alot easier to find what you are looking for.

如果您还没有,请查看Microsoft的Open XML Productivity Tool。它作为openxml sdk的一部分安装。这使得找到你想要的东西变得更容易。

Another excellent resource is the PowerTools for OpenXML basically an open source collection of powershell cmdlets. It is the best example ive seen of coding against the open xml sdk.

另一个优秀的资源是OpenXML的PowerTools基本上是PowerShell cmdlet的开源集合。这是我见过针对open xml sdk进行编码的最好例子。

-SDR

-SDR

#2


0  

you have to explore the DocumentFormat.OpenXml for the extraction of your data from the docx file. Or Another method is that,

您必须浏览DocumentFormat.OpenXml以从docx文件中提取数据。或者另一种方法是,

First convert the extension of the docx file to .zip . After opening the zip file open the file document.xml. In this file you will find all your data . Now you just need to do is to read the xml file in c# and extract the data. You use xmlDocument class and extract The data

首先将docx文件的扩展名转换为.zip。打开zip文件后,打开文件document.xml。在此文件中,您将找到所有数据。现在您只需要在c#中读取xml文件并提取数据。您使用xmlDocument类并提取数据

I think it will be useful.

我认为这将是有用的。

#1


1  

This answer is late I know but after years reading this site I find myself in a position to help.

这个答案我知道的很晚,但经过多年阅读本网站,我发现自己有能力提供帮助。

As the previous answer stated it is just as simple as opening the file as a zip and examining the contents. This approach can be limiting if you ever intend to go beyond reading some simple data out.

正如之前的回答所说,它就像打开zip文件并检查内容一样简单。如果您打算超越阅读一些简单的数据,这种方法可能会受到限制。

If you haven't already, checkout the Open XML Productivity Tool from Microsoft. It is installed as part of the openxml sdk. It makes it alot easier to find what you are looking for.

如果您还没有,请查看Microsoft的Open XML Productivity Tool。它作为openxml sdk的一部分安装。这使得找到你想要的东西变得更容易。

Another excellent resource is the PowerTools for OpenXML basically an open source collection of powershell cmdlets. It is the best example ive seen of coding against the open xml sdk.

另一个优秀的资源是OpenXML的PowerTools基本上是PowerShell cmdlet的开源集合。这是我见过针对open xml sdk进行编码的最好例子。

-SDR

-SDR

#2


0  

you have to explore the DocumentFormat.OpenXml for the extraction of your data from the docx file. Or Another method is that,

您必须浏览DocumentFormat.OpenXml以从docx文件中提取数据。或者另一种方法是,

First convert the extension of the docx file to .zip . After opening the zip file open the file document.xml. In this file you will find all your data . Now you just need to do is to read the xml file in c# and extract the data. You use xmlDocument class and extract The data

首先将docx文件的扩展名转换为.zip。打开zip文件后,打开文件document.xml。在此文件中,您将找到所有数据。现在您只需要在c#中读取xml文件并提取数据。您使用xmlDocument类并提取数据

I think it will be useful.

我认为这将是有用的。