w_sentdataout.srw 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. $PBExportHeader$w_sentdataout.srw
  2. $PBExportComments$数据发送窗口
  3. forward
  4. global type w_sentdataout from w_publ_base
  5. end type
  6. type cb_backup from uo_imflatbutton within w_sentdataout
  7. end type
  8. type st_1 from statictext within w_sentdataout
  9. end type
  10. type sle_filename from singlelineedit within w_sentdataout
  11. end type
  12. type cb_ch from commandbutton within w_sentdataout
  13. end type
  14. type gb_1 from groupbox within w_sentdataout
  15. end type
  16. type ddlb_dataformat from dropdownlistbox within w_sentdataout
  17. end type
  18. type rb_xls from radiobutton within w_sentdataout
  19. end type
  20. type rb_xlsx from radiobutton within w_sentdataout
  21. end type
  22. type ddlb_1 from dropdownlistbox within w_sentdataout
  23. end type
  24. type st_2 from statictext within w_sentdataout
  25. end type
  26. end forward
  27. global type w_sentdataout from w_publ_base
  28. integer width = 2487
  29. integer height = 628
  30. string title = "数据发送"
  31. boolean minbox = false
  32. windowtype windowtype = response!
  33. cb_backup cb_backup
  34. st_1 st_1
  35. sle_filename sle_filename
  36. cb_ch cb_ch
  37. gb_1 gb_1
  38. ddlb_dataformat ddlb_dataformat
  39. rb_xls rb_xls
  40. rb_xlsx rb_xlsx
  41. ddlb_1 ddlb_1
  42. st_2 st_2
  43. end type
  44. global w_sentdataout w_sentdataout
  45. type variables
  46. DATAWINDOW OBJ_DW
  47. INT ddlb_dataformat_INDEX=1
  48. end variables
  49. forward prototypes
  50. public function string of_globalreplace (string as_source, string as_old, string as_new)
  51. public function integer of_xlsx (string arg_str)
  52. end prototypes
  53. public function string of_globalreplace (string as_source, string as_old, string as_new);long ll_oldlen, ll_newlen, ll_pos
  54. as_source=trim(as_source)
  55. as_old=trim(as_old)
  56. ll_pos = Pos(as_source,as_old)
  57. IF ll_pos > 0 Then
  58. ll_oldlen = Len(as_old)
  59. ll_newlen = Len(as_new)
  60. DO WHILE ll_pos > 0
  61. as_source = Replace(as_source,ll_pos,ll_oldlen,as_new)
  62. ll_pos = Pos(as_source,as_old,ll_pos + ll_newlen)
  63. LOOP
  64. END IF
  65. RETURN as_source
  66. end function
  67. public function integer of_xlsx (string arg_str);
  68. OLEObject ExcelServer
  69. ExcelServer = Create OLEObject
  70. string new_str
  71. IF ExcelServer.ConnectToNewObject( "excel.application" ) < 0 THEN
  72. MessageBox('', "连接excel失败,检查你的系统是否安装了office,必须安装EXCLE才可以使用该导入功能!")
  73. RETURN 0
  74. END IF
  75. TRY
  76. ExcelServer.Workbooks.Open(arg_str)
  77. ExcelServer.activeworkbook.worksheets(1).Activate
  78. ExcelServer.activeworkbook.Save
  79. new_str= replace(arg_str,pos(arg_str,'.'),1,' .')
  80. new_str= of_globalreplace(new_str,'xls','xlsx')
  81. new_str= of_globalreplace(new_str,'XLS','xlsx')
  82. ExcelServer.activeworkbook.SaveAs(new_str,51)
  83. ExcelServer.displayalerts = False
  84. ExcelServer.quit()
  85. ExcelServer.DisconnectObject()
  86. Destroy ExcelServer
  87. FileDelete(arg_str)
  88. RETURN 1
  89. Catch(runtimeerror er)
  90. MessageBox('错误','导出execl失败~r~n'+er.getmessage())
  91. FileDelete(arg_str)
  92. Destroy ExcelServer
  93. // ll_rtn_dsr = 0
  94. RETURN 0
  95. END TRY
  96. end function
  97. on w_sentdataout.create
  98. int iCurrent
  99. call super::create
  100. this.cb_backup=create cb_backup
  101. this.st_1=create st_1
  102. this.sle_filename=create sle_filename
  103. this.cb_ch=create cb_ch
  104. this.gb_1=create gb_1
  105. this.ddlb_dataformat=create ddlb_dataformat
  106. this.rb_xls=create rb_xls
  107. this.rb_xlsx=create rb_xlsx
  108. this.ddlb_1=create ddlb_1
  109. this.st_2=create st_2
  110. iCurrent=UpperBound(this.Control)
  111. this.Control[iCurrent+1]=this.cb_backup
  112. this.Control[iCurrent+2]=this.st_1
  113. this.Control[iCurrent+3]=this.sle_filename
  114. this.Control[iCurrent+4]=this.cb_ch
  115. this.Control[iCurrent+5]=this.gb_1
  116. this.Control[iCurrent+6]=this.ddlb_dataformat
  117. this.Control[iCurrent+7]=this.rb_xls
  118. this.Control[iCurrent+8]=this.rb_xlsx
  119. this.Control[iCurrent+9]=this.ddlb_1
  120. this.Control[iCurrent+10]=this.st_2
  121. end on
  122. on w_sentdataout.destroy
  123. call super::destroy
  124. destroy(this.cb_backup)
  125. destroy(this.st_1)
  126. destroy(this.sle_filename)
  127. destroy(this.cb_ch)
  128. destroy(this.gb_1)
  129. destroy(this.ddlb_dataformat)
  130. destroy(this.rb_xls)
  131. destroy(this.rb_xlsx)
  132. destroy(this.ddlb_1)
  133. destroy(this.st_2)
  134. end on
  135. event open;call super::open;OBJ_DW=Message.PowerObjectParm
  136. IF OBJ_DW.DATAOBJECT='' THEN CLOSE(THIS)
  137. ddlb_1.selectitem(2)
  138. end event
  139. type cb_func from w_publ_base`cb_func within w_sentdataout
  140. boolean visible = false
  141. integer x = 64
  142. integer y = 388
  143. boolean enabled = false
  144. end type
  145. type cb_exit from w_publ_base`cb_exit within w_sentdataout
  146. integer x = 1138
  147. integer y = 388
  148. integer width = 320
  149. end type
  150. type cb_backup from uo_imflatbutton within w_sentdataout
  151. integer x = 453
  152. integer y = 388
  153. integer width = 320
  154. integer height = 96
  155. integer taborder = 60
  156. string text = "发送"
  157. end type
  158. event clicked;call super::clicked;Integer SAVE_RSLT = 0
  159. IF ddlb_dataformat_INDEX <> 4 AND Len(Trim(sle_filename.Text)) <= 5 THEN
  160. MessageBox('错误','请检查文件名!')
  161. RETURN
  162. END IF
  163. IF FileExists(sle_filename.Text) THEN
  164. IF MessageBox("系统提示","文件"+sle_filename.Text+"已经存在,是否覆盖该文件?",Question!,YesNo!,2) = 2 THEN
  165. RETURN
  166. END IF
  167. FileDelete(sle_filename.Text)
  168. END IF
  169. string ls_Sparse
  170. ls_Sparse = trim(obj_dw.Describe('datawindow.Sparse'))
  171. obj_dw.setredraw(false)
  172. If ddlb_1.Text = '不合并' Then
  173. obj_dw.Object.DataWindow.Sparse = ''
  174. obj_dw.Modify("DataWindow.HTMLTable.Border='0'")
  175. End If
  176. CHOOSE CASE ddlb_dataformat_INDEX
  177. CASE 1 //EXCEL
  178. n_cst_dw2Excel lnv_Excel
  179. SAVE_RSLT = lnv_Excel.OF_dw2Excel(obj_dw,sle_filename.Text,'Sheet1')
  180. IF rb_xlsx.Checked = True THEN of_xlsx(sle_filename.Text)
  181. CASE 2 //EXCEL
  182. SAVE_RSLT = obj_dw.SaveAsAscii(sle_filename.Text)
  183. IF rb_xlsx.Checked = True THEN of_xlsx(sle_filename.Text)
  184. CASE 3 //HTML
  185. SAVE_RSLT = obj_dw.SaveAs(sle_filename.Text,HTMLTable!,FALSE)
  186. CASE 4 //TEXT
  187. SAVE_RSLT = obj_dw.SaveAs(sle_filename.Text,Text!,FALSE)
  188. CASE 5 //CLB
  189. SAVE_RSLT = obj_dw.SaveAs(sle_filename.Text,Clipboard!,FALSE)
  190. CASE ELSE
  191. END CHOOSE
  192. If ddlb_1.Text = '不合并' Then
  193. obj_dw.Object.DataWindow.Sparse = ls_Sparse
  194. obj_dw.Modify("DataWindow.HTMLTable.Border='1'")
  195. end if
  196. obj_dw.setredraw(true)
  197. IF SAVE_RSLT = 1 THEN
  198. MessageBox("成功信息","数据发送操作成功!")
  199. ELSE
  200. MessageBox("失败信息","数据发送操作失败!请检查目标文件名称是否拼写正确!")
  201. END IF
  202. //Clipboard! Save to the clipboard
  203. //CSV! ?Comma-separated values
  204. //dBASE2! ?dBASE-II format
  205. //dBASE3! ?dBASE-III format
  206. //DIF! ?Data Interchange Format
  207. //Excel! ?Microsoft Excel format
  208. //Excel5! ?Microsoft Excel 5 format
  209. //HTMLTable! ?Text with HTML formatting that approximates the DataWindow layout
  210. //PSReport! ?Powersoft Report (PSR) format
  211. //SQLInsert! ?SQL syntax
  212. //SYLK! ?Microsoft Multiplan format
  213. //Text! ?(Default) Tab-separated columns with a return at the end of each row
  214. //WKS! ?Lotus 1-2-3 format
  215. //WK1! ?Lotus 1-2-3 format
  216. //WMF! ?Windows Metafile format
  217. end event
  218. type st_1 from statictext within w_sentdataout
  219. integer x = 73
  220. integer y = 32
  221. integer width = 480
  222. integer height = 48
  223. integer textsize = -9
  224. integer weight = 400
  225. fontcharset fontcharset = gb2312charset!
  226. fontpitch fontpitch = variable!
  227. string facename = "宋体"
  228. long textcolor = 33554432
  229. long backcolor = 134217739
  230. string text = "目标发送数据格式:"
  231. boolean focusrectangle = false
  232. end type
  233. type sle_filename from singlelineedit within w_sentdataout
  234. integer x = 96
  235. integer y = 216
  236. integer width = 1559
  237. integer height = 92
  238. integer taborder = 50
  239. integer textsize = -9
  240. integer weight = 400
  241. fontcharset fontcharset = gb2312charset!
  242. fontpitch fontpitch = variable!
  243. string facename = "宋体"
  244. long textcolor = 33554432
  245. borderstyle borderstyle = stylelowered!
  246. end type
  247. type cb_ch from commandbutton within w_sentdataout
  248. integer x = 1659
  249. integer y = 216
  250. integer width = 114
  251. integer height = 92
  252. integer taborder = 60
  253. integer textsize = -9
  254. integer weight = 400
  255. fontcharset fontcharset = gb2312charset!
  256. fontpitch fontpitch = variable!
  257. string facename = "宋体"
  258. string text = "..."
  259. end type
  260. event clicked;string DATAFORMAT=''
  261. integer i
  262. string pathname,filename
  263. CHOOSE CASE ddlb_dataformat_INDEX
  264. CASE 1,2 //EXCEL
  265. DATAFORMAT='XLS'
  266. CASE 3 //HTML
  267. DATAFORMAT='HTML'
  268. CASE 4 //TEXT
  269. DATAFORMAT='TXT'
  270. CASE ELSE
  271. END CHOOSE
  272. i=getfilesavename("给予目标文件名",pathname,filename,DATAFORMAT,ddlb_dataformat.text+',*.'+DATAFORMAT)
  273. IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
  274. sle_filename.text=pathname
  275. END IF
  276. end event
  277. type gb_1 from groupbox within w_sentdataout
  278. integer x = 32
  279. integer y = 136
  280. integer width = 1810
  281. integer height = 216
  282. integer taborder = 30
  283. integer textsize = -9
  284. integer weight = 400
  285. fontcharset fontcharset = gb2312charset!
  286. fontpitch fontpitch = variable!
  287. string facename = "宋体"
  288. long textcolor = 33554432
  289. long backcolor = 134217739
  290. string text = "发送的目标文件路径及名称"
  291. end type
  292. type ddlb_dataformat from dropdownlistbox within w_sentdataout
  293. integer x = 544
  294. integer y = 20
  295. integer width = 654
  296. integer height = 740
  297. integer taborder = 20
  298. boolean bringtotop = true
  299. integer textsize = -9
  300. integer weight = 400
  301. fontcharset fontcharset = gb2312charset!
  302. fontpitch fontpitch = variable!
  303. string facename = "宋体"
  304. long textcolor = 33554432
  305. boolean sorted = false
  306. boolean vscrollbar = true
  307. string item[] = {"Excel 完整(*.xls)","Excel 快速(*.xls)","HTML (*.htmL)","Text (*.txt)","剪切板"}
  308. borderstyle borderstyle = stylelowered!
  309. end type
  310. event constructor;if THIS.TotalItems ( )>=1 then THIS.SelectItem(1)
  311. end event
  312. event selectionchanged;ddlb_dataformat_INDEX = Index
  313. IF Index = 4 THEN
  314. sle_filename.Enabled = False
  315. cb_ch.Enabled = False
  316. ELSE
  317. sle_filename.Enabled = True
  318. cb_ch.Enabled = True
  319. END IF
  320. sle_filename.Text = ''
  321. IF Pos(This.Text,'xls') <= 0 THEN
  322. rb_xls.Visible = False
  323. rb_xlsx.Visible = False
  324. ELSE
  325. rb_xls.Visible = True
  326. rb_xlsx.Visible = True
  327. END IF
  328. end event
  329. type rb_xls from radiobutton within w_sentdataout
  330. integer x = 1289
  331. integer y = 36
  332. integer width = 256
  333. integer height = 60
  334. boolean bringtotop = true
  335. integer textsize = -9
  336. integer weight = 400
  337. fontcharset fontcharset = gb2312charset!
  338. fontpitch fontpitch = variable!
  339. string facename = "宋体"
  340. long textcolor = 33554432
  341. long backcolor = 67108864
  342. string text = "xls"
  343. boolean checked = true
  344. end type
  345. event constructor;Long ls_show_save
  346. //ls_show_save = Long(ProfileString (sys_inifilename,publ_userid+'_'+String('xlsq'), "xls",'0'))
  347. ls_show_save=long(f_ProfileString (sys_empid,publ_userid+'_'+String('xlsq'), "xls",'0'))
  348. IF ls_show_save = 0 THEN
  349. rb_xls.Checked = True
  350. rb_xlsx.Checked = False
  351. ELSE
  352. rb_xls.Checked = false
  353. rb_xlsx.Checked = True
  354. END IF
  355. end event
  356. event destructor;
  357. long ll_xls
  358. if rb_xls.checked=true then
  359. ll_xls=0
  360. else
  361. ll_xls=1
  362. end if
  363. //f_SetProfileString(SYS_INIFILENAME, publ_userid+'_'+String('xlsq'), "xls", String(ll_xls))
  364. f_SetProfileString (sys_empid,publ_userid+'_'+String('xlsq'), "xls",String(ll_xls))
  365. end event
  366. type rb_xlsx from radiobutton within w_sentdataout
  367. integer x = 1577
  368. integer y = 36
  369. integer width = 256
  370. integer height = 60
  371. boolean bringtotop = true
  372. integer textsize = -9
  373. integer weight = 400
  374. fontcharset fontcharset = gb2312charset!
  375. fontpitch fontpitch = variable!
  376. string facename = "宋体"
  377. long textcolor = 33554432
  378. long backcolor = 67108864
  379. string text = "xlsx"
  380. end type
  381. type ddlb_1 from dropdownlistbox within w_sentdataout
  382. integer x = 1920
  383. integer y = 108
  384. integer width = 507
  385. integer height = 300
  386. integer taborder = 30
  387. boolean bringtotop = true
  388. integer textsize = -9
  389. integer weight = 400
  390. fontcharset fontcharset = gb2312charset!
  391. fontpitch fontpitch = variable!
  392. string facename = "宋体"
  393. long textcolor = 33554432
  394. boolean sorted = false
  395. string item[] = {"不合并","按原格式"}
  396. borderstyle borderstyle = stylelowered!
  397. end type
  398. type st_2 from statictext within w_sentdataout
  399. integer x = 1920
  400. integer y = 32
  401. integer width = 507
  402. integer height = 48
  403. boolean bringtotop = true
  404. integer textsize = -9
  405. integer weight = 400
  406. fontcharset fontcharset = gb2312charset!
  407. fontpitch fontpitch = variable!
  408. string facename = "宋体"
  409. long textcolor = 33554432
  410. long backcolor = 67108864
  411. string text = "相同数据列显示方式"
  412. boolean focusrectangle = false
  413. end type