Want to improve this question? Update the question so it f开发者_开发技巧ocuses on one problem only by editing this post.
Closed 5 years ago.
Improve this questionI 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#?
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.
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
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();
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
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
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
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/
精彩评论