03-18-2019 6:33 AM
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.
03-18-2019 9:01 AM
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).
03-18-2019 9:01 AM
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).
03-18-2019 11:17 AM
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?
03-18-2019 12:02 PM
sanjuvshah You can install it on some sandbox / dummy system and then transfer the package with ABAP2XLSX to your final system.