2010년 8월 8일 일요일

[파워빌더]CSV 포멧으로 파일저장하기

long i,rno,rcnt
string cdate,ccomp,item,header_str,chango,damdang,uprice,qty,price,tax,tprice,pay
string docname, named,w_string,groupname
integer value

header_str = '출고일자,출고처,단체명,제품명,단가,출고량,금액,세액,합계,결재금액,창고명,담당자'
value = GetFileSaveName("Select File", docname, named, "CSV", &
"Comma Seperated Format(*.CSV),*.CSV," + " Text Files (*.TXT), *.TXT")
IF value = 1 THEN
integer li_FileNum
li_FileNum = FileOpen(docname,LineMode!, Write!, LockWrite!, Replace! )
FileWrite(li_FileNum, header_str)
rcnt = dw_1.rowcount()
uo_2.hpb_1.minposition = 0
uo_2.hpb_1.maxposition = rcnt
uo_2.visible = true
for i = 1 to rcnt
cdate = string(dw_1.object.idate[i],'yyyy-mm-dd')
ccomp = dw_1.object.customer_company[i]
groupname = dw_1.Describe("Evaluate('LookUpDisplay(group_no)'," + string(i) + ")")
item = dw_1.object.item_item[i]
uprice = string(dw_1.object.iuprice[i])
qty = string(dw_1.object.isize[i])
price = string(dw_1.object.itotal[i])
tax = string(dw_1.object.tax[i])
tprice = string(dw_1.object.iuprice[i] * dw_1.object.isize[i])
pay = string(dw_1.object.ipay[i])
chango = dw_1.object.storeroom_cname[i]
damdang = dw_1.object.e_name[i]
if isnull(cdate) then cdate = ''
if isnull(ccomp) then ccomp = ''
if isnull(groupname) then groupname = ''
if isnull(item) then item = ''
if isnull(uprice) then uprice = ''
if isnull(qty) then qty = ''
if isnull(price) then price = ''
if isnull(tax) then tax = ''
if isnull(tprice) then tprice = ''
if isnull(pay) then pay = ''
if isnull(chango) then chango = ''
if isnull(damdang) then damdang = ''
w_string = cdate + ',' + ccomp + ',' + groupname + ',' + item + ',' + uprice + ',' + qty + ',' + price + ',' + tax + ',' + &
tprice + ',' + pay + ',' + chango + ',' + damdang
FileWrite(li_FileNum, w_string)
uo_2.hpb_1.position = i
next
FileClose(li_FileNum)
uo_2.visible = false
messagebox('자료생성',string(rcnt) + '건의 자료가 생성되었습니다.')
dw_1.setredraw(true)
end if

댓글 없음: