dw_1.saveas()
dw_1.SaveAsAscii("H:\Q2\RESULTS.TXT","&","'")
我整理了一个可以保存成中文汉字字头的代码.希望对你有用,dw_1.saveas()的缺点就是文字取不来.
//if dw_1.rowcount() > 0 then
// dw_1.SaveAs("",Text!, false)
//end if
//==============================================================================
// 把数据窗口的数据保存成有表头文字的excel文件和txt文件两种类型
// add by jhz
//==============================================================================
integer li_rtn,ii,li_asc
string ls_name,ls_pathname
boolean lb_exist
any vdType
if dw_1.rowcount() < 1 then
messagebox("提示信息","请先检索数据再导出!")
return -1 //error
end if
li_rtn = getfilesavename("选择文件", &
ls_pathname, ls_name, "xls", &
"Excel文档(*.xls), *.xls," + &
"txt文档(*.txt), *.txt")
if li_rtn = 1 then
lb_exist = fileexists(ls_pathname)
if lb_exist then
li_rtn = messagebox("保存", ls_pathname+"已经存在,是否覆盖?",Exclamation!, YesNo!)
end if
//保存成excel文件
if upper(right(ls_pathname,3)) = 'XLS' then
if li_rtn = 1 then
//当文件存在用户选择覆盖,或是文件本就不存在时。
li_rtn = dw_1.saveasascii(ls_pathname)
if li_rtn = 1 then
messagebox("提示信息","数据导出成功!")
else
messagebox("错误信息","数据导出失败!")
return -1 //error
end if
else
return -1 //error
end if
end if
//保存成txt文件
if upper(right(ls_pathname,3)) = 'TXT' then
li_rtn = dw_1.saveasascii(ls_pathname," ","~t")
if li_rtn = 1 then
messagebox("提示信息","数据导出成功!")
end if
end if
else
return -1
end if