我想遍历一个表并将表中的每一行数据写入excel文档。
LOOP AT IT_Table INTO ST_Table.
IF IT_Table[] IS NOT INITIAL.
DELETE FROM ZLN.
MOVE-CORRESPONDING IT_Table[] TO IT_ZLN[].
MODIFY ZLN FROM TABLE IT_ZLN.
"Code here to write to excel
ENDIF.
ENDLOOP.
答案 0 :(得分:0)
FM GUI_DOWNLOAD - 第一个标题,然后追加行。
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = "C:\myexcel.xls"
TABLES
data_tab = lt_hdr.
LOOP AT it_table INTO st_table.
... "here your code
APPEND st_table to it_output.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = "C:\myexcel.xls"
append = 'X' "this will append line to your file
TABLES
data_tab = it_output. "table with one record wich you should collect
CLEAR it_output.
ENDLOOP.
SAP_CONVERT_TO_XLS_FORMAT可以阅读有关此FM
的信息