如何在 C# (.NET) 中加载 MS Word 文档的文本? [英] How to load text of MS Word document in C# (.NET)?

查看:34
本文介绍了如何在 C# (.NET) 中加载 MS Word 文档的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不执行此操作的情况下将 MS Word 文档(.doc 和 .docx)加载到内存(变量)中?:

How do I load MS Word document (.doc and .docx) to memory (variable) without doing this?:

wordApp.Documents.Open

我不想打开 MS Word,我只想要里面的文本.

I don't want to open MS Word, I just want that text inside.

你给了我关于 DOCX 的答案,但关于 DOC 呢?我想要免费和高性能的解决方案 - 不要打开 12.000 个 Word 实例来处理所有这些实例.:( Aspose 是商业产品,900 美元对于我的工作来说太过分了.

You gave me answer for DOCX, but what about DOC? I want free and high performance solution - not to open 12.000 instances of Word to process all of them. :( Aspose is commercial product, and 900$ is a way too much for what I do.

推荐答案

您可以使用 Office 兼容包中的 wordconv.exe 将 doc 转换为 docx.

You can use wordconv.exe which is part of the Office Compatibility Pack to convert from doc to docx.

http:///www.microsoft.com/downloads/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en

只需像这样调用命令:"C:Program FilesMicrosoft OfficeOffice12wordconv.exe" -oice -nme InputFile OutputFile

Just call the command like so: "C:Program FilesMicrosoft OfficeOffice12wordconv.exe" -oice -nme InputFile OutputFile

我不确定您是否需要安装 word 才能运行,但它确实有效.我在本地使用它作为 windows shell 命令,随时将旧的 office 文件转换为 2007 格式.

I'm not sure if you need word installed for it to run but it does work. I use it locally as a windows shell command to convert old office files to 2007 format whenever I want.

这篇关于如何在 C# (.NET) 中加载 MS Word 文档的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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