DSOFramer下載+開(kāi)發(fā)接口(微軟提供ole組件)
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
版本修改記錄:
V2.2.0.2修改: 修改了HttpPost相對(duì)路徑的一些問(wèn)題。 V2.2.0.0增加: [id(0x00010041), helpstring("Get Rev Index")] HRESULT GetRevCount( [out,retval] long * pbool); [id(0x00010042), helpstring("Get Rev Index Info")] HRESULT GetRevInfo([in] long lIndex, [in] long lType, [out,retval] BSTR* pbool); [id(0x00010043), helpstring("Set Doc Prop")] HRESULT SetValue([in] BSTR strValue, [in] BSTR strName, [out,retval] long* pbool); [id(0x00010044), helpstring("Set Doc Variable")] HRESULT SetDocVariable([in] BSTR strVarName, [in] BSTR strValue,[in] long lOpt, [out,retval] long* pbool); [id(0x00010045), helpstring("Save page To Doc")] HRESULT SetPageAs([in] BSTR strLocalFile, [in] long lPageNum, [in] long lType,[out,retval] long* pbool); ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- LoadDso.js var s = "" s += "<OBJECT id=DSOFramer align='middle' style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 100%'" s += "classid=clsid:00460182-9E5E-11D5-B7C8-B8269041DD57 codeBase=DSOFramer.ocx#Version=2,2,0,0' >" s += "</OBJECT>" document.write(s) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 接口文檔: /* 1.新建 */ //新建Word document.all.FramerControl1.CreateNew("Word.Document"); //新建Excel document.all.FramerControl1.CreateNew("Excel.Sheet"); /* 2.打開(kāi)文件 */ //打開(kāi)制定的本地文件 document.all.FramerControl1.Open("C:\\TestBook.xls"); //制定用Word來(lái)打開(kāi)c:\plain.txt文件 document.all.FramerControl1.Open("C:\\Plain.txt",false, "Word.Document"); //打開(kāi)服務(wù)器的文件 document.all.FramerControl1.Open "https://secureserver/test/mytest.asp?id=123",true, "Excel.Sheet", "MyUserAccount", "MyPassword"); //打開(kāi)服務(wù)器的文件 document.all.FramerControl1.Open("http://localhost/1.doc", true); /* 3.保存文件 */ //到本地 document.all.FramerControl1.Save("c:\\1.doc",true); //服務(wù)器 /*增加Http協(xié)議Post上傳接口,可以Post一個(gè)動(dòng)態(tài)頁(yè)面(jsp,asp,php...),由動(dòng)態(tài)頁(yè)面負(fù)責(zé)解析數(shù)據(jù) bool HttpInit(); bool HttpAddPostString(BSTR strName, BSTR strValue); bool HttpAddPostCurrFile(BSTR strFileID, BSTR strFileName); BSTR HttpPost(BSTR bstr); */ //初始化Http引擎 document.all.FramerControl1.HttpInit(); //增加Post變量 document.all.FramerControl1.HttpAddPostString("RecordID","20060102200"); document.all.FramerControl1.HttpAddPostString("UserID","李局長(zhǎng)"); //上傳打開(kāi)的文件 document.all.FramerControl1.HttpAddPostCurrFile("FileData", "文檔名.doc"); //執(zhí)行上傳動(dòng)作 document.all.FramerControl1.HttpPost("http://xxxx.com/uploadfile.asp"); /* 4.修訂留痕 */ //進(jìn)入留痕狀態(tài) document.all.FramerControl1.SetTrackRevisions(1); //進(jìn)入非留痕狀態(tài) document.all.FramerControl1.SetTrackRevisions(0); //接受當(dāng)前修訂 document.all.FramerControl1.SetTrackRevisions(4); /* 5.設(shè)置當(dāng)前用戶(hù) */ document.all.FramerControl1.SetCurrUserName("張三"); /* 6.設(shè)置當(dāng)前時(shí)間(筆跡留痕會(huì)顯示("Like 2006:02:07 11:11:11") */ document.all.FramerControl1.SetCurrTime("2006:02:07 11:11:11"); /* 7.設(shè)置和創(chuàng)建書(shū)簽,此功能比較強(qiáng)大,設(shè)置書(shū)簽數(shù)據(jù)、添加書(shū)簽和添加紅頭文件就靠他了 SetFieldValue(BSTR strFieldName, BSTR strValue, BSTR strCmdOrSheetName) strFieldName:書(shū)簽名 strValue:要設(shè)置的值 strCmdOrSheetName: 命令 ::ADDMARK:: 添加BookMark ::DELMARK:: 刪除這個(gè)BookMark ::GETMARK:: 定位到這個(gè)BookMark ::FILE:: 插入的是文件 ::JPG:: 插入的是圖片 一般來(lái)說(shuō):WORD中書(shū)簽是做好的,可以通過(guò)此接口把外界數(shù)據(jù)設(shè)置進(jìn)書(shū)簽中去。 */ //在當(dāng)前WORD位置插入標(biāo)簽,標(biāo)簽名為"book1",數(shù)值為"test" document.all.FramerControl1.SetFieldValue("book1","test","::ADDMARK::"); //設(shè)置書(shū)簽"Time",數(shù)值為"2006-03-16 22:22:22" document.all.FramerControl1.SetFieldValue("Time","2006-03-16 22:22:22",""); //在書(shū)簽位置"hongtou",插入紅頭文件"http://222.222.222.222/hongtou1.doc" 這樣,紅頭就自動(dòng)插進(jìn)去了 document.all.FramerControl1.SetFieldValue("hongtou","http://222.222.222.222/hongtou1.doc","::FILE::"); /* 8.設(shè)置菜單顯示情況 BOOL SetMenuDisplay(long lMenuFlag) lMenuFlag為以下數(shù)值的組合 #define MNU_NEW 0x01 #define MNU_OPEN 0x02 #define MNU_CLOSE 0x04 #define MNU_SAVE 0x08 #define MNU_SAVEAS 0x16 #define MNU_PGSETUP 0x64 #define MNU_PRINT 0x256 #define MNU_PROPS 0x32 #define MNU_PRINTPV 0x126 */ //只有“新建”菜單可用 document.all.FramerControl1..SetMenuDisplay(1); //只有“打開(kāi)”菜單可用 document.all.FramerControl1.SetMenuDisplay(2); //只有“打開(kāi)”和“新建”菜單可用 document.all.FramerControl1.SetMenuDisplay(3); /* 9.保護(hù)文檔和解保護(hù)文檔 lProOrUn:1:保護(hù)文檔;0:解除保護(hù) lProType: wdNoProtection = -1, wdAllowOnlyRevisions = 0, wdAllowOnlyComments = 1, wdAllowOnlyFormFields = 2 strProPWD:密碼 */ //完全保護(hù)文檔,密碼為"pwd" document.all.FramerControl1.ProtectDoc(1,1,"pwd"); //解除文檔保護(hù) document.all.FramerControl1.ProtectDoc(0,1,"pwd"); /* 10.顯示或隱藏修訂內(nèi)容 ShowRevisions(long nNewValue) nNewValue = 0 則隱藏修訂 = 1 則顯示修訂 */ //顯示修訂留痕 document.all.FramerControl1.ShowRevisions(1); //隱藏修訂留痕 document.all.FramerControl1.ShowRevisions(0); /* 11.插入合并文件, strFieldPath 文件路徑,可以是http,ftp的路徑 pPos = 0 //當(dāng)前鼠標(biāo)位置 1;文件開(kāi)頭 2;文件末尾 pPos的第4位為1的時(shí)候,代表插入的是圖片 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); //當(dāng)前光標(biāo)位置插入文件 document.all.FramerControl1.InSertFile("http://XX.com/XX.doc",0); //文件頭部插入圖片 document.all.FramerControl1.InSertFile("http://XX.com/XX.jpg",9); //文件尾部插入圖片 document.all.FramerControl1.InSertFile("http://XX.com/XX.jpg",10); //當(dāng)前光標(biāo)位置插入圖片 document.all.FramerControl1.InSertFile("http://XX.com/XX.jpg",8); /* 0x31. 文檔另存為 HRESULT SaveAs([in] VARIANT strFileName, [in] VARIANT dwFileFormat, [out,retval] long* pbool); 參數(shù): strFileName:文件本地路徑,如c:\\11.doc dwFileFormat: 文件格式 dwFileFormat的數(shù)值為: Excel: Type enum XlFileFormat { xlAddIn = 18, xlCSV = 6, xlCSVMac = 22, xlCSVMSDOS = 24, xlCSVWindows = 23, xlDBF2 = 7, xlDBF3 = 8, xlDBF4 = 11, xlDIF = 9, xlExcel2 = 16, xlExcel2FarEast = 27, xlExcel3 = 29, xlExcel4 = 33, xlExcel5 = 39, xlExcel7 = 39, xlExcel9795 = 43, xlExcel4Workbook = 35, xlIntlAddIn = 26, xlIntlMacro = 25, xlWorkbookNormal = -4143, xlSYLK = 2, xlTemplate = 17, xlCurrentPlatformText = -4158, xlTextMac = 19, xlTextMSDOS = 21, xlTextPrinter = 36, xlTextWindows = 20, xlWJ2WD1 = 14, xlWK1 = 5, xlWK1ALL = 31, xlWK1FMT = 30, xlWK3 = 15, xlWK4 = 38, xlWK3FM3 = 32, xlWKS = 4, xlWorks2FarEast = 28, xlWQ1 = 34, xlWJ3 = 40, xlWJ3FJ3 = 41, xlUnicodeText = 42, xlHtml = 44 }; Word: Type enum WdSaveFormat { wdFormatDocument = 0, wdFormatTemplate = 1, wdFormatText = 2, wdFormatTextLineBreaks = 3, wdFormatDOSText = 4, wdFormatDOSTextLineBreaks = 5, wdFormatRTF = 6, wdFormatUnicodeText = 7, wdFormatEncodedText = 7, wdFormatHTML = 8 }; PPT: enum PpSaveAsFileType { ppSaveAsPresentation = 1, ppSaveAsPowerPoint7 = 2, ppSaveAsPowerPoint4 = 3, ppSaveAsPowerPoint3 = 4, ppSaveAsTemplate = 5, ppSaveAsRTF = 6, ppSaveAsShow = 7, ppSaveAsAddIn = 8, ppSaveAsPowerPoint4FarEast = 10, ppSaveAsDefault = 11, ppSaveAsHTML = 12, ppSaveAsHTMLv3 = 13, ppSaveAsHTMLDual = 14, ppSaveAsMetaFile = 15, ppSaveAsGIF = 16, ppSaveAsJPG = 17, ppSaveAsPNG = 18, ppSaveAsBMP = 19 }; */ /* 0x32. 刪除本地文件 HRESULT DeleteLocalFile([in] BSTR strFilePath); 參數(shù): strFileName:文件本地路徑,如c:\\11.doc */ /* 0x33.創(chuàng)建臨時(shí)文件 HRESULT GetTempFilePath([out,retval] BSTR* strValue); 返回: 臨時(shí)文件的路徑地址。使用完后,用DeleteLocalFile 刪除 */ /* 0x34.設(shè)置文檔顯示模式 HRESULT ShowView([in] long dwViewType, [out,retval] long * pbool); dwViewType的可取值為: enum WdViewType { wdNormalView = 1, wdOutlineView = 2, wdPrintView = 3, wdPrintPreview = 4, wdMasterView = 5, //這個(gè)是大綱 wdWebView = 6 }; */ //大綱模式 document.all.FramerControl1.ShowView(5); /* 0x39:下載遠(yuǎn)程文件 HRESULT DownloadFile( [in] BSTR strRemoteFile, [in] BSTR strLocalFile, [out,retval] BSTR* strValue); 參數(shù): strRemoteFile:遠(yuǎn)程路徑地址,http or Ftp strLocalFile: 本地保存地址,if strLocalFile == NULL then Create Temp File and return TempFile's Path */ /* 0x40:增加Http上傳時(shí)候的,附加其他文件 HRESULT HttpAddPostFile([in] BSTR strFileID, [in] BSTR strFileName, [out,retval] long* pbool); 參數(shù): strFileID:文件的ID,供服務(wù)器端頁(yè)面解析 strFileName: 本地文件地址 */ /* 0x41,0x42.獲取詳細(xì)的修訂信息。 GetRevCount( [out,retval] long * pbool); 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.FramerControl1.GetRevInfo(i,2); if("1" == vOpt){ vOpt = "插入"; }else if("2" == vOpt){ vOpt = "刪除"; }else{ vOpt = "未知操作"; } vDate = new String(document.all.FramerControl1.GetRevInfo(i,1)); vDate = parseFloat(vDate); alert(vDate); dateObj = new Date(vDate); alert(dateObj.getYear() + "年" + dateObj.getMonth() + 1 + "月" + dateObj.getDate() +"日" + dateObj.getHours() +"時(shí)" + dateObj.getMinutes() +"分" + dateObj.getSeconds() +"秒" ); alert("用戶(hù):"+document.all.FramerControl1.GetRevInfo(i,0) + "\r\n操作:" + vOpt + "\r\n內(nèi)容:" + document.all.FramerControl1.GetRevInfo(i,3)); } /* 0x43.設(shè)置基本信息: HRESULT SetValue([in] BSTR strValue, [in] BSTR strName, [out,retval] long* pbool); 1.設(shè)置文件只讀密碼 SetValue("password","::DOCPROP:PassWord"); 2.設(shè)置文件修改密碼 SetValue("password","::DOCPROP:WritePW"); 返回值: 0 正確 -1:不支持此命令,請(qǐng)確定您的第二個(gè)參數(shù)沒(méi)有傳錯(cuò) -127:異常 */ //設(shè)置文件只讀密碼 document.all.FramerControl1.SetValue("password","::DOCPROP:PassWord"); //設(shè)置文件修改密碼 document.all.FramerControl1.SetValue("password","::DOCPROP:WritePW"); /* 0x44.設(shè)置文檔變量,這個(gè)很少能用到 HRESULT SetDocVariable([in] BSTR strVarName, [in] BSTR strValue,[in] long lOpt, [out,retval] long* pbool); strVarName: 變量名 strVlaue:變量值 lOpt: 操作類(lèi)型, 按位 第一位為1: 表示update域關(guān)聯(lián)的 第二位為1: 表示如果沒(méi)有這個(gè)變量則添加 第三位為1: 未來(lái)支持 return: 0:OK -127:異常 */ /* 0x45: 分頁(yè)保存 HRESULT SetPageAs([in] BSTR strLocalFile, [in] long lPageNum, [in] long lType,[out,retval] long* pbool); strLocalFile:本地路徑 lPageNum:頁(yè)數(shù) */ 該文章在 2013/8/27 18:32:35 編輯過(guò) |
關(guān)鍵字查詢(xún)
相關(guān)文章
正在查詢(xún)... |