EXCEL
文件导入
ABAP
内表中?
ALSM_EXCEL_TO_INTERNAL_TABLE
读取
excel
文件中的内容,放入类型为
alsmex_tabline
的内中。然后你可以把这个表中的内容插入到你想放入的内表中:
REPORT ZIMPEXCEL .
TYPES: BEGIN OF ty_upload,
field1(12) TYPE c,
field2(12) TYPE c,
field3(12) TYPE c,
END OF ty_upload.
DATA: it_upload TYPE STANDARD TABLE OF ty_upload,
wa_upload TYPE ty_upload,
itab TYPE STANDARD TABLE OF alsmex_tabline WITH DEFAULT KEY.
FIELD-SYMBOLS: <wa_itab> TYPE alsmex_tabline.
CALL FUNCTION ‘ALSM_EXCEL_TO_INTERNAL_TABLE’
EXPORTING
FILENAME = ‘c:/test.xls’
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 3
I_END_ROW = 65535
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
SORT itab BY row.
LOOP AT itab ASSIGNING <wa_itab>.
CASE <wa_itab>-col.
WHEN ‘0001’.
wa_upload-field1 = <wa_itab>-value.
WHEN ‘0002’.
wa_upload-field2 = <wa_itab>-value.
WHEN ‘0003’.
wa_upload-field3 = <wa_itab>-value.
ENDCASE.
AT END OF row.
APPEND wa_upload TO it_upload.
CLEAR wa_upload.
ENDAT.
ENDLOOP.
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/18251.html