DEFINE transe_excel_into_intertable.
data : l_intern like alsmex_tabline occurs 0 with header line.
data : l_index type i.
field-symbols : <fs>.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = &1
i_begin_col = &2
i_begin_row = &3
i_end_col = &4
i_end_row = &5
tables
intern = l_intern
exceptions
inconsistent_parameters = 1
upload_ole = 2.
* OTHERS = 3.
loop at l_intern.
move l_intern-col to l_index.
assign component l_index of structure &6 to <fs>.
move l_intern-value to <fs>.
at end of row.
append &6.
clear &6.
endat.
endloop.
END-OF-DEFINITION.
PARAMETERS: SRC_FILE LIKE RLGRAP-FILENAME LOWER CASE DEFAULT
'C:/homedir/ipe_range.xls'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR src_file.
PERFORM select_file CHANGING src_file.
START-OF-SELECTION.
******************************Upload Data from File*********************
transe_excel_into_intertable src_file 1 2 7 1000 s_itab.
FORM select_file CHANGING src_file.
DATA: l_rc TYPE i,
l_filetable TYPE filetable.
* Open The txt File
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = '请选择导入文件'
file_filter = 'Excel(*.XLS)|*.XLS|全部文件 (*.*)|*.*|'
multiselection = space
CHANGING
file_table = l_filetable
rc = l_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc = 0 AND l_rc = 1.
READ TABLE l_filetable INTO src_file INDEX 1.
ENDIF.
ENDFORM. "SELECT_FILE