1.void CreateNew(BSTR ProgIdOrTemplate)
Excel Spreadsheet
Excel Chart
PowerPoint Presentation
Project Project
Visio Drawing
Word Document
2.
[in, optional] VARIANT ProgId, [in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword)
參數:
Document
ReadOnly
ProgId
WebUsername
WebPassword
例子:
DsoFramer1.Open "C:\TestBook.xls"
DsoFramer1.Open "C:\Plain.txt", , "Word.Document"
DsoFramer1.Open "https://secureserver/test/mytest.asp?id=123", True, "Excel.Sheet", "MyUserAccount", "MyPassword"
3.HRESULT Save([in, optional] VARIANT SaveAsDocument, [in, optional] VARIANT OverwriteExisting,
保存文件在本地
DsoFramer1.Save "c:\1.doc"
4.Activate
激活當前文檔,沒搞明白有什麼用
5.
返回當前活動文檔的Dispatch接口,這個接口很重要,可以通過這個接口,操作所有的文檔接口。
如:下面 javascript 語句調用Office內置的對話框
var obj;
obj = new Object(document.all.FramerControl1.ActiveDocument);
if(obj !=null){
var dd;
dd = obj.Application.Dialogs(84).Show();
//... ...
//delete it
delete obj;
}
6.
關閉當前文檔,建議在頁面關閉的時候調用。
MS的原來的版本,有時候關不掉Word,已經修復了。
7.
屬性,獲取|設置窗口標題
8.
9. HRESULT Toolbars([in] boolean vbool);
10.
11.HRESULT ShowDialog([in] dsoShowDialogType DlgType);
12.HRESULT EnableFileCommand([in] dsoFileCommandType Item, [in] boolean vbool);
13.
14.
15. HRESULT BackColor([in] OLE_COLOR clr);
16.HRESULT ForeColor([in]OLE_COLOR clr);
17.HRESULT TitlebarColor([in] OLE_COLOR clr);
HRESULT TitlebarColor([out,retval] OLE_COLOR* pclr);
18.HRESULT TitlebarTextColor([in] OLE_COLOR clr);
19.HRESULT ExecOleCommand([in] LONG OLECMDID, [in, optional] VARIANT Options, [in, optional] VARIANT* vInParam, [in, out, optional] VARIANT* vInOutParam);
20.HRESULT Menubar([in] boolean vbool);
21.HRESULT HostName([in] BSTR bstr);
22. HRESULT DocumentFullName([out,retval] BSTR* pbstr);
23.HRESULT PrintOut([in, optional] VARIANT PromptUser, [in, optional] VARIANT PrinterName, [in, optional] VARIANT Copies,
24.HRESULT PrintPreview();
25.HRESULT PrintPreviewExit();
26.HRESULT IsReadOnly([out,retval] boolean* pbool);
27.HRESULT IsDirty([out,retval] boolean* pbool);
新加的接口說明(開發接口)
[color=red][b]當前版本:V
2.2.0.8
[/color]下載控件需要登錄
說明:
控件未經大批量測試,難免有Bug,
發現 Bug,請及時發帖或者Mail:[email protected]
版本修改記錄:
V2.2.0.8修改:
V2.2.0.6修改:
V2.2.0.2修改:
V2.2.0.0增加:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
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,6' >"
s += "</OBJECT>"
document.write(s)
接口文檔:
//新建Word
document.all.FramerControl1.CreateNew("Word.Document");
//新建Excel
document.all.FramerControl1.CreateNew("Excel.Sheet");
//打開制定的本地文件
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 "https://secureserver/test/mytest.asp?id=123",true, "Excel.Sheet", "MyUserAccount", "MyPassword");
//打開服務器的文件
document.all.FramerControl1.Open("http://localhost/1.doc", true);
//到本地
document.all.FramerControl1.Save("c:\\1.doc",true);
//服務器
//初始化Http引擎
document.all.FramerControl1.HttpInit();
//增加Post變量
document.all.FramerControl1.HttpAddPostString("RecordID","20060102200");
document.all.FramerControl1.HttpAddPostString("UserID","李局長");
//上傳打開的文件
document.all.FramerControl1.HttpAddPostCurrFile("FileData", "文檔名.doc");
//執行上傳動作
document.all.FramerControl1.HttpPost("http://xxxx.com/uploadfile.asp");
//進入留痕狀態
document.all.FramerControl1.SetTrackRevisions(1);
//進入非留痕狀態
document.all.FramerControl1.SetTrackRevisions(0);
//接受當前修訂
document.all.FramerControl1.SetTrackRevisions(4);
document.all.FramerControl1.SetCurrUserName("張三");
document.all.FramerControl1.SetCurrTime("2006:02:07 11:11:11");
//在當前WORD位置插入標籤,標籤名爲"book1",數值爲"test"
document.all.FramerControl1.SetFieldValue("book1","test","::ADDMARK::");
//設置書籤"Time",數值爲"2006-03-16 22:22:22"
document.all.FramerControl1.SetFieldValue("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::");
//只有“新建”菜單可用
document.all.FramerControl1..SetMenuDisplay(1);
//只有“打開”菜單可用
document.all.FramerControl1.SetMenuDisplay(2);
//只有“打開”和“新建”菜單可用
document.all.FramerControl1.SetMenuDisplay(3);
//完全保護文檔,密碼爲"pwd"
document.all.FramerControl1.ProtectDoc(1,1,"pwd");
//解除文檔保護
document.all.FramerControl1.ProtectDoc(0,1,"pwd");
//顯示修訂留痕
document.all.FramerControl1.ShowRevisions(1);
//隱藏修訂留痕
document.all.FramerControl1.ShowRevisions(0);
//文件頭部插入文件
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);
//文件頭部插入圖片
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);
//大綱模式
document.all.FramerControl1.ShowView(5);
var vCount;
vCount = document.all.FramerControl1.GetRevCount();
alert(vCount);
var vOpt = 0;
var vDate;
for(var i=1; i<= vCount; i++){
}
//設置文件只讀密碼
document.all.FramerControl1.SetValue("password","::DOCPROP:PassWord");
//設置文件修改密碼
document.all.FramerControl1.SetValue("password","::DOCPROP:WritePW");
DSO上傳服務器原理
Dsoframer1控件採用文件Http上傳接口實現文件和表單域的上傳保存。
1. 原理
因爲Web頁面上的Dsoframer1打開的文件無法隨表單記錄提交到處理頁面,所以我們把文件模擬成表單的文件域<input type=file …>,通過接口把文件和表單元素髮送到保存記錄的頁面(過程類似表單的提交)。
2. 主要上傳接口:
HttpInit();
該方法用於初始化上傳接口,不需要設置參數
HttpAddPostString(String FieldName, String someValue);
添加要提交的表單域, FieldName是要上傳表單域名稱,someValue是表單域值
例一:
HttpAddPostString("username", "zhangSan");
它類似域表單域的
<input type=text name=username value=zhangSan>
<input type=text name=username value=zhangSan>
注意:如果使用上傳接口,那麼form表單裏的表單域不會被提交到處理頁面。需要手工添加到上傳接口(HttpAddPostString接口),然後通過控件發送到處理頁面。例二使用了“WebForm.username.value”獲取表單域值。
HttpAddPostCurrFile(String fileName, String ReName);
添加當前Dsoframer1編輯的文件給上傳接口,該接口把文件模擬到成一個表單的文件域,並提交到處理頁面。
例一:
HttpAddPostCurrFile("File", "");
該接口模擬表單文件域如下:
<input type=file name=File >
注意:第二個參數爲空表示控件自動爲文件命名,如:temp.doc,如果需要重命名可以在第二個參數指明文件名稱,也可在保存頁面指定文件名稱。
HttpPost(String url);
執行上傳操作將文件和表單域提交到url的頁面進行保存操作,並獲取url頁面返回的執行結果 (是否成功,可以根據這個結果來獲取服務器端執行的結果)。
url支持絕對路徑和相對路徑。
絕對路徑,例如:[url=http://192.168.0.1/savedoc.asp]http://192.168.0.1/savedoc.asp[/url]
相對路徑要以“./”或者“../”開頭。例如:./savedoc.asp
3. 完整的上傳接口演示
function SaveDoc() {
var returnValue;
document.all.Dsoframer11.HttpInit(); // 初始化Http引擎
// 添加相應的Post元素
document.all.Dsoframer11.HttpAddPostString("username", WebForm. username.value);
// 添加上傳文件
document.all.Dsoframer11.HttpAddPostCurrFile("File ","");
// 提交上傳文件
returnValue = document.all.Dsoframer11.HttpPost("../saveDoc.jsp");
if("true" == returnValue){
} else
}
}
4. 關於保存
Dsoframer1上傳接口將數據流以Http方式提交到保存頁面,至於對數據處理就和普通的文件上傳處理一樣了.