You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This use case is quite common: I want to enhance an SALV report with the ability to download an Excel instead of displaying it (similar to the output radiobutton option in the demo programs).
I don't believe I'm the first one to try it and I would like to know what everyone do.
My best attempt is the following.
sy-batch = abap_true. data(excel) = new zcl_excel( ). data(worksheet) = result->get_active_worksheet( ). worksheet->bind_alv( io_alv = salv it_table = table ). sy-batch = abap_false. data(writer) = cast zif_excel_writer( new zcl_excel_writer_2007( ) ). data(excel_xstring) = writer->write_file( excel ).
cl_salv_bs_runtime_info=>set( exporting display = abap_false metadata = abap_true data = abap_true ). salv->display( ). data(excel) = new zcl_excel( ). data(worksheet) = result->get_active_worksheet( ). worksheet->bind_alv( io_alv = salv it_table = table ). data(writer) = cast zif_excel_writer( new zcl_excel_writer_2007( ) ). data(excel_xstring) = writer->write_file( excel ).
Thanks,
PS: I promise I'll PR a doc page with the outcome of the discussion.
The text was updated successfully, but these errors were encountered:
sandraros added the question label Sep 24, 2021 sandraros mentioned this issue Sep 24, 2021 Contributor Author AlexandreHT commented Oct 4, 2021Hi,
In order to reproduce the issue of hidden columns and totals, with ZDEMO_EXCEL32 , please :
data(layout) = lo_salv->get_layout( ). layout->set_key( value salv_s_layout_key( report = sy-repid ) ). layout->set_save_restriction( if_salv_c_layout=>restrict_none ). layout->set_default( abap_true ).
* lo_salv->display( ). cl_salv_bs_runtime_info=>set( exporting display = abap_false metadata = abap_true data = abap_true ). lo_salv->display( ). data(excel) = new zcl_excel( ). data(worksheet) = excel->get_active_worksheet( ). worksheet->bind_alv( io_alv = lo_salv it_table = gt_sbook ). data(writer) = cast zif_excel_writer( new zcl_excel_writer_2007( ) ). data(excel_xstring) = writer->write_file( excel ). data(bytecount) = xstrlen( excel_xstring ). data(filename) = lv_default_file_name. data path type string. data fullpath type string. data(raw_data) = cl_bcs_convert=>xstring_to_solix( excel_xstring ). cl_gui_frontend_services=>file_save_dialog( exporting * window_title pl-c">* default_extension pl-c">* default_file_name = * with_encoding = * file_filter pl-c">* initial_directory pl-k">= abap_true changing filename = filename " File Name to Save path = path " Path to File fullpath = fullpath " Path + File Name * user_action = user_action " User Action (C Class Const ACTION_OK, ACTION_OVERWRITE etc) * file_encoding = exceptions cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 invalid_default_file_name = 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. cl_gui_frontend_services=>gui_download( exporting bin_filesize = bytecount filename = fullpath filetype = 'BIN' changing data_tab = raw_data exceptions file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 invalid_type = 4 no_authority = 5 unknown_error = 6 header_not_allowed = 7 separator_not_allowed = 8 filesize_not_allowed = 9 header_too_long = 10 dp_error_create = 11 dp_error_send = 12 dp_error_write = 13 unknown_dp_error = 14 access_denied = 15 dp_out_of_memory = 16 disk_full = 17 dp_timeout = 18 file_not_found = 19 dataprovider_exception = 20 control_flush_error = 21 not_supported_by_gui = 22 error_no_gui = 23 others = 24 ). if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif.
=> no hidden columns and no total.