货铺QQ群号:834508274
下面开始干货:
上篇OLE中Excel单元格赋值,使用的是
PERFORM fill_range 填充行
PERFORM insert_row 添加新行
其中
FORM fill_range USING value(f_range)
value(f_value).
CALL METHOD OF
wsheetobj
'Range' = rangeobj
EXPORTING
#1 = f_range.
SET PROPERTY OF rangeobj 'Value' = f_value.
ENDFORM. "fill_range
很多时候是直接用的Excel 行列直接进行赋值。
具体demo不做了,这里只写几个用到的form
*&---------------------------------------------------------------------*标签:SET,OLE,demo,Excel,FRM,CELL,EXCEL,ROW From: https://blog.51cto.com/u_15680210/5727550
* 打开EXCEL
*----------------------------------------------------------------------*
* -->P_L_FILE text
*----------------------------------------------------------------------*
Form FRM_EXCEL_OPEN Using P_L_FILE.
Create OBJECT EXCEL 'EXCEL.APPLICATION'.
If SY-SUBRC <> 0.
Message 'Excel开打失败!.' Type 'S'.
Stop.
Else.
Set Property Of EXCEL 'VISIBLE' = 1.
Call Method Of EXCEL 'WORKBOOKS' = WORKBOOK. "新产生一个Excel
Call Method Of WORKBOOK 'OPEN'
Exporting
#1 = P_L_FILE. "要打开的Excel的路径
Get Property Of EXCEL 'ACTIVECELL' = SHEET.
Endif.
Call Method Of EXCEL 'WORKSHEETS' = SHEET
Exporting
#1 = 'SHEET1'.
Call Method Of SHEET 'ACTIVATE'.
Endform. " FRM_EXCEL_OPEN
*&---------------------------------------------------------------------*
*& Form FRM_CELL_SET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ROW 第几行
* -->P_COL 第几列
* -->P_D_BUTXT 要填的值
*----------------------------------------------------------------------*
Form FRM_CELL_SET Using P_ROW
P_COL
P_D_BUTXT.
Call Method Of SHEET 'CELLS' = CELL
Exporting
#1 = P_ROW
#2 = P_COL.
Set Property Of CELL 'VALUE' = P_D_BUTXT.
Endform. " FRM_CELL_SET
Loop At lT_data into ls_data.
Perform FRM_CELL_SET Using L_ROW 1 ls_data-C01.
Perform FRM_CELL_SET Using L_ROW 2 ls_data-c02.
L_ROW = L_ROW + 1.
Endloop.