DSOFramer原有的接口说明
![DSOFramer原有的接口说明_第1页](https://file2.zhuangpeitu.com/fileroot2/2021-11/22/fdc3d68a-f76e-4764-97fd-633ffbcbc4df/fdc3d68a-f76e-4764-97fd-633ffbcbc4df1.gif)
![DSOFramer原有的接口说明_第2页](/images/s.gif)
![DSOFramer原有的接口说明_第3页](/images/s.gif)
《DSOFramer原有的接口说明》由会员分享,可在线阅读,更多相关《DSOFramer原有的接口说明(12页珍藏版)》请在装配图网上搜索。
1、返回当前活动文档的Dispatch接口,这个接口很重要,可以通过这个接口,操作所有的文档接口.如:下面 javascript 语句调用Office内置的对话框var obj;.声明:本文档由山东电建(sddianjian)上传到豆丁网(),若有侵害您的权益,请发站内消息。DSOFramer原有的接口说明=DSOFramer原有的接口说明1.void CreateNew(BSTR ProgIdOrTemplate) 新建文档, 其中: ProgIdOrTemplate参数:Excel Spreadsheet
2、0;"Excel.Sheet" Excel Chart "Excel.Chart" PowerPoint Presentation "PowerPoint.Show" Project Project "MSProject.Project" Visio Drawing "Visio.Drawing" W
3、ord Document "Word.Document" 2. HRESULT Open(in VARIANT Document, in, optional VARIANT ReadOnly, in, optional VARIANT ProgId, in, optional VARIANT WebUsername, in, optional VARIANT WebPassword) 打开文档,可以是本地文件或者是服务器文件参数:Document 文档路
4、径ReadOnly 是否已只读模式打开ProgId OLE类型WebUsername 用户名(访问网络的文件时候,有可能需要)WebPassword 密码例子:DsoFramer1.Open "C:TestBook.xls"DsoFramer1.Open "C:Plain.txt", , "Word.Document" /用Word来打开c:plain.txt文件DsoFramer1.Open "https:/s
5、ecureserver/test/mytest.asp?id=123", True, "Excel.Sheet", "MyUserAccount", "MyPassword"3.HRESULT Save(in, optional VARIANT SaveAsDocument, in, optional VARIANT OverwriteExisting, in, optional VARIANT
6、 WebUsername, in, optional VARIANT WebPassword);保存文件在本地DsoFramer1.Save "c:1.doc"4.Activate激活当前文档,没搞明白有什么用5. HRESULT ActiveDocument(out,retval IDispatch* ppdisp);返回当前活动文档的Dispatch接口,这个接口很重要,可以通过这个接口,操作所有的文档接口。如:下面 javascript 语句调用Office内置的对话框var obj;obj = new Object(document.all.F
7、ramerControl1.ActiveDocument);if(obj !=null)var dd;dd = obj.Application.Dialogs(84).Show();/. . /delete itdelete obj;6. HRESULT Close();关闭当前文档,建议在页面关闭的时候调用。MS的原来的版本,有时候关不掉Word,已经修复了。7. HRESULT Caption(out,retval BSTR* pbstr);属性,获取|设置窗口标题8. HRESULT Titlebar(in boolean
8、 vbool); HRESULT Titlebar(out,retval boolean* pbool); 显示或者隐藏标题栏9. HRESULT Toolbars(in boolean vbool); HRESULT Toolbars(out,retval boolean* pbool); 显示或者隐藏工具栏10. HRESULT ModalState(in boolean vbool); HRESULT ModalState(out,retval bo
9、olean* pbool);11.HRESULT ShowDialog(in dsoShowDialogType DlgType); 显示对话框12.HRESULT EnableFileCommand(in dsoFileCommandType Item, in boolean vbool); HRESULT EnableFileCommand(in dsoFileCommandType Item, out,retval boolean* pbool);13. HRESULT BorderStyle(in dsoBorderSt
10、yle style); HRESULT BorderStyle(out, retval dsoBorderStyle* pstyle);14. HRESULT BorderColor(in OLE_COLOR clr); HRESULT BorderColor(out,retval OLE_COLOR* pclr);15. HRESULT BackColor(in OLE_COLOR clr); HRESULT BackColor(out,retval OLE_COLOR* pclr);16.HRESULT
11、 ForeColor(inOLE_COLOR clr); HRESULT ForeColor(out,retvalOLE_COLOR* pclr);17.HRESULT TitlebarColor(in OLE_COLOR clr);HRESULT TitlebarColor(out,retval OLE_COLOR* pclr);18.HRESULT TitlebarTextColor(in OLE_COLOR clr); HRESULT TitlebarTextColor(out,retval OLE_COLOR* pclr);19.HRESU
12、LT ExecOleCommand(in LONG OLECMDID, in, optional VARIANT Options, in, optional VARIANT* vInParam, in, out, optional VARIANT* vInOutParam);20.HRESULT Menubar(in boolean vbool); HRESULT Menubar(out,retval boolean* pbool);21.HRESULT HostName(in BSTR bstr); HRESULT HostName(out,ret
13、val BSTR* pbstr); 22. HRESULT DocumentFullName(out,retval BSTR* pbstr); 文档的路径23.HRESULT PrintOut(in, optional VARIANT PromptUser, in, optional VARIANT PrinterName, in, optional VARIANT Copies, in, optional VARIANT FromPage, in, optional VARIANT ToPage, in, optiona
14、l VARIANT OutputFile);24.HRESULT PrintPreview(); 25.HRESULT PrintPreviewExit();26.HRESULT IsReadOnly(out,retval boolean* pbool); 是否为只读的。27.HRESULT IsDirty(out,retval boolean* pbool); 是否保存了,实际可以用来判读文档有没有修改 oframer.IsDirty = TRUE /文档没有保存,处于修改状态
15、60; oframer.IsDirty = FALSE /文档已经保存,没有修改新加的接口说明(开发接口)color=redb当前版本:V2.2.0.8 2007-02-07/b/color下载控件需要登录说明:控件未经大批量测试,难免有Bug,发现 Bug,请及时发帖或者Mail:wanhhf版本修改记录:V2.2.0.8修改: 增加了N多个事件,挺不错的东西
16、160; id(DSOF_DISPID_WORD_DocumentChange), helpstring("DSOF_DISPID_WORD_DocumentChange") HRESULT WORD_DocumentChange(); id(DSOF_DISPID_WORD_D
17、ocumentBeforePrint), helpstring("DSOF_DISPID_WORD_DocumentBeforePrint") HRESULT WORD_DocumentBeforePrint(); id(DSOF_DISPID_WORD_WindowActivate), helpstring(&quo
18、t;DSOF_DISPID_WORD_WindowActivate") HRESULT WORD_WindowActivate(); id(DSOF_DISPID_WORD_WindowSelectionChange), helpstring("DSOF_DISPID_WORD_WindowSelectionChang
19、e") HRESULT WORD_WindowSelectionChange(); id(DSOF_DISPID_WORD_WindowBeforeRightClick), helpstring("DSOF_DISPID_WORD_WindowBeforeRightClick")
20、160; HRESULT WORD_WindowBeforeRightClick(); id(DSOF_DISPID_WORD_WindowBeforeDoubleClick), helpstring("DSOF_DISPID_WORD_WindowBeforeDoubleClick")
21、160; HRESULT WORD_WindowBeforeDoubleClick();V2.2.0.6修改: 修改Open,参数为空时候,一个小 Bug 修改了URL过长时候一个Bug
22、0; 增加了一个替换文字的接口 long ReplaceText(BSTR strSearchText, BSTR strReplaceText, long lGradation);V2.2.0.2修改: 修改了HttpPost相对路径的一些问题。 V2.2.0.0
23、增加: id(0x00010041), helpstring("Get Rev Index") HRESULT GetRevCount( out,retval long * pbool);
24、id(0x00010042), helpstring("Get Rev Index Info") HRESULT GetRevInfo(in long lIndex, in long lType, out,retval BSTR* pbool); id(0x00010043), helpstrin
25、g("Set Doc Prop") HRESULT SetValue(in BSTR strValue, in BSTR strName, out,retval long* pbool); id(0x00010044), helpstring("Set Doc Variable"
26、;) HRESULT SetDocVariable(in BSTR strVarName, in BSTR strValue,in long lOpt, out,retval long* pbool); id(0x00010045), helpstring("Save page To Doc")&
27、#160; HRESULT SetPageAs(in BSTR strLocalFile, in long lPageNum, in long lType,out,retval long* pbool);-LoadDso.jsvar s = ""s += "<OBJECT id=DSOFramer align='middle' style='LEFT: 0px; WIDTH:
28、 100%; TOP: 0px; HEIGHT: 100%'"s += "classid=clsid:00460182-9E5E-11D5-B7C8-B8269041DD57 codeBase=DSOFramer.ocx#Version=2,2,0,6' >"s += "</OBJECT>"document.write(s) -接口文档:/*1.新建*/新建Worddocument.all.FramerControl1.CreateNew("Word.Document");/新建Exceld
29、ocument.all.FramerControl1.CreateNew("Excel.Sheet");/*2.打开文件*/打开制定的本地文件document.all.FramerControl1.Open("C:TestBook.xls");/制定用Word来打开c:plain.txt文件document.all.FramerControl1.Open("C:Plain.txt",false, "Word.Document");/打开服务器的文件 document.all.FramerControl1.Open
30、"https:/secureserver/test/mytest.asp?id=123",true, "Excel.Sheet", "MyUserAccount", "MyPassword");/打开服务器的文件 document.all.FramerControl1.Open("http:/localhost/1.doc", true);/*3.保存文件*/到本地document.all.FramerControl1.Save("c:1.doc",true);/服务器
31、60; /*增加Http协议Post上传接口,可以Post一个动态页面(jsp,asp,php.),由动态页面负责解析数据bool HttpInit();bool HttpAddPostString(BSTR strName, BSTR strValue);bool HttpAddPostCurrFile(BSTR strFileID, BSTR strFileName);BSTR HttpPost(BSTR bstr); */初始化Http引擎document.all.FramerControl1.Http
32、Init();/增加Post变量document.all.FramerControl1.HttpAddPostString("RecordID","20060102200");document.all.FramerControl1.HttpAddPostString("UserID","李局长");/上传打开的文件document.all.FramerControl1.HttpAddPostCurrFile("FileData", "文档名.doc");/执行上传动作docu
33、ment.all.FramerControl1.HttpPost(" /*4.修订留痕*/进入留痕状态document.all.FramerControl1.SetTrackRevisions(1);/进入非留痕状态document.all.FramerControl1.SetTrackRevisions(0);/接受当前修订document.all.FramerControl1.SetTrackRevisions(4);/*5.设置当前用户*/document.all.FramerControl1.SetCurrUserName("张三");
34、60; /*6.设置当前时间(笔迹留痕会显示("Like 2006:02:07 11:11:11")*/document.all.FramerControl1.SetCurrTime("2006:02:07 11:11:11");/*7.设置和创建书签,此功能比较强大,设置书签数据、添加书签和添加红头文件就靠他了SetFieldValue(BSTR strFieldName, BSTR strValue, BSTR strCmdOrSheetName)strFieldName:书签名strValue:要设置
35、的值strCmdOrSheetName:命令 :ADDMARK: 添加BookMark:DELMARK: 删除这个BookMark:GETMARK: 定位到这个BookMark:FILE: 插入的是文件:JPG:
36、; 插入的是图片一般来说:WORD中书签是做好的,可以通过此接口把外界数据设置进书签中去。*/在当前WORD位置插入标签,标签名为"book1",数值为"test"document.all.FramerControl1.SetFieldValue("book1","test",":ADDMARK:");/设置书签"Time",数值为"2006-03-16 22:22:22"document.all.FramerControl1.Set
37、FieldValue("Time","2006-03-16 22:22:22","");/在书签位置"hongtou",插入红头文件"http:/222.222.222.222/hongtou1.doc" 这样,红头就自动插进去了document.all.FramerControl1.SetFieldValue("hongtou","http:/222.222.222.222/hongtou1.doc",":FILE:");/*8.设置
38、菜单显示情况BOOL SetMenuDisplay(long lMenuFlag)lMenuFlag为以下数值的组合#define MNU_NEW 0x01#define MNU_OPEN
39、0;0x02#define MNU_CLOSE 0x04#define MNU_SAVE 0x08#define MNU_SAVEAS
40、160; 0x16#define MNU_PGSETUP 0x64#define MNU_PRINT
41、0;0x256#define MNU_PROPS 0x32#define MNU_PRINTPV 0x126*/只有“新建”菜单可用 document.all.FramerControl1.SetMenuDispla
42、y(1);/只有“打开”菜单可用 document.all.FramerControl1.SetMenuDisplay(2);/只有“打开”和“新建”菜单可用 document.all.FramerControl1.SetMenuDisplay(3);/*9.保护文档和解保护文档lProOrUn:1:保护文档;0:解除保护lProType: wdNoProtection = -1, wdAllowOnlyRevisions = 0, wdAllowOnlyComments = 1,
43、 wdAllowOnlyFormFields = 2strProPWD:密码*/完全保护文档,密码为"pwd" document.all.FramerControl1.ProtectDoc(1,1,"pwd");/解除文档保护 document.all.FramerControl1.ProtectDoc(0,1,"pwd");/*10.显示或隐藏
44、修订内容ShowRevisions(long nNewValue)nNewValue = 0 则隐藏修订 = 1 则显示修订*/显示修订留痕document.all.FramerControl1.ShowRevisions(1);/隐藏修订留痕document.all.FramerControl1.ShowRevisions(0);/*11.插入合并文件,strFieldPath 文件路径,可以是http,ftp的路径pPos = 0 /当前鼠标位置1;文件开头2;文件末尾pPos的第4位为1的时候,代表插入的是图片
45、InSertFile(BSTR strFieldPath, long lPos)*/文件头部插入文件document.all.FramerControl1.InSertFile("http:/XX.com/XX.doc",1);/文件尾部插入文件 document.all.FramerControl1.InSertFile("http:/XX.com/XX.doc",2);/当前光标位置插入文件document.all.FramerControl1.InSertFile("http:/XX.com/XX.doc",0);/文件头部插入
46、图片document.all.FramerControl1.InSertFile("http:/XX.com/XX.jpg",9);/文件尾部插入图片document.all.FramerControl1.InSertFile("http:/XX.com/XX.jpg",10);/当前光标位置插入图片document.all.FramerControl1.InSertFile("http:/XX.com/XX.jpg",8);/*0x31. 文档另存为
47、60; HRESULT SaveAs(in VARIANT strFileName, in VARIANT dwFileFormat, out,retval long* pbool); 参数: strFileName:文件本地路径,如c:11.doc dwFileFormat: 文件格式dwFileFormat的数值为:Excel: T
48、ypeenum XlFileFormat xlAddIn = 18, xlCSV = 6, xlCSVMac = 22, xlCSVMSDOS = 24, xlCSVWindows = 23, xlDBF2 = 7, xlDBF3 = 8, xlDBF4 = 11, xlDIF = 9, xlExcel2 = 16,
49、0; xlExcel2FarEast = 27, xlExcel3 = 29, xlExcel4 = 33, xlExcel5 = 39, xlExcel7 = 39, xlExcel9795 = 43, xlExcel4Workbook = 35, xlIntlAddIn = 26, xlIntlMacro = 25, xlWorkbookNormal = -4
50、143, xlSYLK = 2, xlTemplate = 17, xlCurrentPlatformText = -4158, xlTextMac = 19, xlTextMSDOS = 21, xlTextPrinter = 36, xlTextWindows = 20, xlWJ2WD1 = 14, xlWK1 = 5, xlWK1
51、ALL = 31, xlWK1FMT = 30, xlWK3 = 15, xlWK4 = 38, xlWK3FM3 = 32, xlWKS = 4, xlWorks2FarEast = 28, xlWQ1 = 34, xlWJ3 = 40, xlWJ3FJ3 = 41, xlUnicodeText = 42, x
52、lHtml = 44;Word: Typeenum WdSaveFormat wdFormatDocument = 0, wdFormatTemplate = 1, wdFormatText = 2, wdFormatTextLineBreaks = 3, wdFormatDOSText = 4, wdFormatDOSTextLineBreaks = 5, wdFormatRTF = 6,
53、; wdFormatUnicodeText = 7, wdFormatEncodedText = 7, wdFormatHTML = 8;PPT:enum PpSaveAsFileType ppSaveAsPresentation = 1, ppSaveAsPowerPoint7 = 2, ppSaveAsPowerPoint4 = 3, ppSaveAsPowerPoint3 = 4, ppSaveAsTempl
54、ate = 5, ppSaveAsRTF = 6, ppSaveAsShow = 7, ppSaveAsAddIn = 8, ppSaveAsPowerPoint4FarEast = 10, ppSaveAsDefault = 11, ppSaveAsHTML = 12, ppSaveAsHTMLv3 = 13, ppSaveAsHTMLDual = 14, pp
55、SaveAsMetaFile = 15, ppSaveAsGIF = 16, ppSaveAsJPG = 17, ppSaveAsPNG = 18, ppSaveAsBMP = 19; */*0x32. 删除本地文件 HRESULT DeleteLocalFile(i
56、n BSTR strFilePath); 参数: strFileName:文件本地路径,如c:11.doc */ /
57、*0x33.创建临时文件 HRESULT GetTempFilePath(out,retval BSTR* strValue); 返回: 临时文件的路径地址。使用完后,用DeleteLocalFile 删除*/*0x34.设置文档显示模式
58、HRESULT ShowView(in long dwViewType, out,retval long * pbool); dwViewType的可取值为:enum WdViewType wdNormalView = 1, wdOutlineView = 2, wdPrintView = 3, wdPrintPreview = 4, wdMasterView = 5, /这个是大纲
59、; wdWebView = 6;*/ /大纲模式document.all.FramerControl1.ShowView(5);/*0x39:下载远程文件 HRESULT DownloadFile( in BSTR strRemoteFile, in BSTR strLocalFile, out,retval BSTR* strValue); 参数:
60、0; strRemoteFile:远程路径地址,http or Ftp strLocalFile: 本地保存地址,if strLocalFile = NULL then Create Temp File and return TempFile's Path*/*0x40:增加Http上传时候的,附加其他文件 HRESUL
61、T HttpAddPostFile(in BSTR strFileID, in BSTR strFileName, out,retval long* pbool);参数: strFileID:文件的ID,供服务器端页面解析 strFileName: 本地文件地址 */*0x41,0x42.获取详细的修订信息。 GetRevCount( out,retval long * pbool);
62、 GetRevInfo(in long lIndex, in long lType, out,retval BSTR* pbool); 例子如下*/var vCount;vCount = document.all.FramerControl1.GetRevCount();alert(vCount);var vOpt = 0;var vDate;for(var i=1; i<= vCount; i+) vOpt = document.all.FramerCont
63、rol1.GetRevInfo(i,2); if("1" = vOpt) vOpt = "插入" else if("2" = vOpt)
64、0; vOpt = "删除" else vOpt = "未知操作" vDate = new String(document.all.FramerControl1.GetRevInfo(i,1);
65、 vDate = parseFloat(vDate); alert(vDate); dateObj = new Date(vDate); alert(dateObj.getYear() + "年" + dateObj.getMonth() + 1 + "月" + dateObj.getDate() +&
66、quot;日" + dateObj.getHours() +"时" + dateObj.getMinutes() +"分" + dateObj.getSeconds() +"秒" ); alert("用户:"+document.all.FramerControl1.GetRevInfo(i,0) + "rn操作:" + vOpt + "r
67、n内容:" + document.all.FramerControl1.GetRevInfo(i,3);/*0x43.设置基本信息: HRESULT SetValue(in BSTR strValue, in BSTR strName, out,retval long* pbool);1.设置文件只读密码 SetValue("password"
68、;,":DOCPROP:PassWord");2.设置文件修改密码 SetValue("password",":DOCPROP:WritePW");返回值:0 正确-1:不支持此命令,请确定您的第二个参数没有传错-127:异常*/设置文件只读密码document.all.FramerControl1.SetValue("password",":DOCPROP:PassWord");/设置文件修改密码document.all
69、.FramerControl1.SetValue("password",":DOCPROP:WritePW");/*0x44.设置文档变量,这个很少能用到 HRESULT SetDocVariable(in BSTR strVarName, in BSTR strValue,in long lOpt, out,retval long* pbool);strVarName: 变量名strVlaue:变量值l
70、Opt: 操作类型,按位第一位为1: 表示update域关联的第二位为1: 表示如果没有这个变量则添加第三位为1: 未来支持return:0:OK-127:异常*/*0x45: 分页保存HRESULT SetPageAs(in BSTR strLocalFile, in long lPageNum, in long lType,out,retval long* pbool);strLocalFile:本地路径lPageNum:页数*/DSO上传服务器原理-Dsoframer1控件采用文
71、件Http上传接口实现文件和表单域的上传保存。1. 原理因为Web页面上的Dsoframer1打开的文件无法随表单记录提交到处理页面,所以我们把文件模拟成表单的文件域<input type=file >,通过接口把文件和表单元素发送到保存记录的页面(过程类似表单的提交)。2. 主要上传接口:HttpInit();该方法用于初始化上传接口,不需要设置参数HttpAddPostString(String FieldName, String someValue);添加要提交的表单域, FieldName是要上传表单域名称,someValue是表单域值例一:HttpAddPostStrin
72、g("username", "zhangSan");它类似域表单域的<input type=text name=username value=zhangSan> 例二: HttpAddPostString("username", WebForm.username.value); . <form name= WebForm ><input type=text name=username value=zhangSan
73、> </form>注意:如果使用上传接口,那么form表单里的表单域不会被提交到处理页面。需要手工添加到上传接口(HttpAddPostString接口),然后通过控件发送到处理页面。例二使用了“WebForm.username.value”获取表单域值。HttpAddPostCurrFile(String fileName, String ReName);添加当前Dsoframer1编辑的文件给上传接口,该接口把文件模拟到成一个表单的文件域,并提交到处理页面。例一:HttpAddPostCurrFile("File", "
74、;");该接口模拟表单文件域如下:<input type=file name=File >注意:第二个参数为空表示控件自动为文件命名,如:temp.doc,如果需要重命名可以在第二个参数指明文件名称,也可在保存页面指定文件名称。HttpPost(String url);执行上传操作将文件和表单域提交到url的页面进行保存操作,并获取url页面返回的执行结果 (是否成功,可以根据这个结果来获取服务器端执行的结果)。url支持绝对路径和相对路径。绝对路径,例如:url=http:/192.168.0.1/savedoc.asphttp:/192.168.0.1/savedoc
75、.asp/url相对路径要以“./”或者“./”开头。例如:./savedoc.asp3. 完整的上传接口演示function SaveDoc() var returnValue; / 保存页面的返回值document.all.Dsoframer11.HttpInit(); / 初始化Http引擎/ 添加相应的Post元素 document.all.Dsoframer11.HttpAddPostString("username", WebForm. username.value);/ 添加上传文件document.all.Ds
76、oframer11.HttpAddPostCurrFile("File ",""); / 提交上传文件returnValue = document.all.Dsoframer11.HttpPost("./saveDoc.jsp");if("true" = returnValue) alert("文件上传成功"); else alert("文件上传失败") 4. 关于保存Dsoframer1上传接口将数据流以Http方式提交到保存页面,至于对数据处理就和普通的文件上传处理一样了.服务器段接受数据的具体代码? 呵呵。这个就不用多介绍了吧,应该都知道。 下面,请跟贴者补充。-ASP: *JSP: *.Net: *Louts: *PHP: *12
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。