String ls_path, ls_file
blob blob_image, blob_temp
long Job, ll_filelen
integer li_x, li_y, net, li_loop, i
Integer ll_file
String ls_yymm
Long ll_cnt, ll_chk
pointer oldpointer // Declares a pointer variable
ls_yymm = String(dw_1.object.yymm[1], 'yyyymm')
if isnull(ls_yymm) or trim(ls_yymm) = '' then
messagebox("알림", "DOWNLOAD할 년월을 입력하세요")
return 1
end if
select count(*)
into :ll_cnt
from tb_table
where comp_cd = :gs_company
and yymm = :ls_yymm ;
if ll_cnt = 0 then
messagebox("알림", "다운로드할 파일이 존재하지 않습니다!!!")
return 1
end if
net = MessageBox("선택","다운로드를 하시겠습니까?", Question!, YesNo!, 1)
oldpointer = SetPointer(HourGlass!)
choose case net
case 1 // 파일 저장
selectblob filedata
into :blob_image
from tb_table
where comp_cd = :gs_company
and yymm = :ls_yymm ;
ll_filelen = len(blob_image)
if ll_filelen > 32765 then
if mod(ll_filelen,32765) = 0 then
li_loop = ll_filelen / 32765
else
li_loop = (ll_filelen / 32765) + 1
end if
else
li_loop = 1
end if
// 파일이름
select filename
into :ls_path
from tb_table
where comp_cd = :gs_company
and yymm = :ls_yymm ;
GetFileSaveName ( "Select File", ls_path, ls_file, "XLSX", "XLSX Files, *.XLSX, XLS Files, *.XLS, DOC Files, *.DOC")
ll_file = FileOpen(ls_path, StreamMode!, Write!, Shared!, Append!)
for i = 1 to li_loop
if i = li_loop then
blob_temp = BlobMid(blob_image, (i - 1) * 32765 + 1)
else
blob_temp = BlobMid(blob_image, (i - 1) * 32765 + 1, 32765)
end if
FileWrite(ll_file, blob_temp)
next
ll_chk = Fileclose(ll_file)
case else //작업취소
return 1
end choose
SetPointer(oldpointer)