WebOffice-开发文档 下载本文

内容发布更新时间 : 2024/12/23 6:55:15星期一 下面是文章的全部内容请认真阅读。

标记

名称: 状态: 部门: 文档ID:

WebOffice 文档控件

开发文档

WebOffice开发文档 发布 研发部

WebOffice-01-001

目 录

一、工作原理.................................................................................................................. 5

1.1 开发流程 .................................................................................................... 5 1.2 WEB页面调用控件: .................................................................................... 6 二、接口说明.................................................................................................................. 7

2.1 接口 ........................................................................................................... 7

2.1.1 AboutBox.............................................................................................. 7 2.1.2 AcceptAllRevisions ............................................................................ 7 2.1.3 AddMenu ............................................................................................... 7 2.1.4 BookMarkOpt ........................................................................................ 7 2.1.5 CloseDoc.............................................................................................. 8 2.1.6 ConvertToAip....................................................................................... 8 2.1.7 CreateApp ............................................................................................ 8 2.1.8 DelLocalFile....................................................................................... 9 2.1.9 DownLoadFile....................................................................................... 9 2.1.10 ExcProtectSharing ....................................................................... 9 2.1.11 ExcUnprotectSharing ................................................................. 10 2.1.12 FtpConnect ................................................................................. 10 2.1.13 FtpDisConnect ............................................................................ 10 2.1.14 FtpGetFile ................................................................................. 10 2.1.15 GetDocumentObject ......................................................................11 2.1.16 GetFieldValue ............................................................................ 12 2.1.17 GetTempFilePath ........................................................................ 12 2.1.18 GetRevCount ............................................................................... 12 2.1.19 GetRevInfo ................................................................................. 13 2.1.20 GetFileSize ............................................................................... 14 2.1.21 GetBookMarkCount....................................................................... 14 2.1.22 GetBookMarkInfo ........................................................................ 14 2.1.23 HideMenuItem.............................................................................. 15 2.1.24 HideMenuAction .......................................................................... 15 2.1.25 HttpInit..................................................................................... 16 2.1.26 HttpAddPostFile ........................................................................ 16 2.1.27 HttpAddPostBuffer ..................................................................... 17 2.1.28 HttpAddPostValue....................................................................... 17 2.1.29 HttpAddPostString ..................................................................... 17 2.1.30 HttpAddPostCurrFile ................................................................. 17 2.1.31 HttpAddPostCurrFile2................................................................ 18 2.1.32 HttpPost..................................................................................... 18 2.1.33 InsertFile ................................................................................. 18 2.1.34 IsOpened..................................................................................... 19

2.1.35 IsSaved ...................................................................................... 20 2.1.36 InsertFile ................................................................................. 20 2.1.37 LoadOriginalFile....................................................................... 21 2.1.38 OpenFileDlg ............................................................................... 21 2.1.39 ProtectDoc ................................................................................. 21 2.1.40 PrintDoc..................................................................................... 22 2.1.41 PutSaved..................................................................................... 22 2.1.42 ReplaceText ............................................................................... 23 2.1.43 Save............................................................................................ 23 2.1.44 SaveTo ........................................................................................ 23 2.1.45 SaveAs ........................................................................................ 23 2.1.46 SaveAsPDF ................................................................................... 24 2.1.47 SetFieldValue ............................................................................ 24 2.1.48 SetPageAs ................................................................................... 25 2.1.49 SetTrackRevisions ..................................................................... 26 2.1.50 ShowRevisions ............................................................................ 26 2.1.51 SetCurrUserName ........................................................................ 26 2.1.52 SetToolBarButton2 ..................................................................... 26 2.1.53 SetCurrTime ............................................................................... 28 2.1.54 SetKeyCtrl ................................................................................. 28 2.1.55 SetSecurity ............................................................................... 28 2.1.56 ShowDialog ................................................................................. 29 2.1.57 SetValue..................................................................................... 29 2.1.58 SetDocVariable .......................................................................... 30 2.1.59 UnProtectDoc(BSTR strPwd) ....................................................... 30 2.1.60 ZipFile ...................................................................................... 31 2.1.61 GetBMPos..................................................................................... 31 2.1.62 LocalProtect.............................................................................. 31 2.1.63 UnActiveExcel() ........................................................................ 32 2.1.64 HideMenuArea.............................................................................. 32 2.1.65 SetCustomColour ........................................................................ 32 2.1.66 SetCustomToolBtn....................................................................... 33 2.1.67 GetFileBase64 ............................................................................ 34 2.1.68 SaveBinaryFileFromBase64......................................................... 34 2.1.69 SetWindowText ............................................................................ 34 2.2 属性 ......................................................................................................... 35

2.2.1 DocType ............................................................................................. 35 2.2.2 Version ............................................................................................. 35 2.2.3 AppVersion ........................................................................................ 35 2.2.4 lEventRet .......................................................................................... 35 2.2.5 IsModify............................................................................................ 36 2.2.6 ShowToolBar ...................................................................................... 36 2.2.7 OptionFlag ........................................................................................ 36 2.2.8 Is2007 ............................................................................................... 37

2.2.9 lContinue .......................................................................................... 37 2.3 事件 ......................................................................................................... 37

2.3.1 NotifyWordEvent ............................................................................... 37 2.3.2 NotifyCtrlReady ............................................................................... 38 2.3.3 NotifyToolBarClick .......................................................................... 38

三、ASP例子说明 ......................................................................................................... 40

3.1 Access数据库结构 .................................................................................. 40 3.2 演示程序主要页面说明 ............................................................................ 40 3.3 开发必读 .................................................................................................. 40 四、FAQ ......................................................................................................................... 41

4.1 如何把文件直接上传到服务器 ....................................................................... 41 五、附录 ....................................................................................................................... 42

5.1 WebOffice文件Http上传原理 ...................................................................... 42 5.1 如何自定义工具栏.............................................................错误!未定义书签。

一、工作原理

WebOffice是基于客户端的ocx控件,它的功能是将Office文档(Word、Excel、WPS)嵌入到浏览器中,并调用Office中各种接口,完成文档编辑工作,然后使用控件的Http接口模拟表单提交,发送到数据处理页面(此文档举例为saveDoc.asp页,代码见演示文件),完成文档的存档工作。

1.1 开发流程

├ 装载控件 ... ├ 触发初始化方法

├ 执行初始化方法,打开新文档或装载已经存在的文档

function WebOffice1_NotifyCtrlReady() {

document.all.WebOffice1.LoadOriginalFile(\, \); }

├ 根据当前步骤,来决定是否进入修订状态,如果是修订状态,最好设置当前的用户名

function WebOffice1_NotifyCtrlReady() {

document.all.WebOffice1.LoadOriginalFile(\, \); document.all.WebOffice1.SetCurrUserName(\张三\ document.all.WebOffice1.SetTrackRevisions(1); }

├ 填写表单元素,编辑Office文档

├ 执行Http上传接口保存表单元素和Office文档

//保存文档之前,如果需要接受修订,需要调用 document.all.WebOffice1.SetTrackRevisions(4); //通过Http接口上传

document.all.WebOffice1.HttpInit();

document.all.WebOffice1.HttpAddPostString(\ \ document.all.WebOffice1.HttpAddPostCurrFile(\, \); document.all.WebOffice1.HttpPost(\

├ saveDoc.asp获取表单数据和Office进行数据库操作,并返回操作是否正确。 ├ 根据saveDoc.asp返回值进行相应操作。