函数: 'ALSM_EXCEL_TO_INTERNAL_TABLE'
DATA: I_EXCEL type table of ALSMEX_TABLINE.
CLEAR : I_EXCEL[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = lv_fieldname ”文件路径
i_begin_col = l_bcol "起始列
i_begin_row = l_brow “起始行
i_end_col = l_ecol ”终止列
i_end_row = l_erow “终止行
TABLES
intern = I_EXCEL
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAAGE.....
ENDIF.
此时Excel表格中的数据会按照 ROW COL VALUE 的格式存储到内表I_EXCEL中.
接下来则需要对固定格式的数据进一步处理,以存放至数据库表格中。
DATA: num_col type i.
LOOP at I_EXCEL into w_excel
num_col = w_excel-col.
ASSIGN COMPONENT num_col OF STRUCTURE w_table TO <FS>.
<FS> = w_excel-value.
AT END OF ROW.
APPEND w_table to i_table.
clear w_table.
ENDAT.
CLEAR:e_excel.
ENDLOOP.
MODIFY <数据库表> FROM TABLE i_TABLE.