And it worked very well. You simply need to pass your internal table reference to the method, get the excel content in xstring and transfer it to application server.
GET REFERENCE OF it_out_rec INTO DATA(lo_data_ref).
DATA(lv_xstring) = NEW zcl_itab_to_excel( )->itab_to_xstring( lo_data_ref ).
OPEN DATASET lv_xls_file FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
TRANSFER lv_xstring TO lv_xls_file.
It is easy to create excel file on application server with help of the SALV and related classes
This method also works well if xlsx attachment is required to be sent in an email
This method also helps formatting the excel with aggregations and layout settings. Explore class cl_salv_controller_metadata for more details.
Your comments and suggestions are welcome to further improve this code. Please use the comment section below or you can also post your questions here.