li_ret = ole_object.ConnectToObject("","Excel.Application")
IF li_ret <> 0 THEN
//Èç¹ûExcel»¹Ã»Óдò¿ª£¬Ôòн¨¡£
li_ret = ole_object.ConnectToNewObject("Excel.Application")
if li_ret <> 0 then
MessageBox('OLE´íÎó','OLEÎÞ·¨Á¬½Ó!´íÎóºÅ£º' + string(li_ret))
return 0
end if
ole_object.Visible = True
END IF
pointer oldpointer
oldpointer = SetPointer(HourGlass!)
ole_object.Workbooks.Add
long ll_colnum,ll_rownum
string ls_value
string ls_objects,ls_obj,ls_objs[],ls_objtag[]
long ll_pos,ll_len,ll_num = 0
string ls_colname
integer i,j,k
for i = 1 to ll_colnum
//µÃµ½±êÌâÍ·µÄÃû×Ö
ls_value = ls_objtag[i]
ole_object.cells(1,i).value = ls_value
next
string column_name
for i = 2 to ll_rownum
for j = 1 to ll_colnum
column_name = ls_objs[j]
if adw.Describe(column_name + '.type') = 'column' then
ls_value = adw.Describe("Evaluate('LookupDisplay("+column_name+")',"+string(i - 1)+")")
end if
if adw.Describe(column_name + '.type') = 'compute' then
ls_value = adw.Describe("Evaluate('" + adw.Describe(column_name + '.expression') + "',"+string(i - 1)+")")
end if
ole_object.cells(i,j).value = ls_value
next
next
li_ret = ole_object.ConnectToObject("","Excel.Application")
IF li_ret <> 0 THEN
//如果Excel还没有打开,则新建。
li_ret = ole_object.ConnectToNewObject("Excel.Application")
if li_ret <> 0 then
MessageBox('OLE错误','OLE无法连接!错误号:' + string(li_ret))
return 0
end if
ole_object.Visible = True
END IF
pointer oldpointer
oldpointer = SetPointer(HourGlass!)
ole_object.Workbooks.Add
long ll_colnum,ll_rownum
string ls_value
string ls_objects,ls_obj,ls_objs[],ls_objtag[],ls_width[]
long ll_pos,ll_len,ll_num = 0
for i = 1 to ll_colnum
//得到标题头的名字
ls_value = ls_objtag[i]
ole_object.cells(2,i).value = ls_value //1
if isnull(ls_width[i]) then
ld_width=12
else
ld_width=dec(ls_width[i])/35
end if
ole_object.Columns(i).ColumnWidth=ld_width
ole_object.Columns(i).HorizontalAlignment =3
ole_object.Columns(i).Borders.LineStyle= 1
ole_object.Columns(i).Font.Bold =True
next
string column_name,ls_coltype
for i = 3 to ll_rownum
for j = 1 to ll_colnum
column_name = ls_objs[j]
if adw.Describe(column_name + '.type') = 'column' then
ls_value = adw.Describe("Evaluate('LookupDisplay("+column_name+")',"+string(i - 2)+")")
end if
if adw.Describe(column_name + '.type') = 'compute' then
ls_value = adw.Describe("Evaluate('" + adw.Describe(column_name + '.expression') + "',"+string(i - 2)+")")
end if
ls_coltype=adw.Describe(column_name+'.coltype')
if pos(upper(ls_coltype),"CHAR")>0 then //对字符型数据处理
ole_object.cells(i,j).NumberFormat ="@"
end if
ole_object.cells(i,j).Font.Bold =false
ole_object.cells(i,j).value = ls_value
next
next
value = GetFileSaveName("选择文件",docname, named, "XLS","Excel文件 (*.XLS), *.xls,文本文件 (*.TXT),*.TXT")
IF value = 1 THEN
dw_body . SaveAsAscii ( docname )
end if