- Notifications
You must be signed in to change notification settings - Fork 306
Open
Description
Hi,
When I use bind_alv with an SALV that has colored cells, the Excel file produced by ABAP2xlsx does not have any colors (Option 1 in the demo program).
Surprisingly, if I use the code contained in bin_alv (Option 2), it works.
Steps to reproduce:
- Execute demo program with option Direct display => SALV displayed in SAP with colored cells
- Execute with option Save to frontend => Excel file doesn't have colored cells
- Change program: Comment Option 1 and uncomment Option 2 / Activate
- Execute with option Save to frontend => Excel file has colored cells
report zdemo_excel_issue. types: begin of ty_t005t_line, mandt type mandt, spras type spras, land1 type land1, landx type landx, natio type natio, landx50 type landx50, natio50 type natio50, colors type lvc_t_scol, end of ty_t005t_line, ty_t005t_lines type table of ty_t005t_line. data lt_test type ty_t005t_lines. constants: gc_save_file_name type string value 'issue.xlsx'. include zdemo_excel_outputopt_incl. start-of-selection. perform load_fixed_data changing lt_test. try. cl_salv_table=>factory( importing r_salv_table = data(salv_table) changing t_table = lt_test ). data(columns) = salv_table->get_columns( ). columns->set_color_column( 'COLORS' ). if rb_show = 'X'. salv_table->display( ). else. data(excel) = new zcl_excel( ). data(worksheet) = excel->get_active_worksheet( ). **** Option 1 : no colors in output **** worksheet->bind_alv( io_alv = salv_table it_table = lt_test ). **** Option 2 : colors in output **** * data(lo_converter) = new zcl_excel_converter( ). * lo_converter->convert( * exporting * io_alv = salv_table * it_table = lt_test ** i_row_int = i_top ** i_column_int = i_left ** i_table = i_table ** i_style_table = table_style * io_worksheet = worksheet * changing * co_excel = excel ). *** Create output lcl_output=>output( excel ). endif. catch cx_salv_error into data(exception). message exception type 'E'. endtry. form load_fixed_data changing ct_test type ty_t005t_lines. data: lt_lines type table of string, lv_line type string, lt_fields type table of string, lv_comp type i, lv_field type string, ls_test type ty_t005t_line. * ls_test type t005t. field-symbols: <lv_field> type simple. append '001 E AD Andorra Andorran Andorra Andorran ' to lt_lines. append '001 E BE Belgium Belgian Belgium Belgian ' to lt_lines. append '001 E DE Germany German Germany German ' to lt_lines. append '001 E FM Micronesia Micronesian Micronesia Micronesian' to lt_lines. loop at lt_lines into lv_line. clear ls_test. condense lv_line. split lv_line at space into table lt_fields. lv_comp = 1. loop at lt_fields into lv_field. assign component lv_comp of structure ls_test to <lv_field>. <lv_field> = lv_field. lv_comp = lv_comp + 1. endloop. data(div) = conv f( sy-tabix / 2 ). if frac( div ) = 0. insert value lvc_s_scol( fname = 'LAND1' color = value #( col = 5 int = '1' inv = '0' ) ) into table ls_test-colors. endif. append ls_test to ct_test. endloop. endform.Metadata
Metadata
Assignees
Labels
No labels