I know this is a very old topic, but I didn't find easy solution for this. My solution is simple to output the internal table data to XLSX file. Just choose the file name by F4 help, make sure you give the extension 'xlsx'.
The solution is based on the built in functions of cl_salv_table class. I hope this will help you. Please let me know your comments and suggestions. Please ignore the naming conventions and untidiness of the code. 🙂
BEGIN OF ty_s_cline,
line TYPE c LENGTH 1024, " Line of type Character
END OF ty_s_cline .
DATA: gr_table TYPE REF TO cl_salv_table, " Basis Class for Simple Tables
gt_outtab TYPE STANDARD TABLE OF sflight, " Flight
lr_functions TYPE REF TO cl_salv_functions_list, " Generic and User-Defined Functions in List-Type Tables
lr_layout TYPE REF TO cl_salv_layout, " Settings for Layout
lv_xml_type TYPE salv_bs_constant,
lv_xml TYPE xstring,
gt_srctab TYPE STANDARD TABLE OF ty_s_cline,
gt_len TYPE i, " Len of type Integers
lv_file_xlsx TYPE string,
lv_file TYPE localfile, " Local file for upload/download
ls_key TYPE salv_s_layout_key, " Layout Key
lr_content TYPE REF TO cl_salv_form_element. " General Element in Design Object
PARAMETERS: p_file TYPE localfile. " Local file for upload/download
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
file_name = lv_file.
p_file = lv_file.
lv_file_xlsx = lv_file.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_outtab UP TO 100 ROWS.