class ZCL_EXCEL_CONVERTER_ALV_GRID definition
public
final
create public .
public section.
*"* public components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*"* do not include other source files here!!!
interfaces ZIF_EXCEL_CONVERTER .*"* 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.
zif_excel_converter~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.