翻譯|使用教程|編輯:楊鵬連|2021-06-09 14:11:09.390|閱讀 399 次
概述:本文檔全面介紹WEB前端如何集成WebOffice控件,通過Javascript編程實現(xiàn)控件功能接口的調(diào)用,達到解決Web項目需求的目的,掌握此前端設(shè)計后將會理解WebOffice以View層的解決方案從而適合任意Web項目架構(gòu)。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
WebOffice控件是國內(nèi)領(lǐng)先的在線編輯Office文檔軟件,軟件產(chǎn)品從1998年立項至今已有20多年歷史,期間服務(wù)了眾多大中小型企業(yè)、各級政府機關(guān)、科研機構(gòu)和學(xué)校等事業(yè)單位。通過WebOffice軟件可以讓用戶方便從遠程直接打開Word,Excel,Ppt等文檔編輯后再次保存至服務(wù)器原位置,實現(xiàn)遠程編輯文檔、遠程保存,為用戶在線辦公開創(chuàng)新式、便捷的使用體驗。
WebOffice文檔控件(標準版永久授權(quán))原價8000元,現(xiàn)活動優(yōu)惠價只需7846元 >>查看其他版本
相關(guān)內(nèi)容推薦:
WebOffice使用教程:WebOffice常用API接口在線參考手冊(一)>>>
WebOffice使用教程:WebOffice常用API接口在線參考手冊(二)>>
WebOffice使用教程:WebOffice常用API接口在線參考手冊(三)>>
WebOffice使用教程:WebOffice常用API接口在線參考手冊(四)>>
WebOffice初學(xué)者使用教程:Javascript編程原理(一)>>
WebOffice初學(xué)者使用教程:宏編程與JavaScript編碼的轉(zhuǎn)換>>
WebOffice初學(xué)者使用教程:調(diào)用WebBrowser智能窗實現(xiàn)跨瀏覽器
五、常用功能函數(shù)使用
5.1、JavaScript控制文件菜單
/*************************************************************************使用SetSecurity(lFlag)接口實現(xiàn)文件菜單控制
lFlag的值參考如下:
新建 MNU_NEW 1
打開 MNU_OPEN 2
關(guān)閉 MNU_CLOSE 4
保存 MNU_SAVE 8
另存為 MNU_SAVEAS 16
打印 MNU_PRINT 32
頁面設(shè)置 MNU_PGSETUP 64
屬性 MNU_PROPS 128
如果不允許上面哪個功能,則用255減去對應(yīng)值即可,可以累減實現(xiàn)幾個功能的不允許
****************************************************************/
PrintNot 不允許打印
function PrintNot() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(215); //不允許打印和保存
}
PrintYes 恢復(fù)打印許可
function PrintYes() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(247);//允許打印和不充許保存
}
SaveNot 不允許保存
function SaveNot() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(247);
}
SaveYes 允許保存
function SaveYes() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(255);
}
CreateNewNot 不允許新建
function CreateNewNot() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(254);
}
CreateNewYes 允許新建
function CreateNewYes() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(255);
}
OpenNot 不允許打開
function OpenNot() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(253);
}
OpenYes 允許打開
function OpenYes() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(255);
}
CloseNot 不允許關(guān)閉
function CloseNot() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(251);
}
CloseYes 允許關(guān)閉
function CloseYes() {
var WebOffice=document.getElementById("WebOffice");
WebOffice.SetSecurity(255);
}
5.2、控件界面控制
設(shè)置標題欄顯示或隱藏
function setTitlebar(boolvalue) {
var WebOffice=document.getElementById("WebOffice");
WebOffice.Titlebar = boolvalue;
}
設(shè)置菜單顯示或隱藏
function setMenubar(boolvalue) {
var WebOffice=document.getElementById("WebOffice");
WebOffice.MenuBar = boolvalue;
}
設(shè)置工具欄顯示或隱藏
function setToolbar(boolvalue) {
var WebOffice=document.getElementById("WebOffice");
WebOffice.Toolbars = boolvalue;
}
控件界面標題欄和控件邊框色彩自定義
function WebFace()
{
WebOffice.BorderColor = 250*256*256+230*256+230; //里面數(shù)值可以按需調(diào)整
WebOffice.ForeColor = 236*256*256+226*256+225;
WebOffice.TitlebarColor = 181*256*256+151*256+153;
}
5.3、新建、打開、保存
新建WORD文檔
document.getElementById('WebOffice').CreateNew("Word.Document");
新建EXCEL文檔
document.getElementById('WebOffice').CreateNew("Excel.Sheet");
新建PPT文檔
document.getElementById('WebOffice').CreateNew("PowerPoint.Show");
打開本地文檔
document.getElementById("WebOffice").Open("c:\\a.doc");
保存本地文檔
document.getElementById("WebOffice").Save("c:\\a.doc");
另保存本地文檔
document.getElementById("WebOffice").ActiveDocument.SaveAs("c:\\a.doc")
打開服務(wù)器文檔
document.getElementById("WebOffice").Open("http://www.officectrl.com/officecs/temp/word.doc",true,"Word.Document");
打開服務(wù)器文檔
document.getElementById("WebOffice").WebLoadFile("http://www.officectrl.com/officecs/temp/word.doc","xls");
Save方法保存服務(wù)器文檔
//strSaveUrl為服務(wù)器端腳本程序用于接收上傳過來的二進制文檔數(shù)據(jù)并保存
var strSaveUrl=//www.officectrl.com/officecs/upload.jsp?id=1
document.getElementById('WebOffice').Save(strSaveUrl);
HttpPost方法保存服務(wù)器文檔,仿瀏覽器表單上傳文件方式
var strSaveUrl=//www.officectrl.com/officecs/post.jsp?id=1
document.getElementById("WebOffice").HttpInit();
document.getElementById("WebOffice").HttpAddPostCurrFile("docfile", ""); //執(zhí)行此句會將當(dāng)前編輯的文檔讀取到待上傳文件列表
document.getElementById("WebOffice").HttpPost(strSaveUrl); //執(zhí)行模擬表單POST上傳動作
Close 關(guān)閉文檔
document.getElementById("WebOffice").WebOffice.Close();
5.4、控件功能控制
CopyNot 不允許復(fù)制
document.getElementById("WebOffice").isNotCopy=1;
CopyYes 允許復(fù)制
document.getElementById("WebOffice").isNotCopy=0;
下載文檔
var WebOffice=document.getElementById("WebOffice");
WebOffice.DownloadFile(‘URL文檔路徑’,‘本地保存地址’);
刪除本地文檔
var WebOffice=document.getElementById("WebOffice");
WebOffice.DeleteLocalFile(‘本地地址’);
5.5、智能填充
一、設(shè)置模板上需要填充內(nèi)容的標簽document.getElementById("WebOffice").SetFieldValue('mark_1',dataValue,'::ADDMARK::');
5.6、合并文檔
光標當(dāng)前位置插入WORD文檔document.getElementById("WebOffice").InsertFile(strPath,0);
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自: