ABAP:把内表中的内容导出为excel文件

时间:2023-02-10 09:21:10

REPORT ZEXPEXCEL .
PARAMETERS: p_file TYPE rlgrap-filename DEFAULT 'C:/TEST.XLS'.
DATA: t100_lines TYPE STANDARD TABLE OF t001 WITH DEFAULT KEY.

SELECT * FROM t001 INTO TABLE t100_lines.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
  EXPORTING
*   I_FIELD_SEPERATOR          =
*   I_LINE_HEADER              =
    I_FILENAME                 = p_file
*   I_APPL_KEEP                = ' '
  TABLES
    I_TAB_SAP_DATA             = t100_lines
* CHANGING
*   I_TAB_CONVERTED_DATA       =
  EXCEPTIONS
    CONVERSION_FAILED          = 1
    OTHERS                     = 2
          .
IF SY-SUBRC <> 0.
ENDIF.