轉帖|使用教程|編輯:莫成敏|2020-04-14 14:27:18.460|閱讀 423 次
概述:WebOffice控件是國內領先的在線編輯Office文檔軟件,軟件產品從1998年立項至今已有20多年歷史,期間服務了眾多大中小型企業、各級政府機關、科研機構和學校等事業單位。本文介紹了WebOffice入門教程,Hello World!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
WebOffice控件是國內領先的在線編輯Office文檔軟件,軟件產品從1998年立項至今已有20多年歷史,期間服務了眾多大中小型企業、各級政府機關、科研機構和學校等事業單位。通過WebOffice軟件可以讓用戶方便從遠程直接打開Word、Excel、Ppt等文檔編輯后再次保存至服務器原位置,實現遠程編輯文檔、遠程保存,為用戶在線辦公開創新式、便捷的使用體驗。
本教程介紹了WebOffice打開一個服務器文檔,一共分為四個步驟:
四、設計WebOffice控件加載頁(edit.html)
1、為了讓edit.html能正確加載WebOffice,執行如下操作:
編寫html結構代碼:
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
2、引入WebOffice對象
請將如下代碼復制到edit.html代碼body標簽之后:
<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="500" >');
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>
完成后,如下
<html>
<head>
<title></title>
</head>
<body>
<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="500" >');
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>
3、設計按鈕
在edit.html代碼Body標簽之后 <script language="javascript">標簽之前加入如下代碼:
<div><input type=button onclick="" value="打開"></div>
執行完成后,edit.html的代碼如下:
<html>
<head>
<title></title>
</head>
<body><div><input type=button onclick="" 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="500" >');
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>
執行后的效果如圖:
4、調用WebOffice對象Open()方法打開文檔
為“打開”按扭增加點擊觸發JS函數:
①找到“打開”按扭代碼的onclick屬性,在雙引號里寫入如下代碼:
OpenDoc();
②增加Open()函數的的函數實現
在edit.html的</head>和<body>標簽之前加入如下代碼:
<script language="javascript">
function OpenDoc()
{
//取得WebOffice對象
var WebOffice=document.getElementById("WebOffice");
//通過對象WebOffice的Open方法打開個一個服務器文檔
//此處服務器文檔地址為://www.officectrl.com/officecs/temp/file1.doc
WebOffice.Open("http://www.officectrl.com/officecs/temp/file1.doc",false,"Word.Document");
}
</script>
執行完成以上所有步驟以后,edit.html全部代碼(用戶可把以下代碼復制粘貼到edit.html的記事本編輯器里)如下:
<html>
<head>
<title></title>
</head>
<script language="javascript">
function OpenDoc()
{
//取得WebOffice對象
var WebOffice=document.getElementById("WebOffice");
//通過對象WebOffice的Open方法打開個一個服務器文檔
//此處服務器文檔地址為://www.officectrl.com/officecs/temp/file1.doc
WebOffice.Open("http://www.officectrl.com/officecs/temp/file1.doc",false,"Word.Document");
}
</script>
<body><div><input type=button onclick="OpenDoc();" 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="500" >');
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>
5、運行測試
用瀏覽器打開index.html后,點擊查看鏈接,彈出啟動應用程序是否同意對話框選擇“同意”后,出現智能窗,在智能窗網頁點擊“打開”按鈕,如果你此時互聯網聯通,則可以正確打開 www.officectrl.com服務器上的文檔。效果如下:
本示例,如果用戶不使用互聯網文檔,用戶可以設置自已服務器地址如://localhost/test.doc
將edit.html用地址//localhost/test.doc 修改后代碼如下:
<html>
<head>
<title></title>
</head>
<script language="javascript">
function OpenDoc()
{
//取得WebOffice對象
var WebOffice=document.getElementById("WebOffice");
//通過對象WebOffice的Open方法打開個一個服務器文檔
//此處服務器文檔地址為://www.officectrl.com/officecs/temp/file1.doc
WebOffice.Open("http://localhost/test.doc",false,"Word.Document");
}
</script>
<body><div><input type=button onclick="OpenDoc();" 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="500" >');
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>
如果用戶//localhost/test.doc地址是一個正確WORD文檔的URL地址,則可以正確查看結果。
注意:WebOffice的運行不一定需要使用互聯網絡或局域網環境,WebOffice完全可以在一臺電腦上完成所有測試。因為WebOffice支持網絡B/S結構、C/S結構的一層、多層或任意層的架構運行,也支持單機版、桌面端程序運行。WebOffice采用業界標準的COM組件設計。
本教程內容尚未完結,敬請期待后續內容!您可以下載WebOffice試用版免費體驗~或者點擊下方鏈接,查看本教程示例~
相關內容推薦:
WebOffice入門教程:Hello World!(一)打開服務器文檔
想要購買WebOffice正版授權,或了解更多產品信息請點擊
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: