如何使用 WinForms WebBrowser 查看 Microsoft 文档
我需要能够在系统上的 System.Windows.Forms.WebBrowser (C# Visual Studio 2008) 中查看文件(.doc、docx、.pdf、.txt、.....ect)没有安装office。我该怎么做?能做到吗?我查看了许多与此相关的文档,并且大多数文档都已经安装了 Office。我只需要能够预览文档,而不是修改它们。
I need to be able to view a file (.doc, docx, .pdf, .txt,.....ect) in the System.Windows.Forms.WebBrowser (C# Visual Studio 2008) on a system that does not have office installed on it. How do I do that? Can it be done? I viewed many of the documentation that are out there regarding this and most all have office installed already. I just need to be able to preview the documents, not modify them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般情况下你不能这样做。浏览器显示 Office 文档(或任何其他类型的文档)的方式是运行创建它的应用程序 - 在本例中为 Office。
有多种工具可以将 Office 文档呈现为 HTML。您也许可以使用这些。我经常看到提到的一个是 Aspose,尽管我没有使用过它。
You can't do this in general. The way a browser displays an Office Document (or any other kind of document) is to run the application that created it - in this case, Office.
There are various tools which can render Office documents as HTML. You may be able to use those. One that I see mentioned frequently is Aspose, though I have not used it.
不,您不能仅使用 Web 浏览器来执行此操作。
如果您以前见过 WebBrowser 打开 Word 文档,那是因为系统上安装了 Office,并且它使用 Office ActiveX 控件来查看它。
一些替代方法:
以编程方式将文档上传到 Office Live,然后通过 Web 浏览器导航到该文档。 Office Live 现在具有“Web 浏览器中的 Word”功能,在此处查看。
No, you can't do this using just the WebBrowser.
If you've seen the WebBrowser open a Word doc before, it's because Office was installed on the system, and it was using the Office ActiveX control to view it.
Some alteratives:
Programmatically upload the document to Office Live, then navigate the web browser to it. Office Live now has "Word in a web browser" functionality, check it out here.