662
社区成员
发帖
与我相关
我的任务
分享
#IF DEFINED PBWEBFORM THEN
ls_docname = "c:\temp\" + string(today(), 'YYMMDD') + '_' + string(now(), 'HHmmSS') + ".txt"
ll_value = 1
#ELSE
ls_cur_path = space(256)
getcurrentdirectorya(256, ls_cur_path)
ll_value = getfilesavename("导出文件", ls_docname, ls_named, "txt", "文本文件(*.txt), *.txt")
if ll_value = 1 then
setcurrentdirectorya(ls_cur_path)
end if
if fileexists(ls_docname) then
if messagebox('提示', ls_named + '文件已存在,需要覆盖吗?', Exclamation!, YesNo!, 2) = 2 then return
filedelete(ls_docname)
end if
#END IF
ll_value = FileOpen(ls_docname, LineMode!, Write!, LockWrite!, Append!)
for ll = 1 to dw_list.rowcount()
if dw_list.getitemnumber(1, 'flag') = 0 then continue
ls_str = dw_arg.getitemstring(1, 'code')
ls_str += ','
ls_str += dw_list.getitemstring(ll, 'invo_no')
ls_str += ','
ls_total = dw_list.getitemstring(ll, 'total')
if pos(ls_total, '.00') > 0 then ls_total = string(long(ls_total))
ls_str += ls_total
ls_str += ','
ls_str += string(date(dw_list.getitemstring(ll, 'invo_date')), 'yyyy-mm-dd')
ls_str += '~r'
filewrite(ll_value, ls_str)
next
#IF DEFINED PBWEBFORM THEN
fileclose(ll_value)
string s = GetDownloadFileUrl(ls_docname, false)
long ll_ = URLDownloadToFile(0, s, ls_docname, 0, 0)
if URLDownloadToFile(0, s, ls_docname, 0, 0) > 0 then messagebox('提示', '文件:' + ls_docname + ' 已导出。')
#ELSE
if fileclose(ll_value) = 1 then messagebox('提示', '导出完成。')
#END IF
long ll_row, ll_value
string ls_suffix
ll_row = dw_main.getrow()
if ll_row <= 0 then
return
end if
string ls_file, ls_url, ls_path
string ls_name = "zgszh", ls_net = "zg_gctos"
ll_value = dw_main.getitemnumber(ll_row, "filevalue")
ls_suffix = dw_main.getitemstring(ll_row, "filesuffix")
ls_file = "myfile" + string(now(), "HHMMSS") + "." + ls_suffix
saveastype lenu_data, ld_data[]
ld_data[1] = Excel!
ld_data[2] = Text!
ld_data[3] = CSV!
ld_data[4] = SYLK!
ld_data[5] = WKS!
ld_data[6] = WK1!
ld_data[7] = DIF!
ld_data[8] = dBASE2!
ld_data[9] = dBASE3!
ld_data[10] = SQLInsert!
ld_data[11] = Clipboard!
ld_data[12] = PSReport!
ld_data[13] = WMF!
ld_data[14] = HTMLTable!
ld_data[15] = Excel5!
ld_data[16] = XML!
ld_data[17] = XSLFO!
ld_data[18] = PDF!
ld_data[19] = Excel8!
ld_data[20] = EMF!
ld_data[25] = XLSX!
ld_data[26] = XLSB!
lenu_data = ld_data[ll_value + 1]
#IF DEFINED PBWEBFORM THEN
if idw_data.SaveAs(ls_file, lenu_data, true) <> -1 then
ls_url = System.Web.HttpContext.Current.Request.Url.tostring()
ls_path = MapVirtualPath(ls_file)
long ll_pos, ll_next
ll_pos = pos(ls_url, "/" + ls_name + "/")
if ll_pos > 0 then
ls_url = left(ls_url, ll_pos - 1) + "/"
ll_next = pos(ls_path, ls_net + "_root")
if ll_next > 0 then
ls_url += mid(ls_path, ll_next)
ll_pos = pos(ls_url, '\')
do while ll_pos > 0
ls_url = left(ls_url, ll_pos - 1) + '/' + mid(ls_url, ll_pos + 1)
ll_pos = pos(ls_url, '\')
loop
shl_1.url = ls_url
end if
end if
ls_file = GetDownloadFileUrl(ls_file, false)
shl_2.url = ls_file
shl_1.visible = true
shl_2.visible = true
end if
#ELSE
idw_data.SaveAs(ls_file, lenu_data, true)
#END IF