Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP: Export formatted excel in 'XLSX' format

0 Kudos

Hi,

We have created a formatted excel in ABAP using XML-XSLT(Simple transformation) and are able to export it in .XLS format. Would like to know if there's a way to export it in .XLSX format. Looking for a way to convert the XML to XLSX format instead of XLS.

Sample code:

*File selection
    clear: lv_path, lv_user_action, lv_default_extension, lv_default_file_name, lv_file_filter, lv_filename.
    move '.xls' to lv_default_extension.
    move 'Excel files(*.xls)|*.xls' to lv_file_filter. " description|*.extension
    move 'Formatted_Excel' to lv_default_file_name.

    cl_gui_frontend_services=>file_save_dialog(
      exporting
        default_extension = lv_default_extension
        default_file_name = lv_default_file_name
        file_filter       = lv_file_filter
      changing
        filename          = lv_filename
        path              = lv_path
        fullpath          = lv_fullpath
        user_action       = lv_user_action
      exceptions
        cntl_error        = 1
        error_no_gui      = 2
        others            = 3 ).

    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

    check lv_fullpath is not initial and lt_xml is not initial.

    cl_gui_frontend_services=>gui_download(
      exporting
        filename                = lv_fullpath
        filetype                = 'ASC'    " have also tried BIN option with xml converted to xstring
      changing
        data_tab                = lt_xml   " plain text xml
      exceptions
        file_write_error        = 1
        no_batch                = 2
        gui_refuse_filetransfer = 3
        invalid_type            = 4
        others                  = 5 ).

    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor

Hello,
XLSX Excel format is different from the one you are using now (XLS). You need to use Office Open XML (OOXML). Best way to do it in ABAP is using ABAP2XLSX (custom library available on Github).

-- Tomas --
3 REPLIES 3

Tomas_Buryanek
Active Contributor

Hello,
XLSX Excel format is different from the one you are using now (XLS). You need to use Office Open XML (OOXML). Best way to do it in ABAP is using ABAP2XLSX (custom library available on Github).

-- Tomas --

0 Kudos

Thanks for the inputs. Have already explored that possibility, however my organisation will not allow "abap git" installation. Is there any other "working" alternative to get abap2xlsx in our system?

sanjuvshah You can install it on some sandbox / dummy system and then transfer the package with ABAP2XLSX to your final system.

-- Tomas --