f_rpt_saveas.srf 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. $PBExportHeader$f_rpt_saveas.srf
  2. global type f_rpt_saveas from function_object
  3. end type
  4. forward prototypes
  5. global subroutine f_rpt_saveas (datastore adw, integer i_cc)
  6. end prototypes
  7. global subroutine f_rpt_saveas (datastore adw, integer i_cc);string ls1,ls2,ls3,ls4
  8. ls3="XLS"
  9. ls4="Excel Files(*.XLS),*.XLS"
  10. if GetFileSaveName("Select File",ls1,ls2,ls3,ls4)=1 then
  11. if pos(lower(ls1),'.xls')>0 then
  12. adw.saveas(ls1,htmltable!,true)
  13. long ll,lls,llc,lll
  14. string ls_id,ls_dw,ls_dws
  15. lll=FileLength(ls1)
  16. llc=Ceiling(lll/32765)
  17. lll=FileOpen(ls1,StreamMode!,Read!,Shared!)
  18. for ll=1 to llc
  19. FileRead(lll,ls_dw)
  20. ls_dws=ls_dws+ls_dw
  21. next
  22. FileClose(lll)
  23. ////////////////////以下代码是为了避免Excel2000有时会出现乱码的问题/////
  24. lll=FileOpen(ls1,StreamMode!,Write!,LockWrite!,Replace!)
  25. if i_cc=1 then//gb
  26. FileWrite(lll,'<meta HTTP-EQUIV="content-type" CONTENT="text/html;charset=GB2312">')
  27. else
  28. FileWrite(lll,'<meta HTTP-EQUIV="content-type" CONTENT="text/html;charset=BIG5">')
  29. end if
  30. FileClose(lll)
  31. lll=len(ls_dws)
  32. llc=Ceiling(lll/32765)
  33. lll=FileOpen(ls1,StreamMode!,Write!,Shared!,Append!)
  34. for ll=1 to llc
  35. ls_dw=left(ls_dws,32765)
  36. ls_dws=mid(ls_dws,32766)
  37. FileWrite(lll,ls_dw)
  38. next
  39. FileClose(lll)
  40. /////////////////////////////////////////////////////
  41. messagebox("提示","报表另存成功.")
  42. end if
  43. else
  44. messagebox("出错","报表另存不成功!")
  45. end if
  46. return
  47. end subroutine