首页 > 开发 > JS > 正文

JS实现获取word文档内容并输出显示到html页面示例

2024-05-06 16:45:01
字体:
来源:转载
供稿:网友

本文实例讲述了html">JS实现获取word文档内容并输出显示到html页面。分享给大家供大家参考,具体如下:

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Title</title>  <script>    var w = new ActiveXObject('Word.Application');    var docText;    var obj;    if(w != null) {      w.Visible = true;      obj = w.Documents.Open("D://word//go.doc");      docText = obj.Content;      w.Selection.TypeText("Hello");      w.Documents.Save();      document.write(docText);//Print on webpage      /*The Above Code Opens existing Document       set w.Visible=false       */      /*Below code will create doc file and add data to it and will close*/      w.Documents.Add();      w.Selection.TypeText("Writing This Message ....");      w.Documents.Save("D://word//go.doc");      w.Quit();      /*Don't forget       set w.Visible=false */    }  </script></head><body></body></html>

注意:这里使用了ActiveXObject组建,因此需要使用IE内核浏览器运行本代码。

希望本文所述对大家JavaScript程序设计有所帮助。


注:相关教程知识阅读请移步到JavaScript/Ajax教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表