How can i read .docx file? [closed]

血红的双手。 提交于 2019-11-26 09:50:22

问题


I have a .docx file and it contains many email addresses to which i want to bulk mail. How can i read docx file through c#?


回答1:


The easiest way is probably to use the Open XML SDK 2.0

Get Code Snippets for Visual Studio 2008 for some examples

And I would highly recommend downloading the Open XML SDK productivity tool which will help you understand how the Open XML files are structured, and can even help you generate source code to use with the SDK based on the structure of your documents. You can download the tool from the same page as the SDK. It's 100MB, but it's worth the download.




回答2:


You can simply use Docx library, it is very good and easy to use.

For samples guiding how to use and many examples and videos, check their GitHub page. For download, you could download from here




回答3:


You can read Microsoft Office files through Interop, and Office >2007 files through Open XML as well:

  • Interop: http://blogs.techrepublic.com/howdoi/?p=190
  • Open XML: http://msdn.microsoft.com/en-us/library/bb656295(office.12).aspx



回答4:


Yes, I know this is a very old post, but this information might help others who are searching the forums.

Use this library from Sourceforge. Add a reference to that library, and then:

Code7248.word_reader.TextExtractor extractor = new TextExtractor(filePath);

string contents = extractor.ExtractText();




回答5:


Office 2007 and above follow OpenXML format. you need Packaging API to open and read document parts

http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx

http://openxmldeveloper.org




回答6:


docx files are in fact archives.

You can unzip them into their composite XML files and read through the relevant XML file (file.docx\word\document.xml)) and pull out the email addresses.

This library will help you to unzip the archive: .Net Zip Library




回答7:


There is free way to read doc & docx file, It could help you.

Document doc = new Document();
doc.LoadFromFile("yourfile.docx");

http://freeword.codeplex.com/



来源:https://stackoverflow.com/questions/3633615/how-can-i-read-docx-file

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