- 论坛徽章:
- 0
|
请问如何用PHP读取word之类的文档
如果仅仅是读取的话,不用调用com
我给您一个完整的代码
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">;
- <html style='width:350px; Height: 140px;'>;
- <head>;
- <title>;Open A Word& Document</title>;
- <style>; html, body, button, div, input, select{ font-family: MS Shell Dlg; font-size: 8pt;}; </style>;
- <SCRIPT DEFER>;
- <!--
- function _CloseOnEsc() {if (event.keyCode == 27) { window.close(); return; }}
- document.body.onkeypress = _CloseOnEsc;
- //-->;
- </SCRIPT>;
- <SCRIPT>;
- function openword (){
- var pathlength = document.all.filepath.value.length - 4;
- var pathisdoc = document.all.filepath.value.lastIndexOf(".doc");
- if (pathlength !== pathisdoc){
- alert ("您选择的不是一个 Microsoft Word 文档.\n它的扩展名必须是 .doc");
- }
- else {
- var file = unescape( document.set.filepath.value )
- var word
- try {
- word=new ActiveXObject('Word.Application.9') // word 2k
- } catch (e) {
- try {
- word=new ActiveXObject('Word.Application.8') // word 97
- } catch (e) {
- try {
- word=new ActiveXObject('Word.Application.7') // word 95
- } catch (e) {
- }
- }
- }
- //WordPad.Document
- //word.Visible=true;
- word.Documents.Open(file);
- word.Documents(file).Range(0).Copy();
-
- //word.ActiveDocument.SaveAs("H:\Mydoc.doc", 4);
- //word.Options.PrintBackground = false;
- //word.ActiveDocument.PrintOut();
- word.Quit();
- window.close();
- }
- }
- </SCRIPT>;
- </head>;
- <body style="background: threedface; color: windowtext;" margin: 30px; >;
- <FORM METHOD="post" NAME="set" ID="set">;
- ;&&<IMG SRC="../images/ed_word.gif" ALT="" WIDTH="18" HEIGHT="18" BORDER="0" ALIGN="absmiddle">;打开一个 Word& 文档
- <DIV ALIGN="center">;<INPUT TYPE="file" NAME="filepath" SIZE="30">;
- <P>;<INPUT TYPE="button" NAME="btnOK" VALUE="Open" onclick="openword();">;&&<INPUT TYPE="button" NAME="Cancel" VALUE="退出" onclick="window.close();">;</DIV>;
- </FORM>;
- </body>;
- </html>;
复制代码 |
|