




已阅读5页,还剩23页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
synchroocx控件用户手册目 录1.功能介绍31.1.环境要求及使用注意事项31.2.功能简介31.3.框架描述42.控件安装42.1.synchroocx 的安装要求42.2.synchroocx 控件的本地安装42.3.synchroocx在线安装52.3.1.安装方法52.3.2.注意事项53.控件属性介绍73.1.borderstyle73.2.titlebarcolor83.3.titlebartextcolor83.4.menubar83.5.bordercolor83.6.backcolor93.7.toolbars93.8.activedocument94.控件接口介绍104.1.createnew104.2.open104.3.save114.4.httpinit114.5.httpaddpoststring id value114.6.httpaddpostcurrfile fileid filename124.7.httppost124.8.settrackrevisions124.9.showrevisions134.10.setcurrusername134.11.setcurrtime134.12.setfieldvalue134.13.setmenudisplay(int value)144.14.protectdoc154.15.insertfile154.16.showview164.17.saveas164.18.grammercheck164.19.chglayout174.20.showdialog174.21.closedoc184.22.printout184.23.sendmail185.一个使用控件的例子181. 功能介绍本章主要介绍synchroocx的环境要求以及一些功能和性能的特征。通过阅读本章内容,您可以对synchroocx的基本功能和安装环境有个大体的了解。1.1. 环境要求及使用注意事项正确运行本控件需要客户机安装windows98及以上操作系统,internet explorer 5.0及以上版本,以及正确安装microsoft office 97以上版本。在第一次使用控件的时候需要调整一下浏览器的安全设置,以便能正确安装。调整方法以ie6.0为例说明如下:浏览器菜单栏-工具-internet选项-安全-自定义级别。将“对没有标记为安全的activex控件进行初始化和脚本运行”和“下载未签名的activex控件”两项启用。待控件安装完以后可恢复浏览器的安全级别默认设置。通过以上方法仍然未能下载并安装控件,可能原因是你的防火墙阻止了控件的安装,采取的方法是改变防火墙设置,在你本机有控件的情况下,用dos命令行的方式能注册成功,用一条命令即可:regsvr32 pathoffice.ocxpath为控件所在的本地目录,office.ocx为控件的名称。1.2. 功能简介synchroocx控件对msoffice一些复杂功能进行了包装,使其满足不同客户的需求。控件提供的接口,能够帮助开发人员按照业务的需求,自定义在线office操作。除对msoffice进行了包装以外,synchroocx 控件还提供了其他的一些功能,如在线编辑、上传文档、支持发布为html、支持从本地或服务器url获取文档模板、支持插入本地图片、支持插入远程图片。在性能方面,由于使用c语言直接开发com接口,简洁高效,对内核函数的直接调用使得无需其它动态链接库的支持,兼容性极好;在下载和上载office文档时不会产生临时文件;不会引起防病毒软件和防火墙的安全警告。1.3. 框架描述客户端客户端web编辑页面表单数据office文档数据标准数据传输自定义文档数据传输数据库系统或文件系统服务器端图 1-1 控件工作原理图2. 控件安装2.1. synchroocx 的安装要求正确运行本控件需要客户机安装windows98及以上操作系统,internet explorer 5.0及以上版本,以及正确安装microsoft office 97以上版本。2.2. synchroocx 控件的本地安装控件的本地安装非常简单,前提是本地计算机上必须要有控件的安装程序或控件的打包程序。可以通过命令行的方式完成控件的注册(安装)。第一步、打开dos命令行窗口第二步、输入命令 regsvr32 pathxx.ocxpath为控件包所在的windows目录,xx.ocx为控件包的名称当然也可以通过windows的开始菜单,运行命令。在运行窗口里输入regsvr32然后用鼠标拖动xx.ocx到运行窗口,点击确定即可完成注册。2.3. synchroocx在线安装2.3.1. 安装方法所谓在线安装,意思是在打开浏览器的时候由浏览器负责从服务器上下载控件并自行安装。因此,我们要做的事前就是把控件放在服务器的目录下,在网页脚本标签里面引用控件即可,如下所示: 2.3.2. 注意事项在线安装过程中浏览器会阻止控件的安装,如图2-1所示:图2-1这时候,我们需要做的是暂时降低浏览器的安全级别,当控件安装成功后可以恢复浏览器的默认安全级别,控件在以后使用中浏览器将不会再有安全警告,可正常使用。修改浏览器安全级别的步骤:选择浏览器工具菜单,打开internet 选项对话框,点击安全页,自定义级别。将涉及activex选项都设为启用,确保activex控件自动提示、对标记为安全的activex控件执行脚本、对没有标记为安全的activex控件进行初始化和脚本运行、下载未签名的activex控件、下载已签名的activex控件、运行activex控件和插件为启用。设置完成后刷新页面,点击弹出窗口的是按钮,控件就会自动安装。如图2-2所示。图2-2详见安装盘内的synchroocx控件安装手册。3. 控件属性介绍本章中主要介绍synchroocx 控件提供的一些office文档属性,开发人员可以在自己的web应用开发过程中,通过这些属性的设置,来定制个性化的office文档操作,使控件按照开发人员的意愿工作,从而提高业务效率。3.1. borderstyle设置边框样式,如: 3.2. titlebarcolor设置标题栏颜色,如:3.3. titlebartextcolor设置标题栏文字的颜色,如: 3.4. menubar设置菜单栏状态(每次调用都会显示或隐藏)。例子:sub togglemenubar() dim x on error resume next x = synoffice.menubar synoffice.menubar = not x synoffice.activate end sub3.5. bordercolor设置边框颜色,如: 3.6. backcolor设置背景颜色,如: 3.7. toolbars设置工具栏的显示状态。例子:显示/隐藏工具栏 sub toggletoolbars() dim x on error resume next x = synoffice.toolbars synoffice.toolbars = not x end sub3.8. activedocument此属性为熟悉vba编程的人员提供一个开发接口,编程人员可以利用此属性简化office操作。例子:(插入本地或者远程图片)sub insertpicdim spath on error resume next spath=inputbox(插入图片,输入文件的本地或远程路径)document.all.synoffice.activedocument.inlineshapes.addpicture spath,false,true end sub4. 控件接口介绍本章主要介绍synchroocx提供的接口,利用这些接口,开发人员可以在编辑动态网页的过程中,很好的控制synchroocx的行为。4.1. createnew新建一个文档。例子(创建一个空的word文档):sub newdoc() on error resume next document.all.synoffice.createnew word.document if err.number then msgbox 无法新建文档: & err.description end if end sub建立一个空的excel文档:document.all.framercontrol1.createnew excel.sheet4.2. open按照提供的路径打开一个本地或远程文档。例子(打开一个远程文档):sub openwebdoc() dim surl on error resume next surl = inputbox(请输入文档所在的url地址., ,http:/server/folder/test.doc) if len(surl) then document.all.synoffice.open surl, true, word.document ,myuseraccount,mypassword if err.number then msgbox 无法链接到指定的url: & err.description end if end if end sub打开本地文件:document.all.synoffice.open(c:testbook.xls);参数说明:surl为本地文件位置或者文件在web上的url路径;true:表示文件以read and write方式打开,当为false是文件以只读方式打开;如果有权限,可以解除文档保护。4.3. save保存文档到本地。用法:document.all.synoffice.save c:1.doc,true第二个参数表示是否要覆盖原先版本的文件。true表示覆盖。4.4. httpinit初始化http引擎本接口为上传文件初始化http引擎,没有参数。他通常与后面要介绍的httpaddpoststring、httpaddpostcurrfile、httppost一起使用。4.5. httpaddpoststring id valueid为客户添加的字符串id,value为字符串的值4.6. httpaddpostcurrfile fileid filenamefileid表示上传文件的id值,filename 为要上传得文件的名字。4.7. httppost 参数表示执行上传的动态页面,upload.jsp将执行验证用户的身份及添加的字符串,并执行上传。4、5、6、7接口上传文件的例子:function savedoc() document.all.synoffice.httpinit/ 初始化http引擎/ 添加相应的post元素 document.all.synoffice.httpaddpoststringusername webform.username.value/ 添加上传文件document.all.synoffice.httpaddpostcurrfile file ,/ 提交上传文件document.all.synoffice.httppost ./savedoc.jsp4.8. settrackrevisions设置修订状态参数intvalue表示修订的不同状态,当intvalue=1时,进入记录修订状态,当为0时表示取消修订状态,当为2时表示接受全部修订。例子:function settrackrevisions(ss)on error resume next if not bdocopen then /判断文档是否已经打开 msgbox 请先打开文档然后再操作. else document.all.synoffice.settrackrevisions ss end ifend function4.9. showrevisions brevision等于1时,显示修订,当为0时,隐藏修订。 例子: sub showrevisions(s) on error resume next if not bdocopen then/判断文档是否已经打开 msgbox 请先打开文档然后再操作. else document.all.synoffice.showrevisions s end if end sub4.10. setcurrusername设置当前用户。例子:document.all.synoffice.setcurrusername 张三4.11. setcurrtime设置当前时间(笔迹留痕会显示(like 2006:12:17 11:11:11)。例子:document.all.synoffice.setcurrtime 2006:02:07 11:11:114.12. setfieldvalue设置和创建书签。例子:/设置和创建书签,设置书签数据、添加书签和添加红头文件setfieldvalue strfieldname, strvalue, strcmdorsheetnamestrfieldname:书签名strvalue:要设置的值strcmdorsheetname:命令 :addmark: :file:一般来说:word中书签是做好的,可以通过此接口把外界数据设置进书签中去。/在当前word位置插入标签,标签名为book1,数值为testdocument.all.synoffice.setfieldvaluebook1,test,:addmark:/设置书签time,数值为2006-03-16 22:22:22document.all.synoffice.setfieldvaluetime,2006-03-16 22:22:22,/在书签位置hongtou,插入红头文件http:/ localhost:8080/hongtou1.doc 这样,红头就自动插进去了document.all.synoffice.setfieldvalue synchroocx,http:/localhost:8080/hongtou1.doc,:file:4.13. setmenudisplay(int value)设置菜单显示情况。例子:/只有“新建”菜单可用 document.all.synoffice.setmenudisplay(1)/只有“打开”菜单可用 document.all.synoffice.setmenudisplay(2)/只有“打开”和“新建”菜单可用 document.all.synoffice.setmenudisplay(3)4.14. protectdoc保护文档和解保护文档。例子:/完全保护文档,密码为pwd document.all.synoffice.protectdoc 1,1,pwd/解除文档保护 document.all.synoffice.protectdoc 0,1,pwd第一个参数取1:表示保护文档第一个参数取0:表示解除保护第二个参数取1:表示完全保护文档第二个参数取0:表示以记录修订的方式保护文档第三个参数为保护文档的密码4.15. insertfile 从本地或远程将一个文档插入到当前文档的某一个位置。例子:sub insertfile(a) on error resume next if not bdocopen then/判断文档是否已经打开 msgbox 请先打开文档然后再操作. else document.all.synoffice.insertfile inputbox(请输入文档的web地址, ,), a end if end sub当a取不同的值时分别表示插入不同的位置a=0时表示:插入当前文档的当前位置a=1时表示:插入当前文档的头部a=2时表示:插入当前文档的尾部4.16. showview设置文档浏览模式例子:showview(long dwviewtype)dwviewtype表示不同的文档浏览模式4.17. saveas将当前文档保存为不同格式的页面。根据intvalue的值设定文档的保存方式。关于更多文档类型详细的信息请参阅office自动化相关文档。例子:/将文档保存为html格式document.all.synoffice.saveas 8/将文档保存为txt格式document.all.synoffice.saveas 24.18. grammercheck语法检,对当前文档进行语法检查。例子:sub grammercheck() on error resume next if not bdocopen then/判断文档是否已经打开 msgbox 请先打开文档然后再操作. else document.all.synoffice.activedocument.checkgrammar end if end sub4.19. chglayout页面布局设置例子:sub chglayout() on error resume next synoffice.showdialog 5 dsodialogpagesetupend sub4.20. showdialog可以通过此接口,打开office提供的基本对话框,参数表示对话框类型,例子1(打开页面设置对话框设置页面布局)。sub chglayout() on error resume next synoffice.showdialog 5 end sub例子2(设置文档属性)sub docproperty() on error resume next document.all.synoffice.showdialog 6 end sub0新建文档对象1打开文档2另存为3另存为4打印5页面布局设置6文档属性4.21. closedoc关闭当前文档。例子:sub closedoc() synoffice.closeend sub4.22. printout打印当前文档sub printdoc() on error resume next synoffice.printout trueend sub4.23. sendmail作为邮件发送。例子:sub sendmail() on error resume next document.all.synoffice.activedocument.sendmailend sub5. 一个使用控件的例子本章主要介绍如何在web应用中使用控件,在本章的例子中,涉及到了synchroocx控件提供的大部分方法和属性的用法,可供开发者参考。本例是一个用脚本语言vbscript实现的例子,用户可以根据自己的情况选择不同的脚本语言来实现,实现方法相同。安装盘中(产品演示目录下)提供了实例程序,用户可直接部署使用。例子:synchroocx office control ocx test作为文档是否打开的标示dim bdocopen sub synoffice_ondocumentopened(str, obj) dim s, s2 on error resume next bdocopen = true if len(str) = 0 then str = new document else dim x x = instr(str, ) if x then do str = mid(str, x+1) x = instr(str, ) loop while x 0 else x = instr(str, /) if x then do str = mid(str, x+1) x = instr(str, /) loop while x 0 end if end if end if s = obj.application.name if len(s) = 0 then s = unknown server document.all.tstat.innerhtml = file: & str & server: &s end sub sub synoffice_ondocumentclosed() bdocopen = false document.all.tstat.innerhtml = try another file. end sub新建一个文档 sub newdoc() on error resume next synoffice.showdialog 0 dsodialognew if err.number then msgbox 无法新建文档: & err.description end if end sub打开本地文档 sub opendoc() on error resume next document.all.synoffice.showdialog 1 if err.number then msgbox 无法打开文档: & err.description end if end sub打开web文档 sub openwebdoc() dim surl on error resume next surl = inputbox(请输入文档所在的url地址., ,http:/server/folder/test.doc) if len(surl) then synoffice.open surl, true if err.number then msgbox 无法链接到指定的url: & err.description end if end if end sub保存文档 sub savecopydoc() dim sfile dim spost dim binit dim bpost on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else sfile = inputbox(请输入要保存的文档的名字.,save ,mydoc.doc) spost= binit = document.all.synoffice.httpinit document.all.synoffice.httpaddpoststring recordid,20060102200 document.all.synoffice.httpaddpoststring userid,lisi document.all.synoffice.httpaddpostcurrfile filedata, sfile document.all.synoffice.httppost spost+uploadfile.jsp end if end sub sub chglayout() on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else synoffice.showdialog 5 dsodialogpagesetup end if end sub打印文档 sub printdoc() on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else synoffice.printout true end if end sub显示文档属性sub docproperty() on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else document.all.synoffice.showdialog 6 end if end sub插入文本到文档sub insertfile(a) on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else document.all.synoffice.insertfile inputbox(请输入文档的web地址, ,), a end if end sub显示/隐藏修订留痕sub showrevisions(s) on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else document.all.synoffice.showrevisions s end if end sub修订留痕function settrackrevisions(ss)on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else document.all.synoffice.settrackrevisions ss end ifend function 保护文档sub protectfile(s) on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else document.all.synoffice.protectdoc s,1, inputbox(请输入密码, ,在此输入密码) end if end sub关闭文档 sub closedoc() on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else synoffice.close end if end sub保存为htmlsub saveashtml(s) on error resume next if not bdocopen then msgbox 请先打开文档然后再操作. else document.all.synoffice.activedocument.saveas inputbox(请输入文档的web地址,save as html ,),s,false end if end sub显示/隐藏标题栏 sub toggletitlebar() dim x on error resume next x = synoffice.titlebar synoffice.titlebar = not x end sub显示/隐藏工具栏 sub toggletoolbars() dim x
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年初级软件测试技术实战教程与案例分析
- 临床老师教学规范课件
- 2025年汽车维修技师考试题库及答案集
- 2025年物业管理高级考试备考指南及模拟题答案
- 药事管理与药物治疗学委员会工作制度
- 甲状腺疾病护理课件
- 甲状腺滤泡课件
- 物流管理专业毕业设计
- 中文教学课件新年
- 甲流乙流课件
- 浙江省镇海中学高三一诊考试新高考物理试卷及答案解析
- JT-T-155-2021汽车举升机行业标准
- 化妆品质量意识培训大纲
- 2024年专业技术人员继续教育公需科目-低碳经济笔试参考题库含答案
- 八下单词表(Unit 1-10)大全
- YS-T 650-2020 医用气体和真空用无缝铜管
- JC-T 564-2000 纤维增强硅酸钙板
- 《建筑装饰工程质量检验与检测》课程标准
- PVC地胶板施工工艺流程图文
- 《数学分析》课件
- 子宫内膜息肉教学查房
评论
0/150
提交评论