在未安装 Office 的服务器上操作 Word 文档 (ASP.NET)
我正在编写一个代码来制作 MS Word 到 HTML 系统。在谷歌搜索大约半分钟后,我找到了完全符合我需要的代码。现在..它可以在 ASP.NET 开发服务器上离线工作,但当我将文件上传到我的服务器上时,它就无法工作。
我读了几篇文章,问题似乎是因为服务器上没有安装 MS Office。现在,我不确定它是否已经安装,我仍在等待来自托管的好人的电子邮件(但我假设它没有安装),但我的问题是......
有没有什么方法可以让它在没有安装的情况下工作?安装了 MS Office 吗? 我正在使用 Microsoft.Office.Interop.Word 版本。 12. / ASP 3.5 / C# 我得到的错误是
无法加载文件或程序集 '微软.Office.Interop.Word, 版本=12.0.0.0,文化=中立, PublicKeyToken=71e9bce111e9429c' 或 它的依赖项之一。
谢谢您的宝贵时间!
I'm working on a code to make a MS Word to HTML system. After googleing for about half a minute, I was able to find the code which does exactly what I need. Now.. It works offline on the ASP.NET development server, but it won't work when I upload the files on my server.
I read a couple of posts, and the problem seems to be becouse the server does not have MS Office installed on it. Now, i'm not sure if it has, i'm still avaiting an email from the good people @ hosting (but i assume it's not installed), but my question is...
Is there ANY way to make it work without th MS Office installed?
I'm using Microsoft.Office.Interop.Word ver. 12. / ASP 3.5 / C# and the error I'm getting is
Could not load file or assembly
'Microsoft.Office.Interop.Word,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c' or
one of its dependencies.
Thank you for your time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Interop 库本身并不是一个“工作”库,它只是 .NET 程序的 winword.exe 的包装器,因此如果您不安装或使用 Microsoft Word,那么使用此库没有任何意义。
相反,您需要找到一个允许操作 Word 文档的库。如果您可以将文档限制为新格式(docx),那么这将是一项非常简单的任务,例如使用 OOXML SDK(也由 Stilgar 提议)。但也有旧格式的库。
更新:我必须承认,虽然我确信我之前搜索并找到了一些旧文档格式的库,但我再也找不到这些库了,可能是因为结果列表被“破坏”了docx 的众多优惠。需要明确的是:
如果您有能力坚持使用 docx(2007 或更高版本)格式,您应该这样做。 Office Open XML 是一个(或多或少)基于 ZIP 和 XML 的开放标准,许多工具已经存在并将在将来开发。现在旧格式的支持要少得多。
如果您也必须采用旧格式,则 Aspose(由 Uwe 提议)是我找到的唯一库。
The Interop library is not a "working" library in itself, it is only a wrapper around winword.exe for .NET programs, so using this library does not make any sense if you don't install or use Microsoft Word.
Instead you will need to find a library that allows for manipulating Word Documents. If you can constrain the documents to be in the new format (docx), then it will be quite an easy task, e.g. using the OOXML SDK (as proposed by Stilgar, too). But there are libraries for the old format, too.
Update: I have to admit, although I was convinced I searched and found some libraries for the old doc format before, I do not manage to find those anymore, probably because the result lists is "spoiled" by the many offers for docx. To be clear:
If you can afford to stick to docx (2007 or later) format, you should do that. Office Open XML is a (more or less) open standard based on ZIP and XML, and many tools already exist and will be developed in the future. The old format is much less supported nowadays.
If you have to go for the old format, too, then Aspose (as proposed by Uwe) is the only library I found.
我认为 OOXML SDK 可能包含某些内容,但它仅适用于 docx 而不适用于旧文档。
至于旧格式,我也对一种廉价且简单的方式来支持它们感兴趣,而无需使用自动化 API
I think the OOXML SDK may contain something but it will only work with docx and not with the old doc.
As for the old formats I am also interested in a cheap and easy way to support them without the need to use the Automation APIs
您可以使用 Code7248.word_reader.dll
下面是有关如何使用 Code7248 的示例代码。 word_reader.dll
在您的项目中添加对此 DLL 的引用并复制以下代码。
you can use Code7248.word_reader.dll
below is the sample code on how to use Code7248.word_reader.dll
add reference to this DLL in your project and copy below code.