class ZCL_EXCEL_CONVERTER_ALV_GRID definition
public
final
create public .
*"* public components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*"* do not include other source files here!!!
public section.
interfaces ZIF_EXCEL_CONVERTER .
aliases CAN_CONVERT_OBJECT
for ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT .
aliases CREATE_FIELDCATALOG
for ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG .*"* protected components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*"* do not include other source files here!!!
protected section.*"* private components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*"* do not include other source files here!!!
private section.*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature*"* use this source file for any macro definitions you need
*"* in the implementation part of the classmethod ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT.
data: lo_alv type REF TO cl_gui_alv_grid.
try.
lo_alv ?= io_object.
catch cx_sy_move_cast_error .
raise exception type zcx_excel.
endtry.
endmethod.method ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG.
data: lo_alv type ref to cl_gui_alv_grid.
data: ls_converter_fcat type zexcel_s_converter_fcat,
lt_fcat type lvc_t_fcat,
ls_fcat type lvc_s_fcat,
ls_layout type lvc_s_layo.
field-symbols: <fs_stable> type any.
try.
can_convert_object( io_object = io_object ).
endtry.
lo_alv ?= io_object.
clear: es_layout,
et_fieldcatalog.
if lo_alv is bound.
lo_alv->get_frontend_fieldcatalog( importing et_fieldcatalog = lt_fcat ).
lo_alv->get_frontend_layout( importing es_layout = ls_layout ).
if ls_layout-zebra is not initial.
es_layout-is_stripped = abap_true.
endif.
if ls_layout-no_keyfix is initial or
ls_layout-no_keyfix = '0'.
es_layout-is_fixed = abap_true.
endif.
loop at lt_fcat into ls_fcat.
clear ls_converter_fcat.
if ls_fcat-tech = abap_false.
ls_converter_fcat-tabname = ls_fcat-tabname.
ls_converter_fcat-fieldname = ls_fcat-fieldname .
ls_converter_fcat-columnname = ls_fcat-fieldname .
ls_converter_fcat-position = ls_fcat-col_pos.
ls_converter_fcat-inttype = ls_fcat-inttype.
ls_converter_fcat-scrtext_s = ls_fcat-scrtext_s .
ls_converter_fcat-scrtext_m = ls_fcat-scrtext_m .
ls_converter_fcat-scrtext_l = ls_fcat-scrtext_l.
if ls_fcat-do_sum is not initial.
ls_converter_fcat-totals_function = zcl_excel_table=>totals_function_sum.
endif.
ls_converter_fcat-fix_column = ls_fcat-fix_column.
if ls_layout-cwidth_opt is initial.
if ls_fcat-col_opt is not initial.
ls_converter_fcat-is_optimized = abap_true.
endif.
else.
ls_converter_fcat-is_optimized = abap_true.
endif.
if ls_fcat-no_out is not initial.
clear ls_converter_fcat-is_visible.
else.
ls_converter_fcat-is_visible = abap_true.
endif.
case ls_fcat-just.
when 'R'.
ls_converter_fcat-alignment = zcl_excel_style_alignment=>c_horizontal_right.
when 'L'.
ls_converter_fcat-alignment = zcl_excel_style_alignment=>c_horizontal_left.
when 'C'.
ls_converter_fcat-alignment = zcl_excel_style_alignment=>c_horizontal_center.
when others.
clear ls_converter_fcat-alignment.
endcase.
append ls_converter_fcat to et_fieldcatalog.
endif.
endloop.
endif.
endmethod.method ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT.
data: lo_alv type REF TO cl_gui_alv_grid.
try.
lo_alv ?= io_object.
catch cx_sy_move_cast_error .
raise exception type zcx_excel.
endtry.
endmethod.method ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG.
data: lo_alv type ref to cl_gui_alv_grid.
data: ls_converter_fcat type zexcel_s_converter_fcat,
lt_fcat type lvc_t_fcat,
ls_fcat type lvc_s_fcat,
ls_layout type lvc_s_layo.
field-symbols: <fs_stable> type any.
try.
can_convert_object( io_object = io_object ).
endtry.
lo_alv ?= io_object.
clear: es_layout,
et_fieldcatalog.
if lo_alv is bound.
lo_alv->get_frontend_fieldcatalog( importing et_fieldcatalog = lt_fcat ).
lo_alv->get_frontend_layout( importing es_layout = ls_layout ).
if ls_layout-zebra is not initial.
es_layout-is_stripped = abap_true.
endif.
if ls_layout-no_keyfix is initial or
ls_layout-no_keyfix = '0'.
es_layout-is_fixed = abap_true.
endif.
loop at lt_fcat into ls_fcat.
clear ls_converter_fcat.
if ls_fcat-tech = abap_false.
ls_converter_fcat-tabname = ls_fcat-tabname.
ls_converter_fcat-fieldname = ls_fcat-fieldname .
ls_converter_fcat-columnname = ls_fcat-fieldname .
ls_converter_fcat-position = ls_fcat-col_pos.
ls_converter_fcat-inttype = ls_fcat-inttype.
ls_converter_fcat-scrtext_s = ls_fcat-scrtext_s .
ls_converter_fcat-scrtext_m = ls_fcat-scrtext_m .
ls_converter_fcat-scrtext_l = ls_fcat-scrtext_l.
if ls_fcat-do_sum is not initial.
ls_converter_fcat-totals_function = zcl_excel_table=>totals_function_sum.
endif.
ls_converter_fcat-fix_column = ls_fcat-fix_column.
if ls_layout-cwidth_opt is initial.
if ls_fcat-col_opt is not initial.
ls_converter_fcat-is_optimized = abap_true.
endif.
else.
ls_converter_fcat-is_optimized = abap_true.
endif.
if ls_fcat-no_out is not initial.
clear ls_converter_fcat-is_visible.
else.
ls_converter_fcat-is_visible = abap_true.
endif.
case ls_fcat-just.
when 'R'.
ls_converter_fcat-alignment = zcl_excel_style_alignment=>c_horizontal_right.
when 'L'.
ls_converter_fcat-alignment = zcl_excel_style_alignment=>c_horizontal_left.
when 'C'.
ls_converter_fcat-alignment = zcl_excel_style_alignment=>c_horizontal_center.
when others.
clear ls_converter_fcat-alignment.
endcase.
append ls_converter_fcat to et_fieldcatalog.
endif.
endloop.
endif.
endmethod.