用C#读取word文档 [英] Read word document in C#

查看:30
本文介绍了用C#读取word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读取服务器中的word文档(doc和docx).服务器没有安装了office,所以我不能使用com对象,也不能使用商业软件.

I want to read a word document in the server (both doc and docx). The server does not have office installed, therefore i can't use com objects and also no commercial softwares.

有没有一种方法可以让我单独使用办公工具并阅读单词文档(2003 年和 2007 年)

Is there a way that I can use office tools alone and read the word docs (2003 and 2007)

推荐答案

很遗憾,没有好的免费选项可用于阅读 .doc 和 .docx 文件.即使是价格合理的商业选择也很少,但也有非常昂贵的选择.

Unfortunately there are no good free options for reading .doc and .docx files. Even commercial options are sparse at reasonable prices, but there are good extremely expensive options.

对于阅读 .doc 文件,我所知道的唯一免费选项是 Java 的 POI,您可以使用 IKVM 在 .NET 中运行它.但是POI的SVN仓库的一个实验分支支持Word,所以不知道效果如何.

For reading .doc files the only free option I'm aware of is POI for Java which you can run in .NET using IKVM. However, Word support in an experimental branch of POI's SVN repository, so I don't know how well it works.

http://poi.apache.org/

http://www.ikvm.net/

如果您只想要 .doc 文件中的文本而不关心格式,您可以使用 IFilter 通过 pinvoke 的 Win32 接口.

If you just want the text out of the .doc file and don't care about formatting, you can use the IFilter Win32 interface through pinvoke.

要阅读 .docx 文件,您可以使用 Microsoft Office Open XML SDK.不过,不要让SDK"愚弄您,这是对直接处理 XML 的一种非常轻量级的抽象.使用起来几乎一样痛苦.

For reading .docx files you can use Microsoft Office Open XML SDK. Don't let "SDK" fool you though, this is a very light abstraction over the dealing with the XML directly. It's almost as painful to use.

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

这篇关于用C#读取word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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