<SCRIPT LANGUAGE="JavaScript">
<!--
var FileSource;
var FileDesource;
var word;
var xmlhttp;
var filename;
function Load(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
filename = fso.GetSpecialFolder(2) + "\\" + "WjTemp.doc";
//alert(filename);
//OpenWeb();
}catch(e){alert(e.message);};
}
function UnLoad(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filename);
f.Delete();
}catch(e){ShowErrorMsg();};
}
function OpenWeb(){
try{
FileSource = document.WebForm.FileSource.value + "&ID=" + document.WebForm.ID.value + "&FileMode=" + document.WebForm.FileMode.value + "&FileType=" + document.WebForm.FileType.value;
//alert(FileSource);
var binData;
xmlhttp = new ActiveXObject("msxml2.xmlhttp");
xmlhttp.Open("get",FileSource,false);
xmlhttp.Send();
binData=xmlhttp.ResponseBody;
var objsm = new ActiveXObject("ADODB.STREAM");
objsm.Type=1;
objsm.Open();
objsm.Write(binData);
objsm.SaveToFile(filename,2);
objsm.Close();
word = new ActiveXObject("word.application");
word.Visible = true;
word.documents.open(filename);
}catch(e){ShowErrorMsg(e);};
}
function SaveWeb(){
try{
FileDesource = document.WebForm.FileDesource.value + "&ID=" + document.WebForm.ID.value + "&FileMode=" + document.WebForm.FileMode.value + "&FileType=" + document.WebForm.FileType.value;
if (document.WebForm.FileMode.value == "new"){
var Name;
if (Name=window.prompt("请输入文档名称!","")){
FileDesource = FileDesource + "&Name=" + Name
};
};
//alert(FileDesource);
if (word != null){
word.activedocument.save();
word.quit();
};
var binData
var objsm = new ActiveXObject("ADODB.STREAM");
objsm.Type=1;
objsm.Open();
objsm.LoadFromFile(filename);
binData=objsm.read(objsm.size);
objsm.Close
xmlhttp = new ActiveXObject("msxml2.xmlhttp");
xmlhttp.Open("post",FileDesource,false);
xmlhttp.Send(binData);
Dim theArray(20,10000)
for i=0 to row-1
for j=0 to column-1
theArray(j+1,i+1) = table.rows(i).cells(j).innerTEXT
next
next
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("综合查询结果集") //显示表格标题
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
Set rngPara = objWordDoc.Application.ActiveDocument.Paragraphs(1).Range
With rngPara
.Bold = True //将标题设为粗体
.ParagraphFormat.Alignment = 1 //将标题居中
.Font.Name = "隶书" //设定标题字体
.Font.Size = 18 //设定标题字体大小
End With
Set rngCurrent = objWordDoc.Application.ActiveDocument.Paragraphs(3).Range
Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,row,column)
for i = 1 to column
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1
next
For i =1 to column
For j = 2 to row
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter theArray(i,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1
Next
Next