Code: Alles auswählen.
* Daten holen
SELECT * FROM sflight INTO TABLE @DATA(it_sflight).
TRY.
* ABAP2XLSX
DATA: o_xl TYPE REF TO zcl_excel.
* Converter itab->ABAP2XLSX
DATA(o_converter) = NEW zcl_excel_converter( ).
o_converter->convert( EXPORTING
it_table = it_sflight
CHANGING
co_excel = o_xl ).
* aktive Worksheet
DATA(o_xl_ws) = o_xl->get_active_worksheet( ).
* oberste Zeile einfrieren -> beim Scrollen immer sichtbar
o_xl_ws->freeze_panes( ip_num_rows = 1 ).
* Daten mit DOI (Excel inplace) anzeigen
DATA(o_xlwriter) = CAST zif_excel_writer( NEW zcl_excel_writer_2007( ) ).
DATA(lv_xl_xdata) = o_xlwriter->write_file( o_xl ).
DATA: o_oic TYPE REF TO i_oi_container_control.
DATA: o_oid TYPE REF TO i_oi_document_proxy.
DATA: o_err TYPE REF TO i_oi_error.
c_oi_container_control_creator=>get_container_control( IMPORTING
control = o_oic
error = o_err ).
IF abap_true = o_err->has_succeeded.
o_oic->init_control( EXPORTING
inplace_enabled = abap_true
no_flush = abap_true
r3_application_name = 'Flugverbindungen'
parent = cl_gui_container=>default_screen
IMPORTING
error = o_err ).
IF abap_true = o_err->has_succeeded.
o_oic->get_document_proxy( EXPORTING
document_type = 'Excel.Sheet'
no_flush = ' '
IMPORTING
document_proxy = o_oid
error = o_err ).
IF abap_true = o_err->has_succeeded.
DATA(it_raw) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xl_xdata ).
DATA(lv_rawlen) = xstrlen( lv_xl_xdata ).
* Binärdaten des *.xlsx im Hintergrund an DOI-Objekt senden und anzeigen
o_oid->open_document_from_table( EXPORTING
document_size = lv_rawlen
document_table = it_raw
open_inplace = abap_true ).
* leere Toolbar ausblenden
cl_abap_list_layout=>suppress_toolbar( ).
* cl_gui_container=>default_screen erzwingen
WRITE space.
ENDIF.
ENDIF.
ENDIF.
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.