注册 登录
编程论坛 PowerBuilder

怎么样把select查找到的记录生成txt文件

daring 发布于 2006-10-18 15:07, 1419 次点击
怎么样把select查找到的记录生成txt文件,用什么函数,语句怎么写,代码都要在pb中实现
4 回复
#2
潇洒老乌龟2006-10-18 16:25
1\使用动态数据窗口
2\dw_1.saveas()
#3
jimn20002006-10-25 17:56

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


#4
jiazishu2006-11-09 11:47
支持
#5
路過2006-12-20 13:51

1