久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

ABAP操作EXECL詳細

 一騎當(dāng)千_30 2018-09-03
  1. REPORT ZVR013.
  2. INCLUDE ole2incl.
  3. DATA: gs_excel TYPE ole2_object,
  4. gs_wbooklist TYPE ole2_object,
  5. gs_application TYPE ole2_object,
  6. gs_wbook TYPE ole2_object,
  7. gs_activesheet TYPE ole2_object,
  8. gs_sheets TYPE ole2_object,
  9. gs_newsheet TYPE ole2_object,
  10. gs_cell1 TYPE ole2_object,
  11. gs_cell2 TYPE ole2_object,
  12. gs_cells TYPE ole2_object,
  13. gs_font TYPE ole2_object,
  14. gs_page TYPE ole2_object,
  15. gs_range type ole2_object,
  16. gs_borders type ole2_object.
  17. DATA: gv_sheet_name(20) TYPE c.
  18. DATA: gv_outer_index LIKE sy-index.
  19. DATA: gv_intex(2) TYPE c.
  20. DATA: gv_line_cntr TYPE i. 'line counter
  21. DATA: gv_linno TYPE i. 'line number
  22. DATA: gv_colno TYPE i. 'column number
  23. DATA: gv_value TYPE i. 'data
  24. data: x1 type p, x2 type p, y1 type p, y2 type p.
  25. data: value(100),value1(100).
  26. data: name(20),size(2).
  27. data: bold type p, underline type p, Alignment type p.
  28. data: row type p value 11, line type p value 1. '循環(huán)次數(shù)
  29. data: row1 type p,line1 type p.
  30. data: quantity(20),amount(20).
  31. data: rowheight(10),columnwidth(10).
  32. data: page type p, pg_index type p.
  33. *-----------------------------------------------------------
  34. *-----------------------------------------------------------
  35. CREATE OBJECT gs_excel 'EXCEL.APPLICATION'.
  36. SET PROPERTY OF gs_excel 'Visible' = 1.
  37. GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooklist.
  38. GET PROPERTY OF gs_wbooklist 'Application' = gs_application.
  39. SET PROPERTY OF gs_application 'SheetsInNewWorkbook' = 1.
  40. CALL METHOD OF gs_wbooklist 'Add' = gs_wbook.
  41. GET PROPERTY OF gs_application 'ActiveSheet' = gs_activesheet.
  42. SET PROPERTY OF gs_activesheet 'Name' = gv_sheet_name.
  43. get property of gs_activesheet 'pagesetup' = gs_page.
  44. set property of gs_page 'TopMargin' = '25'.
  45. set property of gs_page 'BottomMargin' = '25'.
  46. set property of gs_page 'LeftMargin' = '25'.
  47. set property of gs_page 'RightMargin' = '25'.
  48. *--Formatting the title
  49. form format using gs_cell1 value name size bold alignment underline.
  50. condense value.
  51. condense name.
  52. condense size.
  53. GET PROPERTY OF gs_cell1 'Font' = gs_font .
  54. SET PROPERTY OF gs_font 'Name' = name.
  55. SET PROPERTY OF gs_font 'Size' = size.
  56. SET PROPERTY OF gs_font 'Bold' = bold. 'Not bold
  57. SET PROPERTY OF gs_font 'Italic' = '1'. 'Not Italic
  58. SET PROPERTY OF gs_font 'Underline' = underline. 'Not underlined
  59. SET PROPERTY OF gs_cell1 'WrapText' = 1.
  60. SET PROPERTY OF gs_cell1 'horizontalAlignment' = alignment.
  61. ' && 水平方向 2左對齊,3居中,,4右對齊
  62. SET PROPERTY OF gs_cell1 'VerticalAlignment' = 2.
  63. '&& 垂直方向 1靠上 ,2居中,3靠下
  64. set property of gs_cell1 'NumberFormatLocal' = '@'.
  65. '&& 設(shè)置數(shù)據(jù)格式
  66. SET PROPERTY OF gs_cell1 'Value' = value.
  67. endform. 'format
  68. *------------------------------
  69. *該函數(shù)用來合并excel單元格
  70. *------------------------------
  71. form merged using x1 y1 x2 y2.
  72. *--Selecting cell area to be merged.
  73. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  74. EXPORTING
  75. #1 = x1
  76. #2 = y1.
  77. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  78. EXPORTING
  79. #1 = x2
  80. #2 = y2.
  81. CALL METHOD OF gs_excel 'Range' = gs_cells
  82. EXPORTING
  83. #1 = gs_cell1
  84. #2 = gs_cell2.
  85. CALL METHOD OF gs_cells 'Select'.
  86. *--Merging
  87. CALL METHOD OF gs_cells 'Merge' .
  88. endform. 'merged
  89. *---------------------------------
  90. *生成四周有邊框的單元格
  91. *---------------------------------
  92. form merged_borders using x1 y1 x2 y2.
  93. *--Selecting cell area to be merged.
  94. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  95. EXPORTING
  96. #1 = x1
  97. #2 = y1.
  98. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  99. EXPORTING
  100. #1 = x2
  101. #2 = y2.
  102. CALL METHOD OF gs_excel 'Range' = gs_cells
  103. EXPORTING
  104. #1 = gs_cell1
  105. #2 = gs_cell2.
  106. CALL METHOD OF gs_cells 'Select'.
  107. *--Merging
  108. CALL METHOD OF gs_cells 'Merge' .
  109. GET PROPERTY OF gs_cells 'borders' = gs_range .
  110. SET PROPERTY OF gs_range 'weight' = '2'.
  111. SET PROPERTY OF gs_range 'linestyle' = '1'.
  112. FREE OBJECT gs_range.
  113. endform. 'merged
  114. *--------------------------------------
  115. *---------------------------------
  116. *生成左右有邊框的單元格
  117. *---------------------------------
  118. form sides_borders using x1 y1 x2 y2.
  119. *--Selecting cell area to be merged.
  120. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  121. EXPORTING
  122. #1 = x1
  123. #2 = y1.
  124. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  125. EXPORTING
  126. #1 = x2
  127. #2 = y2.
  128. CALL METHOD OF gs_excel 'Range' = gs_cells
  129. EXPORTING
  130. #1 = gs_cell1
  131. #2 = gs_cell2.
  132. CALL METHOD OF gs_cells 'Select'.
  133. *--Merging
  134. CALL METHOD OF gs_cells 'Merge' .
  135. CALL METHOD OF gs_cells 'BORDERS' = gs_borders
  136. EXPORTING
  137. #1 = '1'.
  138. SET PROPERTY OF gs_borders 'LINESTYLE' = '1'.
  139. SET PROPERTY OF gs_borders 'WEIGHT' = 2.
  140. FREE OBJECT gs_borders.
  141. CALL METHOD OF gs_cells 'BORDERS' = gs_borders
  142. EXPORTING
  143. #1 = '2'.
  144. SET PROPERTY OF gs_borders 'LINESTYLE' = '7'.
  145. *& (其中Borders參數(shù):1-左,、2-右,、3-頂、4-底,、5-斜、6-斜/,;
  146. *&LineStyle值:1與7-細實,、2-細虛、4-點虛,、9-雙細實線)
  147. SET PROPERTY OF gs_borders 'WEIGHT' = 2.
  148. FREE OBJECT gs_borders.
  149. endform. 'merged
  150. *---------------------------------
  151. form left_borders using x1 y1 x2 y2.
  152. *--Selecting cell area to be merged.
  153. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  154. EXPORTING
  155. #1 = x1
  156. #2 = y1.
  157. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  158. EXPORTING
  159. #1 = x2
  160. #2 = y2.
  161. CALL METHOD OF gs_excel 'Range' = gs_cells
  162. EXPORTING
  163. #1 = gs_cell1
  164. #2 = gs_cell2.
  165. CALL METHOD OF gs_cells 'Select'.
  166. *--Merging
  167. CALL METHOD OF gs_cells 'Merge' .
  168. CALL METHOD OF gs_cells 'BORDERS' = gs_borders
  169. EXPORTING
  170. #1 = '1'.
  171. SET PROPERTY OF gs_borders 'LINESTYLE' = '1'.
  172. SET PROPERTY OF gs_borders 'WEIGHT' = 2.
  173. FREE OBJECT gs_borders.
  174. endform. 'merged
  175. form right_borders using x1 y1 x2 y2.
  176. *--Selecting cell area to be merged.
  177. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  178. EXPORTING
  179. #1 = x1
  180. #2 = y1.
  181. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  182. EXPORTING
  183. #1 = x2
  184. #2 = y2.
  185. CALL METHOD OF gs_excel 'Range' = gs_cells
  186. EXPORTING
  187. #1 = gs_cell1
  188. #2 = gs_cell2.
  189. CALL METHOD OF gs_cells 'Select'.
  190. *--Merging
  191. CALL METHOD OF gs_cells 'Merge' .
  192. CALL METHOD OF gs_cells 'BORDERS' = gs_borders
  193. EXPORTING
  194. #1 = '2'.
  195. SET PROPERTY OF gs_borders 'LINESTYLE' = '1'.
  196. SET PROPERTY OF gs_borders 'WEIGHT' = 2.
  197. FREE OBJECT gs_borders.
  198. endform. 'merged
  199. *---------------------------------
  200. *生成bottom有邊框的單元格
  201. *---------------------------------
  202. form bottom_borders using x1 y1 x2 y2.
  203. *--Selecting cell area to be merged.
  204. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  205. EXPORTING
  206. #1 = x1
  207. #2 = y1.
  208. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  209. EXPORTING
  210. #1 = x2
  211. #2 = y2.
  212. CALL METHOD OF gs_excel 'Range' = gs_cells
  213. EXPORTING
  214. #1 = gs_cell1
  215. #2 = gs_cell2.
  216. CALL METHOD OF gs_cells 'Select'.
  217. *--Merging
  218. CALL METHOD OF gs_cells 'Merge' .
  219. CALL METHOD OF gs_cells 'BORDERS' = gs_borders
  220. EXPORTING
  221. #1 = '4'.
  222. SET PROPERTY OF gs_borders 'LINESTYLE' = '7'.
  223. SET PROPERTY OF gs_borders 'WEIGHT' = 2.
  224. FREE OBJECT gs_borders.
  225. endform. 'merged
  226. form bottom_lines using x1 y1 x2 y2.
  227. *--Selecting cell area to be merged.
  228. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  229. EXPORTING
  230. #1 = x1
  231. #2 = y1.
  232. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  233. EXPORTING
  234. #1 = x2
  235. #2 = y2.
  236. CALL METHOD OF gs_excel 'Range' = gs_cells
  237. EXPORTING
  238. #1 = gs_cell1
  239. #2 = gs_cell2.
  240. CALL METHOD OF gs_cells 'Select'.
  241. *--Merging
  242. CALL METHOD OF gs_cells 'Merge' .
  243. CALL METHOD OF gs_cells 'BORDERS' = gs_borders
  244. EXPORTING
  245. #1 = '4'.
  246. SET PROPERTY OF gs_borders 'LINESTYLE' = '9'.
  247. SET PROPERTY OF gs_borders 'WEIGHT' = 5.
  248. FREE OBJECT gs_borders.
  249. endform. 'merged
  250. *-------------------------------------------------
  251. *設(shè)置行高和列寬,。
  252. form row_column using x1 y1 x2 y2 rowheight columnwidth.
  253. *--Selecting cell area to be merged.
  254. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  255. EXPORTING
  256. #1 = x1
  257. #2 = y1.
  258. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  259. EXPORTING
  260. #1 = x2
  261. #2 = y2.
  262. CALL METHOD OF gs_excel 'Range' = gs_cells
  263. EXPORTING
  264. #1 = gs_cell1
  265. #2 = gs_cell2.
  266. CALL METHOD OF gs_cells 'Select'.
  267. *--Merging
  268. CALL METHOD OF gs_cells 'Merge' .
  269. get property of gs_cells 'rows' = gs_borders.
  270. SET PROPERTY OF gs_borders 'rowheight' = rowheight.
  271. GET PROPERTY OF gs_cells 'columns' = gs_range .
  272. SET PROPERTY OF gs_range 'columnwidth' = columnwidth.
  273. FREE OBJECT gs_borders.
  274. FREE OBJECT gs_range.
  275. endform. 'merged
  276. form rowheight using x1 y1 x2 y2 rowheight.
  277. *--Selecting cell area to be merged.
  278. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  279. EXPORTING
  280. #1 = x1
  281. #2 = y1.
  282. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  283. EXPORTING
  284. #1 = x2
  285. #2 = y2.
  286. CALL METHOD OF gs_excel 'Range' = gs_cells
  287. EXPORTING
  288. #1 = gs_cell1
  289. #2 = gs_cell2.
  290. CALL METHOD OF gs_cells 'Select'.
  291. *--Merging
  292. CALL METHOD OF gs_cells 'Merge' .
  293. get property of gs_cells 'rows' = gs_borders.
  294. SET PROPERTY OF gs_borders 'rowheight' = rowheight.
  295. * GET PROPERTY OF gs_cells 'columns' = gs_range .
  296. * SET PROPERTY OF gs_range 'columnwidth' = columnwidth.
  297. FREE OBJECT gs_borders.
  298. FREE OBJECT gs_range.
  299. endform. 'merged
  300. form columnwidth using x1 y1 x2 y2 columnwidth.
  301. *--Selecting cell area to be merged.
  302. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  303. EXPORTING
  304. #1 = x1
  305. #2 = y1.
  306. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  307. EXPORTING
  308. #1 = x2
  309. #2 = y2.
  310. CALL METHOD OF gs_excel 'Range' = gs_cells
  311. EXPORTING
  312. #1 = gs_cell1
  313. #2 = gs_cell2.
  314. CALL METHOD OF gs_cells 'Select'.
  315. *--Merging
  316. CALL METHOD OF gs_cells 'Merge' .
  317. * get property of gs_cells 'rows' = gs_borders.
  318. * SET PROPERTY OF gs_borders 'rowheight' = rowheight.
  319. GET PROPERTY OF gs_cells 'columns' = gs_range .
  320. SET PROPERTY OF gs_range 'columnwidth' = columnwidth.
  321. FREE OBJECT gs_borders.
  322. FREE OBJECT gs_range.
  323. endform. 'merged
  324. ********************************************************
  325. form pages using l_file x y.
  326. x1 = 1.
  327. y1 = 1.
  328. x2 = x.
  329. y2 = y.
  330. *do page times.
  331. *_-create excel
  332. CONCATENATE 'Sheet' '1' INTO gv_sheet_name.
  333. CREATE OBJECT gs_excel 'EXCEL.APPLICATION'.
  334. SET PROPERTY OF gs_excel 'Visible' = 1.
  335. GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooklist.
  336. *----copy
  337. CALL METHOD OF gs_wbooklist 'open' = gs_range
  338. EXPORTING
  339. #1 = l_file.
  340. CALL METHOD OF gs_excel 'Worksheets' = gs_borders
  341. EXPORTING #1 = 1.
  342. CALL METHOD OF gs_borders 'Activate'.
  343. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  344. EXPORTING
  345. #1 = 1
  346. #2 = 1.
  347. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  348. EXPORTING
  349. #1 = x
  350. #2 = y.
  351. CALL METHOD OF gs_excel 'Range' = gs_cells
  352. EXPORTING
  353. #1 = gs_cell1
  354. #2 = gs_cell2.
  355. CALL METHOD OF gs_cells 'copy'.
  356. *----PasteSpecial
  357. *-create
  358. CALL METHOD OF gs_wbooklist 'Add' = gs_wbook.
  359. GET PROPERTY OF gs_application 'ActiveSheet' = gs_activesheet.
  360. SET PROPERTY OF gs_activesheet 'Name' = gv_sheet_name.
  361. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  362. EXPORTING
  363. #1 = 1
  364. #2 = 1.
  365. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  366. EXPORTING
  367. #1 = x
  368. #2 = y.
  369. CALL METHOD OF gs_excel 'Range' = gs_cells
  370. EXPORTING
  371. #1 = gs_cell1
  372. #2 = gs_cell2.
  373. CALL METHOD OF gs_cells 'PasteSpecial'.
  374. CALL METHOD OF gs_cells 'copy'.
  375. call method OF gs_range 'Activate'.
  376. CALL METHOD OF gs_range 'close'.
  377. call method OF gs_activesheet 'Activate'.
  378. endform.
  379. *-------------------------------------------------
  380. form pages1 using x y.
  381. do page times.
  382. x1 = x1 x.
  383. y1 = 1.
  384. x2 = x2 x.
  385. y2 = y.
  386. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  387. EXPORTING
  388. #1 = 1
  389. #2 = 1.
  390. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  391. EXPORTING
  392. #1 = x
  393. #2 = y.
  394. CALL METHOD OF gs_excel 'Range' = gs_cells
  395. EXPORTING
  396. #1 = gs_cell1
  397. #2 = gs_cell2.
  398. CALL METHOD OF gs_cells 'copy'.
  399. CALL METHOD OF gs_excel 'Cells' = gs_cell1
  400. EXPORTING
  401. #1 = x1
  402. #2 = y1.
  403. CALL METHOD OF gs_excel 'Cells' = gs_cell2
  404. EXPORTING
  405. #1 = x2
  406. #2 = y2.
  407. CALL METHOD OF gs_excel 'Range' = gs_cells
  408. EXPORTING
  409. #1 = gs_cell1
  410. #2 = gs_cell2.
  411. CALL METHOD OF gs_cells 'PasteSpecial'.
  412. enddo.
  413. endform.

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點,。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多