1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- $PBExportHeader$f_rpt_saveas.srf
- global type f_rpt_saveas from function_object
- end type
- forward prototypes
- global subroutine f_rpt_saveas (datastore adw, integer i_cc)
- end prototypes
- global subroutine f_rpt_saveas (datastore adw, integer i_cc);string ls1,ls2,ls3,ls4
- ls3="XLS"
- ls4="Excel Files(*.XLS),*.XLS"
- if GetFileSaveName("Select File",ls1,ls2,ls3,ls4)=1 then
- if pos(lower(ls1),'.xls')>0 then
- adw.saveas(ls1,htmltable!,true)
- long ll,lls,llc,lll
- string ls_id,ls_dw,ls_dws
- lll=FileLength(ls1)
- llc=Ceiling(lll/32765)
- lll=FileOpen(ls1,StreamMode!,Read!,Shared!)
- for ll=1 to llc
- FileRead(lll,ls_dw)
- ls_dws=ls_dws+ls_dw
- next
- FileClose(lll)
- ////////////////////以下代码是为了避免Excel2000有时会出现乱码的问题/////
- lll=FileOpen(ls1,StreamMode!,Write!,LockWrite!,Replace!)
- if i_cc=1 then//gb
- FileWrite(lll,'<meta HTTP-EQUIV="content-type" CONTENT="text/html;charset=GB2312">')
- else
- FileWrite(lll,'<meta HTTP-EQUIV="content-type" CONTENT="text/html;charset=BIG5">')
- end if
- FileClose(lll)
-
- lll=len(ls_dws)
- llc=Ceiling(lll/32765)
- lll=FileOpen(ls1,StreamMode!,Write!,Shared!,Append!)
- for ll=1 to llc
- ls_dw=left(ls_dws,32765)
- ls_dws=mid(ls_dws,32766)
- FileWrite(lll,ls_dw)
- next
- FileClose(lll)
- /////////////////////////////////////////////////////
- messagebox("提示","报表另存成功.")
- end if
- else
- messagebox("出错","报表另存不成功!")
- end if
- return
- end subroutine
|