WebOffice正式版
前期准备
在开始之前您需要确定两件事:
第一件:您已学习《WebOffice入门教程一:Hello Word!》,并已实际动手实践成功完成此教程的全部内容。
第二件:您要确定好需要使用哪个脚本语言及相关环境,如果使用JAVA,请确保Java与之相关Web服务器已搭建并能正常执行相应脚本,同样如果是php,c#,asp等也要确认与之相关Web服务器已搭建并能正常执行相应脚本。
使用方法
1、建立本示例目录
(1)在C盘新建名为WebOfficeSave目录,如果是TOMCAT或PHP等的相关服务器,也可以把此文件夹直接建立在对应的站点发布根目录下,如Tomcat可以是:C:TomcatwebappsWebOfficeSave
(2)拷入《WebOffice入门教程:Hello World!》里所生产的 index.html和edit.html
2、确定能够以Web方法运行本示例文件
(1)确定C:WebOfficeSave 或 C:TomcatwebappsWebOfficeSave为可运行的Web服务器目录,如设置名为:WebOffice,则访问index.html可以用如下地址:
http://localhost/weboffice/index.html 或 http://127.0.0.1/weboffice/index.html 也可以是 http://127.0.0.1:8080/weboffice/index.html
Tomcat如果是C:TomcatwebappsWebOfficeSave,则访问的地址应是:http://127.0.0.1:8080/WebOfficeSave/index.html 或 http://127.0.0.1/WebOfficeSave/index.html 等等,这些都是服务器相关知识,可以参考 络相关教程。 如果使用Tomcat等服务器,此教程以下内容的http://localhost/weboffice 应改为: http://127.0.0.1/WebOfficeSave/index.html 或 http://127.0.0.1:8080/WebOfficeSave/index.html 或 http://localhost/WebOfficeSave/index.html 具体情况请以你本机地环境决定。目的只有一个,即是可以通过WEB方式访问到本示例的index.html,为接下来打开控件页面作好准备工作。
请确保上面地址能正确打开index.html 页,并看到效果如下:
(2)修改index.html
用记事本打开index.html代码,将下面语句:
<a href="WebOffice://|Officectrl|file:///C:/WebOfficeTest/edit.html">查看</a>
里的路径修改为:
<a href="WebOffice://|Officectrl|http://localhost/weboffice/edit.html">查看</a>
即将edit.html文件所在的WebOfficeTest目录改为本示例可运行的Web路径
修改完成后再次刷新打开index.html页后点击查看链接,将提示:“弹出对话框是否同意启动应用”
请选择同意:启动应用,如果一切顺利将会启动智能窗打开edit.html,如下图:
3、设计保存按钮
用记事本打开edit.html代码,在<input type=button onclick=”” value=”打开”></div>代码之后,</div>标签之前,加入下面代码
<input type=button onclick=”OpenSave();” value=”保存”>
执行完成后,edit.html的代码如下:
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"><title></title></head><script language="javascript">function OpenDoc(){//取得WebOffice对象var WebOffice=document.getElementById("WebOffice");//通过对象WebOffice的Open方法打开个一个服务器文档//此处服务器文档地址为:http://www.officectrl.com/officecs/temp/file1.docWebOffice.Open("http://www.officectrl.com/officecs/temp/file1.doc",false,"Word.Document");}</script><body><div><input type=button onclick="OpenDoc();" value="打开"><input type=button onclick="OpenSave();" value="保存"></div><script language="javascript">if (!!window.ActiveXObject || "ActiveXObject" in window){document.write('<object classid="clsid:FF09E4FA-BFAA-486E-ACB4-86EB0AE875D5" codebase="WebOffice.ocx#Version=2019,1,7,3" id="WebOffice" width="900" height="700" >');document.write('</object>');}else{document.write('<object id="WebOffice" CLSID="{FF09E4FA-BFAA-486E-ACB4-86EB0AE875D5}" TYPE="application/x-itst-activex" width=100% height=900></object>');}</script></body></html>
以上代码 WebOffice.Open(“http://www.officectrl.com/officecs/temp/file1.doc”,false,”Word.Document”);
也可以改成您本地方式的地址打开如:
WebOffice.Open(“http://locahost/file1.doc”,false,”Word.Document”);
如果 http://locahost/file1.doc 存在,则一样可以打开WORD文档。
加入保存按钮后效果如下:
未完待续……
相关内容推荐:
WebOffice 试用下载>>>
WebOffice入门教程:Hello World!(一)打开服务器文档
WebOffice入门教程:Hello World!(二)设计WebOffice控件加载页
WebOffice入门教程:Hello World!(三)修改第一个WebOffice程序的文件编码
想要购买WebOffice正版授权,或了解更多产品信息请点击【咨询在线客服】
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!