我试图使用 com 类测试代码以显示 Word 文件,但我似乎无法得到答案并且仍在搜索。我收到错误,有时程序根本不显示任何内容。请给我一些想法。我正在使用 PHP 4。
arken
问问题
9327 次
3 回答
2
如果该站点托管在带有 Word 的 Windows 计算机上,则您可以使用 PHP 的 COM 扩展来访问 Word 文档。使用 Word 的自动化模型公开的自动化方法,您可能会执行一些操作,例如将 word 文档导出到 HTML,然后将该 HTML 呈现到页面上的某个框架/div。我没有查看代码或尝试过,但有人在这里创建了一个 word/php 类:
http ://www.phpclasses.org/browse/package/3553.html
可能还有很多其他人。
虽然我在过去看到过无需使用自动化就可以直接读取 Word 文档的代码,但我不推荐它,因为它很容易被新版本或文件格式中的怪异所破坏。
于 2008-10-20T10:24:44.490 回答
0
你的意思是你想在浏览器中激活这个词插件?尝试<object>
使用正确的 mime 类型的标签。
于 2008-10-20T10:13:57.537 回答
0
<head><title>snook.ca load document</title>
<script language="JavaScript">
<!--//
function loadworddoc(){
// creates the word object
var doc = new ActiveXObject("Word.Application");
// doesn't display Word window
doc.Visible=false;
// specify path to document
doc.Documents.Open(document.all.hello.value);
//copy the content from my word document and throw it into my variable
var txt;
txt = doc.Documents(document.all.hello.value).Content;
//document.all.myarea.value = txt;
document.all.tbContentElement.DOM.body.innerHTML = txt;
// quit word (very important or you'll quickly chew up memory!)
doc.quit(0);
}
//-->
</script>
</head>
<body>
<p><input type=button onClick="loadworddoc();" value="Load">
<p><input type=file name=hello>
<p><textarea name=myarea cols=50 rows=5>nothing here yet</textarea>
<object ID="tbContentElement" CLASS="tbContentElement"
CLASSID="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" VIEWASTEXT
width="450" height="300">
<param name=Scrollbars value=true></object>
</body>
于 2019-05-25T20:11:36.837 回答