1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
*&---------------------------------------------------------------------* *& Report Z_TEST_2 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT Z_TEST_2. *---------------------------OLE----------------------------------* include ole2incl. data: excel type ole2_object, " Excel object workbook type ole2_object, " Workbook object sheet type ole2_object, " Worksheet object range type ole2_object, " Range object cell type ole2_object. " Cell object data: sheet_name(20) value 'BS'. "Excel文件里的sheet name data local_file like rcgfiletr-ftfront."下载文件类型 local_file = 'c<img src="//www.ut163.com/wp-content/uploads/2019/08/20190829101429-10.gif" border="0" alt="" />O_TEST_OLE.xls'. START-OF-SELECTION. data: c1 type i, c2 type i, c3 type i, c4 type i. create object excel 'EXCEL.APPLICATION'. " CREATE EXCEL OBJECT if sy-subrc ne 0. write: / 'Excel init failed, return code is ', sy-subrc. exit. endif. set property of excel 'Visible' = 1. call method of excel 'Workbooks' = workbook. data h type i. call method of workbook 'Open' exporting #1 = local_file. call method of excel 'Sheets' = sheet exporting #1 = sheet_name. call method of sheet 'SELECT' . *填充抬头 perform fill_range using 1 1 'F_TEST1'. perform fill_range using 1 2 'F_TEST2'. free object excel. free object workbook. free object sheet. free object range. free object cell. *---------------------------------------------------------------------* * FORM fill_range * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> VALUE(F_ROW) * * --> VALUE(F_COL) * * --> VALUE(F_VALUE) * *---------------------------------------------------------------------* form fill_range using value(f_row) value(f_col) value(f_value). call method of excel 'CELLS' = cell exporting #1 = f_row #2 = f_col. set property of cell 'VALUE' = f_value. endform. "FILL_RANGE |
2019
08-29
08-29