其他分享
首页 > 其他分享> > PB 导出Excel

PB 导出Excel

作者:互联网

string ls_pathname,ls_file,ls_ext
long ll_return
if dw_1.rowcount()<1 then
    messagebox('提示',"当前数据窗无记录数据,无导出的必要!",exclamation!)
    return
end if

ll_return=getfilesavename("导出文件",ls_pathname,ls_file,"txt","txt文件(*.txt),*.txt,csv文件(*.csv),*.csv,xls文件(*.xls),*.xls" )

if ll_return<>1 then return
IF fileexists(ls_pathname) THEN
    ll_return = messagebox('提示', ls_pathname+"已经存在,是否覆盖?",Question!, YesNo!)
    if ll_return=2 then return
end if

ls_ext = trim(right(ls_pathname,3))
if ls_ext = 'txt' then
    ll_return = dw_1.saveasascii(ls_pathname)
elseif ls_ext = 'csv' then
    ll_return = dw_1.saveasascii(ls_pathname)//,csv!,true)
elseif ls_ext = 'xls' then
    ll_return = dw_1.saveasascii(ls_pathname)//,Excel!,true)    
end if

IF ll_return <>1 then
    messagebox('错误',"导出数据失败!",stopsign!)
    return
END IF 
messagebox('提示',"已成功导出【"+string(dw_1.rowcount())+"】条数据;~r~n 文件位置"+ls_pathname)

PB6.5可用,导出Group类型的datawindow,统计行也能正常导出

来自:https://www.cnblogs.com/yh-xiaoxiami/p/13872550.html

标签:return,Excel,ll,导出,PB,ext,pathname,ls,dw
来源: https://www.cnblogs.com/djd66/p/16205398.html