abap2xlsx/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk
2012-01-22 16:52:36 +00:00

113 lines
5.0 KiB
XML

<?xml version="1.0" encoding="utf-16"?>
<CLAS CLSNAME="ZCL_EXCEL_CONVERTER_ALV_GRID" VERSION="1" LANGU="E" DESCRIPT="SALV converter" UUID="4F037FA9DF490087E1008000C008015A" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="RTURNHEIM" CREATEDON="20120106" CHANGEDBY="FEMIA" CHANGEDON="20120120" CHGDANYON="00000000" CLSFINAL="X" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="702" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 ">
<implementing CLSNAME="ZCL_EXCEL_CONVERTER_ALV_GRID" REFCLSNAME="ZIF_EXCEL_CONVERTER" VERSION="1" EXPOSURE="2" STATE="1" AUTHOR="FEMIA" CREATEDON="20120120" CHANGEDBY="FEMIA" CHANGEDON="20120120" RELTYPE="1" EDITORDER="0 "/>
<publicSection>class ZCL_EXCEL_CONVERTER_ALV_GRID definition
public
final
create public .
public section.
*&quot;* public components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*&quot;* do not include other source files here!!!
interfaces ZIF_EXCEL_CONVERTER .</publicSection>
<protectedSection>*&quot;* protected components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*&quot;* do not include other source files here!!!
protected section.</protectedSection>
<privateSection>*&quot;* private components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*&quot;* do not include other source files here!!!
private section.</privateSection>
<localImplementation>*&quot;* local class implementation for public class
*&quot;* use this source file for the implementation part of
*&quot;* local helper classes</localImplementation>
<localTypes>*&quot;* use this source file for any type declarations (class
*&quot;* definitions, interfaces or data types) you need for method
*&quot;* implementation or private method&apos;s signature</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<interfaceMethod CLSNAME="ZCL_EXCEL_CONVERTER_ALV_GRID" CPDNAME="ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT">
<source>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.</source>
</interfaceMethod>
<interfaceMethod CLSNAME="ZCL_EXCEL_CONVERTER_ALV_GRID" CPDNAME="ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG">
<source>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: &lt;fs_stable&gt; 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-&gt;get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = lt_fcat ).
lo_alv-&gt;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 = &apos;0&apos;.
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=&gt;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 &apos;R&apos;.
ls_converter_fcat-alignment = zcl_excel_style_alignment=&gt;c_horizontal_right.
WHEN &apos;L&apos;.
ls_converter_fcat-alignment = zcl_excel_style_alignment=&gt;c_horizontal_left.
WHEN &apos;C&apos;.
ls_converter_fcat-alignment = zcl_excel_style_alignment=&gt;c_horizontal_center.
WHEN OTHERS.
CLEAR ls_converter_fcat-alignment.
ENDCASE.
APPEND ls_converter_fcat TO et_fieldcatalog.
ENDIF.
ENDLOOP.
ENDIF.
ENDMETHOD.</source>
</interfaceMethod>
</CLAS>