[ABAP] ABAP2XLSX: CSV-Datei schreiben

TRY.
* Daten holen
    SELECT * FROM sflight INTO TABLE @DATA(it_sflight).

* ABAP2XLSX-Objekt
    DATA: o_xl TYPE REF TO zcl_excel.

* Converter itab->ABAP2XLSX
    DATA(o_xl_conv) = NEW zcl_excel_converter( ).
    o_xl_conv->convert( EXPORTING it_table = it_sflight
                        CHANGING  co_excel = o_xl ).

* CSV-Writer-Objekt erzeugen
    DATA(o_csv) = NEW zcl_excel_writer_csv( ).
    o_csv->set_delimiter( ip_value = ';' ).
    o_csv->set_enclosure( ip_value = '''' ).
    o_csv->set_endofline( ip_value = cl_abap_char_utilities=>cr_lf ).
    o_csv->set_active_sheet_index( i_active_worksheet = 1 ).

* Excel-Writer-Objekt erzeugen
    DATA(o_writer) = CAST zif_excel_writer( o_csv ).
* Excel-Writer-Objekt->xstring
    DATA(lv_xstr) = o_writer->write_file( o_xl ).

* xstring -> solix
    DATA(it_solix_data) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xstr ).

* CSV-Daten lokal speichern (binär übertragen)
    cl_gui_frontend_services=>gui_download( EXPORTING filename     = 'Test.csv'
                                                      filetype     = 'BIN'
                                                      bin_filesize = xstrlen( lv_xstr )
                                            CHANGING  data_tab     = it_solix_data ).

  CATCH cx_root INTO DATA(e_txt).
    WRITE: / e_txt->get_text( ).
ENDTRY.