如何使用 PHP 在文本区域中显示 Word 文档?
我试图使用 com 类测试代码来显示 Word 文件,但我似乎无法得到答案并且仍在搜索。 我遇到错误,有时程序根本不显示任何内容。 请给我一些想法。 我正在使用 PHP 4。
I was trying to test code using com class to display Word files but I cannot seem to get the answer and still searching. I get errors and sometimes, programs do not display anything at all. Please give me some ideas. I'm working with PHP 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果站点托管在装有 Word 的 Windows 计算机上,您可以使用 PHP 的 COM 扩展来访问 Word 文档。 使用 Word 的自动化模型公开的自动化方法,您可能可以执行一些操作,例如将 Word 文档导出为 HTML,然后将该 HTML 呈现到页面上的某个框架/div。 我没有查看代码或尝试过,但有人在这里创建了一个 word/php 类:
http://www.phpclasses.org/browse/package/3553.html
可能还有很多其他的。
尽管我过去见过代码实际上可以在不使用自动化的情况下直接读取 Word 文档,但我不推荐它,因为它很容易被新版本或奇怪的文件格式破坏。
If the site is hosted on a Windows machine with Word you may be able to use a COM extension to PHP that will give you access to Word documents. Using the automation methods exposed by Word's Automation model, you could probably do something like export a word document to HTML and then render that HTML to some frame/div on your page. I haven't looked at the code or tried it, but someone has created a word/php class here:
http://www.phpclasses.org/browse/package/3553.html
There are probably many others.
Although I have seen code in the past that will actually read a Word document directly without the use of Automation, I wouldn't recommend it as it could be easily broken by new versions or oddities in file format.
您的意思是您想在浏览器中激活单词插件吗? 尝试
Do you mean you want to have the word plugin activated in the browser? Try the
<object>
tag with the correct mime type.