diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk
index b8d22ca..64dc423 100644
--- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk
+++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER.slnk
@@ -1,12 +1,12 @@
-
-
+
-
-
-
-
@@ -39,10 +39,10 @@ public section.
type-pools ABAP .
class-methods CLASS_CONSTRUCTOR .
- methods CONVERT
+ methods CONVERT
importing
!IO_ALV type ref to OBJECT optional
- !IT_TABLE type STANDARD TABLE
+ !IT_TABLE type STANDARD TABLE optional
!I_ROW_INT type I default 1
!I_COLUMN_INT type I default 1
!I_TABLE type FLAG optional
@@ -101,67 +101,160 @@ protected section.
*"* do not include other source files here!!!
private section.
- data wo_excel type ref to zcl_excel .
- data wo_worksheet type ref to zcl_excel_worksheet .
- data wo_data type ref to data .
- data wt_fieldcatalog type zexcel_t_converter_fcat .
- data ws_layout type zexcel_s_converter_layo .
- class-data wt_objects type tt_alv_types .
- data w_fcount type numc3 .
+ data WO_EXCEL type ref to ZCL_EXCEL .
+ data WO_WORKSHEET type ref to ZCL_EXCEL_WORKSHEET .
+ data WO_AUTOFILTER type ref to ZCL_EXCEL_AUTOFILTER .
+ data WO_TABLE type ref to DATA .
+ data WO_DATA type ref to DATA .
+ data WT_FIELDCATALOG type ZEXCEL_T_CONVERTER_FCAT .
+ data WS_LAYOUT type ZEXCEL_S_CONVERTER_LAYO .
+ data WT_COLORS type ZEXCEL_T_CONVERTER_COL .
+ data WT_FILTER type ZEXCEL_T_CONVERTER_FIL .
+ class-data WT_OBJECTS type TT_ALV_TYPES .
+ class-data W_FCOUNT type NUMC3 .
+ data WT_SORT_VALUES type TT_SORT_VALUES .
+ data WT_SUBTOTAL_ROWS type TT_SUBTOTAL_ROWS .
+ data WT_STYLES type TT_STYLES .
+ constants C_TYPE_HDR type CHAR1 value 'H'. "#EC NOTEXT
+ constants C_TYPE_STR type CHAR1 value 'P'. "#EC NOTEXT
+ constants C_TYPE_NOR type CHAR1 value 'N'. "#EC NOTEXT
+ constants C_TYPE_SUB type CHAR1 value 'S'. "#EC NOTEXT
+ constants C_TYPE_TOT type CHAR1 value 'T'. "#EC NOTEXT
+ data WT_COLOR_STYLES type TT_COLOR_STYLES .
- methods bind_table
+ methods GET_COLOR_STYLE
importing
- !i_style_table type zexcel_table_style .
- methods bind_cells
+ !I_ROW type ZEXCEL_CELL_ROW
+ !I_FIELDNAME type FIELDNAME
+ !I_STYLE type ZEXCEL_CELL_STYLE
+ returning
+ value(R_STYLE) type ZEXCEL_CELL_STYLE .
+ methods CLEAN_FIELDCATALOG .
+ methods SET_CELL_FORMAT
+ importing
+ !I_INTTYPE type INTTYPE
+ !I_DECIMALS type INT1
+ returning
+ value(R_FORMAT) type ZEXCEL_NUMBER_FORMAT .
+ methods GET_FUNCTION_NUMBER
+ importing
+ !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
+ returning
+ value(R_FUNCTION_NUMBER) type INT1 .
+ methods LOOP_NORMAL
+ importing
+ !I_ROW_INT type ZEXCEL_CELL_ROW
+ !I_COL_INT type ZEXCEL_CELL_COLUMN
+ returning
+ value(R_FREEZE_COL) type INT1
raising
- zcx_excel .
- methods create_formular_total
+ ZCX_EXCEL .
+ methods LOOP_SUBTOTAL
importing
- !i_row_int type zexcel_cell_row
- !i_column type zexcel_cell_column_alpha
- !i_totals_function type zexcel_table_totals_function
+ !I_ROW_INT type ZEXCEL_CELL_ROW
+ !I_COL_INT type ZEXCEL_CELL_COLUMN
returning
- value(r_formula) type string .
- methods create_style_hdr
- importing
- !i_alignment type zexcel_alignment optional
- returning
- value(r_style) type zexcel_cell_style .
- methods create_style_normal
- importing
- !i_alignment type zexcel_alignment optional
- !i_inttype type inttype optional
- returning
- value(r_style) type zexcel_cell_style .
- methods create_style_stripped
- importing
- !i_alignment type zexcel_alignment optional
- !i_inttype type inttype optional
- returning
- value(r_style) type zexcel_cell_style .
- methods create_style_total
- importing
- !i_alignment type zexcel_alignment optional
- !i_inttype type inttype optional
- returning
- value(r_style) type zexcel_cell_style .
- methods create_path
- returning
- value(r_path) type string .
- methods create_table
- importing
- !it_table type standard table .
- methods create_worksheet
- importing
- !i_table type flag default 'X'
- !i_style_table type zexcel_table_style .
- methods execute_converter
- importing
- !io_object type ref to object
- !it_table type standard table
+ value(R_FREEZE_COL) type INT1
raising
- zcx_excel .
- methods set_fieldcatalog .
+ ZCX_EXCEL .
+ methods BIND_TABLE
+ importing
+ !I_STYLE_TABLE type ZEXCEL_TABLE_STYLE
+ returning
+ value(R_FREEZE_COL) type INT1
+ raising
+ ZCX_EXCEL .
+ methods BIND_CELLS
+ returning
+ value(R_FREEZE_COL) type INT1
+ raising
+ ZCX_EXCEL .
+ methods SET_AUTOFILTER_AREA .
+ methods CREATE_COLOR_STYLE
+ importing
+ !I_STYLE type ZEXCEL_CELL_STYLE
+ !IS_COLORS type ZEXCEL_S_CONVERTER_COL
+ returning
+ value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
+ methods CREATE_FORMULAR_SUBTOTAL
+ importing
+ !I_ROW_INT_START type ZEXCEL_CELL_ROW
+ !I_ROW_INT_END type ZEXCEL_CELL_ROW
+ !I_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA
+ !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
+ returning
+ value(R_FORMULA) type STRING .
+ methods CREATE_FORMULAR_TOTAL
+ importing
+ !I_ROW_INT type ZEXCEL_CELL_ROW
+ !I_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA
+ !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
+ returning
+ value(R_FORMULA) type STRING .
+ methods CREATE_PATH
+ returning
+ value(R_PATH) type STRING .
+ methods CREATE_STYLE_HDR
+ importing
+ !I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
+ returning
+ value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
+ methods CREATE_STYLE_NORMAL
+ importing
+ !I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
+ !I_INTTYPE type INTTYPE optional
+ !I_DECIMALS type INT1 optional
+ returning
+ value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
+ methods CREATE_STYLE_STRIPPED
+ importing
+ !I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
+ !I_INTTYPE type INTTYPE optional
+ !I_DECIMALS type INT1 optional
+ returning
+ value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
+ methods CREATE_STYLE_SUBTOTAL
+ importing
+ !I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
+ !I_INTTYPE type INTTYPE optional
+ !I_DECIMALS type INT1 optional
+ returning
+ value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
+ methods CREATE_STYLE_TOTAL
+ importing
+ !I_ALIGNMENT type ZEXCEL_ALIGNMENT optional
+ !I_INTTYPE type INTTYPE optional
+ !I_DECIMALS type INT1 optional
+ returning
+ value(RO_STYLE) type ref to ZCL_EXCEL_STYLE .
+ methods CREATE_TABLE .
+ methods CREATE_TEXT_SUBTOTAL
+ importing
+ !I_VALUE type ANY
+ !I_TOTALS_FUNCTION type ZEXCEL_TABLE_TOTALS_FUNCTION
+ returning
+ value(R_TEXT) type STRING .
+ methods CREATE_WORKSHEET
+ importing
+ !I_TABLE type FLAG default 'X'
+ !I_STYLE_TABLE type ZEXCEL_TABLE_STYLE
+ raising
+ ZCX_EXCEL .
+ methods EXECUTE_CONVERTER
+ importing
+ !IO_OBJECT type ref to OBJECT
+ !IT_TABLE type STANDARD TABLE
+ raising
+ ZCX_EXCEL .
+ methods SET_FIELDCATALOG .
+ methods GET_STYLE
+ importing
+ !I_TYPE type CHAR1
+ !I_ALIGNMENT type ZEXCEL_ALIGNMENT default SPACE
+ !I_INTTYPE type INTTYPE default SPACE
+ !I_DECIMALS type INT1 default 0
+ returning
+ value(R_STYLE) type ZEXCEL_CELL_STYLE .
*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes
@@ -169,153 +262,117 @@ private section.
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature
-types: begin of ts_alv_types,
- seoclass type SEOCLSNAME,
- clsname type seoclsname,
- end of ts_alv_types,
- tt_alv_types type hashed table of ts_alv_types with unique key seoclass.
+TYPES: BEGIN OF ts_alv_types,
+ seoclass TYPE seoclsname,
+ clsname TYPE seoclsname,
+ END OF ts_alv_types,
+ tt_alv_types TYPE HASHED TABLE OF ts_alv_types WITH UNIQUE KEY seoclass.
+
+TYPES: BEGIN OF ts_sort_values,
+ fieldname TYPE fieldname,
+ row_int TYPE zexcel_cell_row,
+ value TYPE REF TO data,
+ new TYPE flag,
+ END OF ts_sort_values,
+
+ tt_sort_values TYPE HASHED TABLE OF ts_sort_values WITH UNIQUE KEY fieldname.
+TYPES: BEGIN OF ts_subtotal_rows,
+ row_int TYPE zexcel_cell_row,
+ row_int_start TYPE zexcel_cell_row,
+ columnname TYPE fieldname,
+ END OF ts_subtotal_rows,
+
+ tt_subtotal_rows TYPE HASHED TABLE OF ts_subtotal_rows WITH UNIQUE KEY row_int.
+
+TYPES: BEGIN OF ts_styles,
+ type TYPE char1,
+ alignment TYPE zexcel_alignment,
+ inttype TYPE inttype,
+ decimals TYPE int1,
+ style TYPE REF TO zcl_excel_style,
+ guid TYPE zexcel_cell_style,
+ END OF ts_styles,
+
+ tt_styles TYPE HASHED TABLE OF ts_styles WITH UNIQUE KEY type alignment inttype decimals.
+
+TYPES: BEGIN OF ts_color_styles,
+ guid_old TYPE zexcel_cell_style,
+ fontcolor TYPE zexcel_style_color_argb,
+ fillcolor TYPE zexcel_style_color_argb,
+ style_new TYPE REF TO zcl_excel_style,
+ END OF ts_color_styles,
+
+ tt_color_styles TYPE HASHED TABLE OF ts_color_styles WITH UNIQUE KEY guid_old fontcolor fillcolor.
*"* use this source file for any macro definitions you need
*"* in the implementation part of the class
+
+
+
+
+
+
+
+
+
+
+
ABAP
SLIS
SOI
-
-
-
-
-
-
-
-
-
-
-
- method BIND_CELLS.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ METHOD bind_cells.
- data: lo_tabdescr type ref to cl_abap_structdescr,
- lo_data type ref to data,
- l_row_header type zexcel_cell_row value '2',
- l_col_header type zexcel_cell_column_alpha value 'B',
- l_row_int type zexcel_cell_row,
- l_col_int type zexcel_cell_column,
- l_col_alpha type zexcel_cell_column_alpha,
- l_cell_value type zexcel_cell_value,
- l_hdr type zexcel_cell_style,
- l_stripped type zexcel_cell_style,
- l_normal type zexcel_cell_style,
- l_total type zexcel_cell_style,
- l_s_color type abap_bool,
- i_num_columns type i,
- lo_col_dim type ref to zcl_excel_worksheet_columndime,
- l_formula type zexcel_cell_formula.
+* Do we need subtotals with grouping
+ READ TABLE wt_fieldcatalog TRANSPORTING NO FIELDS WITH KEY is_subtotalled = abap_true.
+ IF sy-subrc = 0 .
+ r_freeze_col = loop_subtotal( i_row_int = w_row_int
+ i_col_int = w_col_int ) .
+ ELSE.
+ r_freeze_col = loop_normal( i_row_int = w_row_int
+ i_col_int = w_col_int ) .
+ ENDIF.
-
- field-symbols: <fs_stab> type any,
- <fs_tab> type any table,
- <fs_sfcat> type zexcel_s_converter_fcat,
- <fs_fldval> type any,
- <fs_cell_value> type zexcel_cell_value.
-
- assign wo_data->* to <fs_tab> .
-
- l_col_int = w_col_int.
- l_row_int = w_row_int.
-* First lets check if we fiedl catalog ready or we need conversion from table.
- if wt_fieldcatalog is initial.
- set_fieldcatalog( ).
- endif.
- clear ws_layout.
-* It is better to loop column by column
- loop at wt_fieldcatalog assigning <fs_sfcat>.
-* Default stype with alignment and format
- l_hdr = create_style_hdr( i_alignment = <fs_sfcat>-alignment ).
- if ws_layout-is_stripped = abap_true.
- l_stripped = create_style_stripped( i_alignment = <fs_sfcat>-alignment
- i_inttype = <fs_sfcat>-inttype ).
- endif.
- l_normal = create_style_normal( i_alignment = <fs_sfcat>-alignment
- i_inttype = <fs_sfcat>-inttype ).
- l_total = create_style_total( i_alignment = <fs_sfcat>-alignment
- i_inttype = <fs_sfcat>-inttype ).
-* Freeze panes
- if <fs_sfcat>-fix_column = abap_true.
- add 1 to i_num_columns.
- endif.
- l_s_color = abap_true.
- l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
- " First of all write column header
- l_cell_value = <fs_sfcat>-scrtext_m.
- wo_worksheet->set_cell( ip_column = l_col_alpha
- ip_row = l_row_int
- ip_value = l_cell_value
- ip_abap_type = cl_abap_typedescr=>typekind_string
- ip_style = l_hdr ).
- add 1 to l_row_int.
- loop at <fs_tab> assigning <fs_stab>.
-* Now the cell values
- assign component <fs_sfcat>-columnname of structure <fs_stab> to <fs_fldval>.
- if ws_layout-is_stripped = abap_true and l_s_color = abap_true.
- wo_worksheet->set_cell( ip_column = l_col_alpha
- ip_row = l_row_int
- ip_value = <fs_fldval>
- ip_abap_type = <fs_sfcat>-inttype
- ip_style = l_stripped ).
- clear l_s_color.
- else.
- wo_worksheet->set_cell( ip_column = l_col_alpha
- ip_row = l_row_int
- ip_value = <fs_fldval>
- ip_abap_type = <fs_sfcat>-inttype
- ip_style = l_normal ).
- l_s_color = abap_true.
- endif.
- add 1 to l_row_int.
- endloop.
-* Now let's check for optimized
- if <fs_sfcat>-is_optimized = abap_true.
- lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
- lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
- endif.
-* Now let's check for visible
- if <fs_sfcat>-is_visible = abap_false.
- lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
- lo_col_dim->set_visible( ip_visible = abap_false ) .
- endif.
-* Now let's check for total
- if <fs_sfcat>-totals_function is not initial.
- l_row_int = l_row_int - 1.
-
- l_formula = create_formular_total( i_row_int = l_row_int
- i_column = l_col_alpha
- i_totals_function = <fs_sfcat>-totals_function ).
- add 1 to l_row_int.
- wo_worksheet->set_cell( ip_column = l_col_alpha
- ip_row = l_row_int
- ip_formula = l_formula
- ip_style = l_total ).
- endif.
- l_row_int = w_row_int.
- add 1 to l_col_int.
- endloop.
-* Check for freeze panes
- if ws_layout-is_fixed = abap_true.
- if i_num_columns = 0.
- i_num_columns = w_col_int.
- endif.
- wo_worksheet->freeze_panes( exporting ip_num_columns = i_num_columns
- ip_num_rows = w_row_int ) .
- endif.
-endmethod.
+ENDMETHOD.
-
-
- method BIND_TABLE.
+
+
+
+
+ method bind_table.
data: lt_field_catalog type zexcel_t_fieldcatalog,
ls_field_catalog type zexcel_s_fieldcatalog,
ls_fcat type zexcel_s_converter_fcat,
+ lo_col_dim type ref to zcl_excel_worksheet_columndime,
+ lo_row_dim type ref to zcl_excel_worksheet_rowdimensi,
+ l_col_int type zexcel_cell_column,
+ l_col_alpha type zexcel_cell_column_alpha,
ls_settings type zexcel_s_table_settings,
l_line type i.
@@ -323,9 +380,6 @@ endmethod.
assign wo_data->* to <fs_tab> .
- if wt_fieldcatalog is initial.
- set_fieldcatalog( ) .
- endif.
ls_settings-table_style = i_style_table.
ls_settings-top_left_column = zcl_excel_common=>convert_column2alpha( ip_column = w_col_int ).
ls_settings-top_left_row = w_row_int.
@@ -352,39 +406,104 @@ endmethod.
importing
es_table_settings = ls_settings
).
+ loop at wt_fieldcatalog into ls_fcat.
+ l_col_int = w_col_int + ls_fcat-position - 1.
+ l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
+* Freeze panes
+ if ls_fcat-fix_column = abap_true.
+ add 1 to r_freeze_col.
+ endif.
+* Now let's check for optimized
+ if ls_fcat-is_optimized = abap_true.
+ lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
+ lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
+ endif.
+* Now let's check for visible
+ if ls_fcat-is_hidden = abap_true.
+ lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
+ lo_col_dim->set_visible( ip_visible = abap_false ) .
+ endif.
+ endloop.
endmethod.
-
- method CLASS_CONSTRUCTOR.
- data: ls_objects type ts_alv_types.
+
+ METHOD class_constructor.
+ DATA: ls_objects TYPE ts_alv_types.
* Object CL_GUI_ALV_GRID
ls_objects-seoclass = 'CL_GUI_ALV_GRID'.
ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_ALV_GRID'.
- insert ls_objects into table wt_objects.
+ INSERT ls_objects INTO TABLE wt_objects.
* Object CL_SALV_TABLE
ls_objects-seoclass = 'CL_SALV_TABLE'.
ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_SALV_TABLE'.
- insert ls_objects into table wt_objects.
-endmethod.
+ INSERT ls_objects INTO TABLE wt_objects.
+
+* Object CL_SALV_RESULT
+ ls_objects-seoclass = 'CL_SALV_EX_RESULT_DATA_TABLE '.
+ ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_EX_RESULT'.
+ INSERT ls_objects INTO TABLE wt_objects.
+* Object CL_SALV_WD_RESULT
+ ls_objects-seoclass = 'CL_SALV_WD_RESULT_DATA_TABLE '.
+ ls_objects-clsname = 'ZCL_EXCEL_CONVERTER_WD_RESULT'.
+ INSERT ls_objects INTO TABLE wt_objects.
+
+ENDMETHOD.
-
-
-
-
-
-
-
-
-
-
- method CONVERT.
+
+ METHOD clean_fieldcatalog.
+ DATA: l_position TYPE int1.
+
+ FIELD-SYMBOLS: <fs_sfcat> TYPE zexcel_s_converter_fcat.
+
+ SORT wt_fieldcatalog BY position col_id.
+
+ CLEAR l_position.
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_sfcat>.
+ ADD 1 TO l_position.
+ <fs_sfcat>-position = l_position.
+* Default stype with alignment and format
+ <fs_sfcat>-style_hdr = get_style( i_type = c_type_hdr
+ i_alignment = <fs_sfcat>-alignment ).
+ IF ws_layout-is_stripped = abap_true.
+ <fs_sfcat>-style_stripped = get_style( i_type = c_type_str
+ i_alignment = <fs_sfcat>-alignment
+ i_inttype = <fs_sfcat>-inttype
+ i_decimals = <fs_sfcat>-decimals ).
+ ENDIF.
+ <fs_sfcat>-style_normal = get_style( i_type = c_type_nor
+ i_alignment = <fs_sfcat>-alignment
+ i_inttype = <fs_sfcat>-inttype
+ i_decimals = <fs_sfcat>-decimals ).
+ <fs_sfcat>-style_subtotal = get_style( i_type = c_type_sub
+ i_alignment = <fs_sfcat>-alignment
+ i_inttype = <fs_sfcat>-inttype
+ i_decimals = <fs_sfcat>-decimals ).
+ <fs_sfcat>-style_total = get_style( i_type = c_type_tot
+ i_alignment = <fs_sfcat>-alignment
+ i_inttype = <fs_sfcat>-inttype
+ i_decimals = <fs_sfcat>-decimals ).
+ ENDLOOP.
+
+ENDMETHOD.
+
+
+
+
+
+
+
+
+
+
+
+ method convert.
try.
- execute_converter( io_object = io_alv
- it_table = it_table ) .
+ execute_converter( EXPORTING io_object = io_alv
+ it_table = it_table ) .
endtry.
if io_worksheet is supplied and io_worksheet is bound.
@@ -400,9 +519,9 @@ endmethod.
* Move table to data object and clean it up
if wt_fieldcatalog is not initial.
- create_table( it_table = it_table ).
+ create_table( ).
else.
- get reference of it_table into wo_data.
+ wo_data = wo_table .
endif.
if wo_excel is not bound.
@@ -423,66 +542,125 @@ endmethod.
endmethod.
-
-
-
-
-
- method CREATE_FORMULAR_TOTAL.
+
+
+
+
+ METHOD create_color_style.
+ DATA: ls_styles TYPE ts_styles.
+ DATA: lo_style TYPE REF TO zcl_excel_style.
+
+ READ TABLE wt_styles INTO ls_styles WITH KEY guid = i_style.
+ IF sy-subrc = 0.
+ lo_style = wo_excel->add_new_style( ).
+* lo_style->borders = ls_styles-style->borders.
+* lo_style->protection = ls_styles-style->protection.
+ lo_style->font->bold = ls_styles-style->font->bold.
+ lo_style->alignment->horizontal = ls_styles-style->alignment->horizontal.
+ lo_style->number_format->format_code = ls_styles-style->number_format->format_code.
+
+ lo_style->font->color-rgb = is_colors-fontcolor.
+ lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
+ lo_style->fill->fgcolor-rgb = is_colors-fillcolor.
+
+ ro_style = lo_style.
+ ENDIF.
+ENDMETHOD.
+
+
+
+
+
+
+
+ method create_formular_subtotal.
+ data: l_row_alpha_start type string,
+ l_row_alpha_end type string,
+ l_func_num type string.
+
+ l_row_alpha_start = i_row_int_start.
+ l_row_alpha_end = i_row_int_end.
+
+ l_func_num = get_function_number( i_totals_function = i_totals_function ).
+ concatenate 'SUBTOTAL(' l_func_num ',' i_column l_row_alpha_start ':' i_column l_row_alpha_end ')' into r_formula.
+endmethod.
+
+
+
+
+
+
+ method create_formular_total.
data: l_row_alpha type string,
l_row_e_alpha type string.
- l_row_alpha = w_row_int.
+ l_row_alpha = w_row_int + 1.
l_row_e_alpha = i_row_int.
concatenate i_totals_function '(' i_column l_row_alpha ':' i_column l_row_e_alpha ')' into r_formula.
endmethod.
-
-
- method CREATE_PATH.
- data: l_sep type c .
+
+
+ METHOD create_path.
+ DATA: l_sep TYPE c ,
+ l_path TYPE string,
+ l_return TYPE i .
- clear r_path.
+ CLEAR r_path.
" Save the file
cl_gui_frontend_services=>get_sapgui_workdir(
- changing
- sapworkdir = r_path
-* exceptions
-* get_sapworkdir_failed = 1
-* cntl_error = 2
-* error_no_gui = 3
-* not_supported_by_gui = 4
+ CHANGING
+ sapworkdir = l_path
+ EXCEPTIONS
+ get_sapworkdir_failed = 1
+ cntl_error = 2
+ error_no_gui = 3
+ not_supported_by_gui = 4
).
- if sy-subrc <> 0.
+ IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
- endif.
-
- add 1 to w_fcount.
+ CONCATENATE 'Excel_' w_fcount '.xlsx' INTO r_path.
+ ELSE.
+ DO.
+ ADD 1 TO w_fcount.
*-obtain file separator character---------------------------------------
- call method cl_gui_frontend_services=>get_file_separator
- changing
- file_separator = l_sep
- exceptions
- cntl_error = 1
- error_no_gui = 2
- not_supported_by_gui = 3
- others = 4.
+ CALL METHOD cl_gui_frontend_services=>get_file_separator
+ CHANGING
+ file_separator = l_sep
+ EXCEPTIONS
+ cntl_error = 1
+ error_no_gui = 2
+ not_supported_by_gui = 3
+ OTHERS = 4.
- if sy-subrc <> 0.
- l_sep = ''.
- endif.
+ IF sy-subrc <> 0.
+ l_sep = ''.
+ ENDIF.
- concatenate r_path l_sep 'Excel_' w_fcount '.xlsx' into r_path.
+ CONCATENATE l_path l_sep 'Excel_' w_fcount '.xlsx' INTO r_path.
-endmethod.
+ IF cl_gui_frontend_services=>file_exist( file = r_path ) = abap_true.
+ cl_gui_frontend_services=>file_delete( EXPORTING filename = r_path
+ CHANGING rc = l_return
+ EXCEPTIONS OTHERS = 1 ).
+ IF sy-subrc = 0 .
+ RETURN.
+ ENDIF.
+ ELSE.
+ RETURN.
+ ENDIF.
+ ENDDO.
+ ENDIF.
+
+ENDMETHOD.
-
-
-
- method CREATE_STYLE_HDR.
+
+
+
+ method create_style_hdr.
data: lo_style type ref to zcl_excel_style.
lo_style = wo_excel->add_new_style( ).
@@ -493,38 +671,48 @@ endmethod.
if i_alignment is supplied and i_alignment is not initial.
lo_style->alignment->horizontal = i_alignment.
endif.
- r_style = lo_style->get_guid( ) .
+ ro_style = lo_style .
endmethod.
-
-
-
-
- method CREATE_STYLE_NORMAL.
- data: lo_style type ref to zcl_excel_style.
+
+
+
+
+
+ METHOD create_style_normal.
+ DATA: lo_style TYPE REF TO zcl_excel_style,
+ l_format TYPE zexcel_number_format.
- lo_style = wo_excel->add_new_style( ).
- if i_alignment is supplied and i_alignment is not initial.
- lo_style->alignment->horizontal = i_alignment.
- endif.
- if i_inttype is supplied and i_inttype is not initial.
- case i_inttype.
- when cl_abap_typedescr=>typekind_date.
- lo_style->number_format->format_code = wo_worksheet->get_default_excel_date_format( ).
- when cl_abap_typedescr=>typekind_time.
- lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_date_time6.
- endcase.
- endif.
- r_style = lo_style->get_guid( ) .
+ IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL.
+ l_format = set_cell_format( i_inttype = i_inttype
+ i_decimals = i_decimals ) .
+ ENDIF.
+ IF l_format IS NOT INITIAL OR
+ ( i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL ) .
-endmethod.
+ lo_style = wo_excel->add_new_style( ).
+
+ IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL.
+ lo_style->alignment->horizontal = i_alignment.
+ ENDIF.
+
+ IF l_format IS NOT INITIAL.
+ lo_style->number_format->format_code = l_format.
+ ENDIF.
+
+ ro_style = lo_style .
+
+ ENDIF.
+ENDMETHOD.
-
-
-
-
- method CREATE_STYLE_STRIPPED.
+
+
+
+
+
+ method create_style_stripped.
data: lo_style type ref to zcl_excel_style.
+ data: l_format type zexcel_number_format.
lo_style = wo_excel->add_new_style( ).
lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
@@ -533,167 +721,337 @@ endmethod.
lo_style->alignment->horizontal = i_alignment.
endif.
if i_inttype is supplied and i_inttype is not initial.
- case i_inttype.
- when cl_abap_typedescr=>typekind_date.
- lo_style->number_format->format_code = wo_worksheet->get_default_excel_date_format( ).
- when cl_abap_typedescr=>typekind_time.
- lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_date_time6.
- endcase.
+ l_format = set_cell_format( i_inttype = i_inttype
+ i_decimals = i_decimals ) .
+ if l_format is not initial.
+ lo_style->number_format->format_code = l_format.
+ endif.
endif.
- r_style = lo_style->get_guid( ) .
+ ro_style = lo_style.
endmethod.
-
-
-
-
- method CREATE_STYLE_TOTAL.
+
+
+
+
+
+ method CREATE_STYLE_SUBTOTAL.
data: lo_style type ref to zcl_excel_style.
+ data: l_format type zexcel_number_format.
- lo_style = wo_excel->add_new_style( ).
-
- create object lo_style->borders->top.
- lo_style->borders->top->border_style = zcl_excel_style_border=>c_border_thin.
- lo_style->borders->top->border_color-rgb = zcl_excel_style_color=>c_black.
-
- create object lo_style->borders->right.
- lo_style->borders->right->border_style = zcl_excel_style_border=>c_border_none.
- lo_style->borders->right->border_color-rgb = zcl_excel_style_color=>c_black.
-
- create object lo_style->borders->down.
- lo_style->borders->down->border_style = zcl_excel_style_border=>c_border_double.
- lo_style->borders->down->border_color-rgb = zcl_excel_style_color=>c_black.
-
- create object lo_style->borders->left.
- lo_style->borders->left->border_style = zcl_excel_style_border=>c_border_none.
- lo_style->borders->left->border_color-rgb = zcl_excel_style_color=>c_black.
+ lo_style = wo_excel->add_new_style( ).
+ lo_style->font->bold = abap_true.
if i_alignment is supplied and i_alignment is not initial.
lo_style->alignment->horizontal = i_alignment.
endif.
if i_inttype is supplied and i_inttype is not initial.
- case i_inttype.
- when cl_abap_typedescr=>typekind_date.
- lo_style->number_format->format_code = wo_worksheet->get_default_excel_date_format( ).
- when cl_abap_typedescr=>typekind_time.
- lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_date_time6.
- endcase.
- endif.
-
- r_style = lo_style->get_guid( ) .
-
-endmethod.
-
-
-
- method CREATE_TABLE.
- data: lo_data type ref to data.
- data: lo_addit type ref to cl_abap_elemdescr,
- lt_components_tab type cl_abap_structdescr=>component_table,
- ls_components type abap_componentdescr,
- lo_table type ref to cl_abap_tabledescr,
- lo_struc type ref to cl_abap_structdescr.
-
- field-symbols: <fs_scat> type zexcel_s_converter_fcat,
- <fs_stab> type any,
- <fs_ttab> type standard table,
- <fs> type any.
-
- sort wt_fieldcatalog by position.
- read table it_table assigning <fs_stab> index 1.
- if sy-subrc eq 0 .
- loop at wt_fieldcatalog assigning <fs_scat>.
- assign component <fs_scat>-columnname of structure <fs_stab> to <fs>.
- if sy-subrc = 0.
- ls_components-name = <fs_scat>-columnname.
- lo_addit ?= cl_abap_typedescr=>describe_by_data( <fs> ).
- ls_components-type = lo_addit .
- insert ls_components into table lt_components_tab.
- endif.
- endloop.
- "create new line type
- lo_struc = cl_abap_structdescr=>create( lt_components_tab ).
-
- lo_table = cl_abap_tabledescr=>create( lo_struc ).
-
- create data wo_data type handle lo_table.
- create data lo_data type handle lo_struc.
-
- assign wo_data->* to <fs_ttab>.
- assign lo_data->* to <fs_stab>.
- loop at it_table assigning <fs>.
- clear <fs_stab>.
- move-corresponding <fs> to <fs_stab>.
- append <fs_stab> to <fs_ttab>.
- endloop.
- endif.
-
-endmethod.
-
-
-
-
- method CREATE_WORKSHEET.
-
- if wo_data is bound and wo_worksheet is bound.
- if i_table = abap_true.
- bind_table( i_style_table = i_style_table ) .
- else.
- bind_cells( ) .
+ l_format = set_cell_format( i_inttype = i_inttype
+ i_decimals = i_decimals ) .
+ if l_format is not initial.
+ lo_style->number_format->format_code = l_format.
endif.
endif.
- wo_worksheet->zif_excel_sheet_properties~zoomscale = 100.
- wo_worksheet->zif_excel_sheet_properties~zoomscale_normal = 100.
+
+ ro_style = lo_style .
endmethod.
-
-
-
-
- method EXECUTE_CONVERTER.
- data: lt_fieldcatalog type zexcel_t_fieldcatalog,
- ls_fieldcatalog type zexcel_s_converter_fcat,
- lo_if type ref to zif_excel_converter,
- ls_types type ts_alv_types,
- lo_addit type ref to cl_abap_classdescr.
+
+
+
+
+
+ METHOD create_style_total.
+ DATA: lo_style TYPE REF TO zcl_excel_style.
+ DATA: l_format TYPE zexcel_number_format.
- if io_object is bound.
- try.
+ lo_style = wo_excel->add_new_style( ).
+ lo_style->font->bold = abap_true.
+
+ CREATE OBJECT lo_style->borders->top.
+ lo_style->borders->top->border_style = zcl_excel_style_border=>c_border_thin.
+ lo_style->borders->top->border_color-rgb = zcl_excel_style_color=>c_black.
+
+ CREATE OBJECT lo_style->borders->right.
+ lo_style->borders->right->border_style = zcl_excel_style_border=>c_border_none.
+ lo_style->borders->right->border_color-rgb = zcl_excel_style_color=>c_black.
+
+ CREATE OBJECT lo_style->borders->down.
+ lo_style->borders->down->border_style = zcl_excel_style_border=>c_border_double.
+ lo_style->borders->down->border_color-rgb = zcl_excel_style_color=>c_black.
+
+ CREATE OBJECT lo_style->borders->left.
+ lo_style->borders->left->border_style = zcl_excel_style_border=>c_border_none.
+ lo_style->borders->left->border_color-rgb = zcl_excel_style_color=>c_black.
+
+ IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL.
+ lo_style->alignment->horizontal = i_alignment.
+ ENDIF.
+ IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL.
+ l_format = set_cell_format( i_inttype = i_inttype
+ i_decimals = i_decimals ) .
+ IF l_format IS NOT INITIAL.
+ lo_style->number_format->format_code = l_format.
+ ENDIF.
+ ENDIF.
+
+ ro_style = lo_style .
+
+ENDMETHOD.
+
+
+ METHOD create_table.
+ TYPES: BEGIN OF ts_output,
+ fieldname TYPE fieldname,
+ function TYPE funcname,
+ END OF ts_output.
+
+ DATA: lo_data TYPE REF TO data.
+ DATA: lo_addit TYPE REF TO cl_abap_elemdescr,
+ lt_components_tab TYPE cl_abap_structdescr=>component_table,
+ ls_components TYPE abap_componentdescr,
+ lo_table TYPE REF TO cl_abap_tabledescr,
+ lo_struc TYPE REF TO cl_abap_structdescr,
+ lt_fieldcatalog TYPE zexcel_t_converter_fcat.
+
+ FIELD-SYMBOLS: <fs_scat> TYPE zexcel_s_converter_fcat,
+ <fs_stab> TYPE ANY,
+ <fs_ttab> TYPE STANDARD TABLE,
+ <fs> TYPE ANY,
+ <fs_table> TYPE STANDARD TABLE.
+
+ SORT wt_fieldcatalog BY position.
+ ASSIGN wo_table->* TO <fs_table>.
+
+ READ TABLE <fs_table> ASSIGNING <fs_stab> INDEX 1.
+ IF sy-subrc EQ 0 .
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_scat>.
+ ASSIGN COMPONENT <fs_scat>-columnname OF STRUCTURE <fs_stab> TO <fs>.
+ IF sy-subrc = 0.
+ ls_components-name = <fs_scat>-columnname.
+ TRY.
+ lo_addit ?= cl_abap_typedescr=>describe_by_data( <fs> ).
+ CATCH cx_sy_move_cast_error.
+ CLEAR lo_addit.
+ DELETE TABLE wt_fieldcatalog FROM <fs_scat>.
+ ENDTRY.
+ IF lo_addit IS BOUND.
+ ls_components-type = lo_addit .
+ INSERT ls_components INTO TABLE lt_components_tab.
+ ENDIF.
+ ENDIF.
+ ENDLOOP.
+ IF lt_components_tab IS NOT INITIAL.
+ "create new line type
+ lo_struc = cl_abap_structdescr=>create( lt_components_tab ).
+
+ lo_table = cl_abap_tabledescr=>create( lo_struc ).
+
+ CREATE DATA wo_data TYPE HANDLE lo_table.
+ CREATE DATA lo_data TYPE HANDLE lo_struc.
+
+ ASSIGN wo_data->* TO <fs_ttab>.
+ ASSIGN lo_data->* TO <fs_stab>.
+ LOOP AT <fs_table> ASSIGNING <fs>.
+ CLEAR <fs_stab>.
+ MOVE-CORRESPONDING <fs> TO <fs_stab>.
+ APPEND <fs_stab> TO <fs_ttab>.
+ ENDLOOP.
+ ENDIF.
+ ENDIF.
+
+ENDMETHOD.
+
+
+
+
+
+ method create_text_subtotal.
+ data: l_string type string,
+ l_func type string.
+
+ case i_totals_function.
+ when zcl_excel_table=>totals_function_sum. " Total
+ l_func = 'Total'(003).
+ when zcl_excel_table=>totals_function_min. " Minimum
+ l_func = 'Minimum'(004).
+ when zcl_excel_table=>totals_function_max. " Maximum
+ l_func = 'Maximum'(005).
+ when zcl_excel_table=>totals_function_average. " Mean Value
+ l_func = 'Average'(006).
+ when zcl_excel_table=>totals_function_count. " Count
+ l_func = 'Count'(007).
+ when others.
+ clear l_func.
+ endcase.
+ l_string = i_value.
+
+ concatenate l_string l_func into r_text separated by space.
+
+endmethod.
+
+
+
+
+
+ METHOD create_worksheet.
+ DATA: l_freeze_col TYPE i.
+ DATA: l_guid TYPE oltpguid16.
+
+ wo_worksheet->zif_excel_sheet_properties~summarybelow = zif_excel_sheet_properties=>c_below_on. " By default is on
+
+ IF wo_data IS BOUND AND wo_worksheet IS BOUND.
+
+ IF wt_fieldcatalog IS INITIAL.
+ set_fieldcatalog( ) .
+ ELSE.
+ clean_fieldcatalog( ) .
+ ENDIF.
+
+ IF i_table = abap_true.
+ l_freeze_col = bind_table( i_style_table = i_style_table ) .
+ ELSE.
+* Let's check for filter.
+ IF wt_filter IS NOT INITIAL.
+ wo_autofilter = wo_excel->add_new_autofilter( io_sheet = wo_worksheet ).
+ l_freeze_col = bind_cells( ) .
+ set_autofilter_area( ) .
+ ELSE.
+ l_freeze_col = bind_cells( ) .
+ ENDIF.
+
+ ENDIF.
+ ENDIF.
+
+* Check for freeze panes
+ IF ws_layout-is_fixed = abap_true.
+ IF l_freeze_col = 0.
+ l_freeze_col = w_col_int.
+ ENDIF.
+ wo_worksheet->freeze_panes( EXPORTING ip_num_columns = l_freeze_col
+ ip_num_rows = w_row_int ) .
+ ENDIF.
+
+ENDMETHOD.
+
+
+
+
+
+ METHOD execute_converter.
+ DATA: lt_fieldcatalog TYPE zexcel_t_fieldcatalog,
+ ls_fieldcatalog TYPE zexcel_s_converter_fcat,
+ lo_if TYPE REF TO zif_excel_converter,
+ ls_types TYPE ts_alv_types,
+ lo_addit TYPE REF TO cl_abap_classdescr.
+
+ IF io_object IS BOUND.
+ TRY.
lo_addit ?= cl_abap_typedescr=>describe_by_object_ref( io_object ).
- catch cx_sy_move_cast_error.
- raise exception type zcx_excel.
- endtry.
+ CATCH cx_sy_move_cast_error.
+ RAISE EXCEPTION TYPE zcx_excel.
+ ENDTRY.
ls_types-seoclass = lo_addit->get_relative_name( ).
- read table wt_objects into ls_types with table key seoclass = ls_types-seoclass.
- if sy-subrc = 0.
- create object lo_if type (ls_types-clsname).
+ READ TABLE wt_objects INTO ls_types WITH TABLE KEY seoclass = ls_types-seoclass.
+ IF sy-subrc = 0.
+ CREATE OBJECT lo_if TYPE (ls_types-clsname).
- try.
+ TRY.
lo_if->create_fieldcatalog(
- exporting
+ EXPORTING
io_object = io_object
it_table = it_table
- importing
+ IMPORTING
es_layout = ws_layout
et_fieldcatalog = wt_fieldcatalog
+ eo_table = wo_table
+ et_colors = wt_colors
+ et_filter = wt_filter
).
- endtry.
- else.
- raise exception type zcx_excel.
- endif.
- else.
- refresh wt_fieldcatalog.
- endif.
+ ENDTRY.
+* data lines of highest level.
+ IF ws_layout-max_subtotal_level > 0.
+ ADD 1 TO ws_layout-max_subtotal_level.
+ ENDIF.
+ ELSE.
+ RAISE EXCEPTION TYPE zcx_excel.
+ ENDIF.
+ ELSE.
+ REFRESH wt_fieldcatalog.
+ GET REFERENCE OF it_table INTO wo_table.
+ ENDIF.
-endmethod.
+ENDMETHOD.
-
-
-
-
- method GET_FILE.
+
+
+
+
+
+ METHOD get_color_style.
+ DATA: ls_colors TYPE zexcel_s_converter_col,
+ ls_color_styles TYPE ts_color_styles,
+ lo_style TYPE REF TO zcl_excel_style.
+
+ r_style = i_style. " Default we change nothing
+
+ IF wt_colors IS NOT INITIAL.
+* Full line has color
+ READ TABLE wt_colors INTO ls_colors WITH KEY rownumber = i_row
+ columnname = space.
+ IF sy-subrc = 0.
+ READ TABLE wt_color_styles INTO ls_color_styles WITH KEY guid_old = i_style
+ fontcolor = ls_colors-fontcolor
+ fillcolor = ls_colors-fillcolor.
+ IF sy-subrc = 0.
+ r_style = ls_color_styles-style_new->get_guid( ).
+ ELSE.
+ lo_style = create_color_style( i_style = i_style
+ is_colors = ls_colors ) .
+ r_style = lo_style->get_guid( ) .
+ ls_color_styles-guid_old = i_style.
+ ls_color_styles-fontcolor = ls_colors-fontcolor.
+ ls_color_styles-fillcolor = ls_colors-fillcolor.
+ ls_color_styles-style_new = lo_style.
+ INSERT ls_color_styles INTO TABLE wt_color_styles.
+ ENDIF.
+ ELSE.
+* Only field has color
+ READ TABLE wt_colors INTO ls_colors WITH KEY rownumber = i_row
+ columnname = i_fieldname.
+ IF sy-subrc = 0.
+ READ TABLE wt_color_styles INTO ls_color_styles WITH KEY guid_old = i_style
+ fontcolor = ls_colors-fontcolor
+ fillcolor = ls_colors-fillcolor.
+ IF sy-subrc = 0.
+ r_style = ls_color_styles-style_new->get_guid( ).
+ ELSE.
+ lo_style = create_color_style( i_style = i_style
+ is_colors = ls_colors ) .
+ ls_color_styles-guid_old = i_style.
+ ls_color_styles-fontcolor = ls_colors-fontcolor.
+ ls_color_styles-fillcolor = ls_colors-fillcolor.
+ ls_color_styles-style_new = lo_style.
+ INSERT ls_color_styles INTO TABLE wt_color_styles.
+ r_style = ls_color_styles-style_new->get_guid( ).
+ ENDIF.
+ ELSE.
+ r_style = i_style.
+ ENDIF.
+ ENDIF.
+ ELSE.
+ r_style = i_style.
+ ENDIF.
+
+ENDMETHOD.
+
+
+
+
+
+ method get_file.
data: lo_excel_writer type ref to zif_excel_writer,
lo_excel type ref to zcl_excel.
@@ -729,8 +1087,562 @@ endmethod.
endmethod.
-
- method OPEN_FILE.
+
+
+
+ method get_function_number.
+*Number Function
+*1 AVERAGE
+*2 COUNT
+*3 COUNTA
+*4 MAX
+*5 MIN
+*6 PRODUCT
+*7 STDEV
+*8 STDEVP
+*9 SUM
+*10 VAR
+*11 VARP
+
+ case i_totals_function.
+ when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_SUM. " Total
+ r_function_number = 9.
+ when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_MIN. " Minimum
+ r_function_number = 5.
+ when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_MAX. " Maximum
+ r_function_number = 4.
+ when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_AVERAGE. " Mean Value
+ r_function_number = 1.
+ when ZCL_EXCEL_TABLE=>TOTALS_FUNCTION_count. " Count
+ r_function_number = 2.
+ when others.
+ clear r_function_number.
+ endcase.
+endmethod.
+
+
+
+
+
+
+
+ METHOD get_style.
+ DATA: ls_styles TYPE ts_styles,
+ lo_style TYPE REF TO zcl_excel_style.
+
+ CLEAR r_style.
+
+ READ TABLE wt_styles INTO ls_styles WITH TABLE KEY type = i_type
+ alignment = i_alignment
+ inttype = i_inttype
+ decimals = i_decimals.
+ IF sy-subrc = 0.
+ r_style = ls_styles-guid.
+ ELSE.
+ CASE i_type.
+ WHEN c_type_hdr. " Header
+ lo_style = create_style_hdr( i_alignment = i_alignment ).
+ WHEN c_type_str. "Stripped
+ lo_style = create_style_stripped( i_alignment = i_alignment
+ i_inttype = i_inttype
+ i_decimals = i_decimals ).
+ WHEN c_type_nor. "Normal
+ lo_style = create_style_normal( i_alignment = i_alignment
+ i_inttype = i_inttype
+ i_decimals = i_decimals ).
+ WHEN c_type_sub. "Subtotals
+ lo_style = create_style_subtotal( i_alignment = i_alignment
+ i_inttype = i_inttype
+ i_decimals = i_decimals ).
+ WHEN c_type_tot. "Totals
+ lo_style = create_style_total( i_alignment = i_alignment
+ i_inttype = i_inttype
+ i_decimals = i_decimals ).
+ ENDCASE.
+ IF lo_style IS NOT INITIAL.
+ r_style = lo_style->get_guid( ).
+ ls_styles-type = i_type.
+ ls_styles-alignment = i_alignment.
+ ls_styles-inttype = i_inttype.
+ ls_styles-decimals = i_decimals.
+ ls_styles-guid = r_style.
+ ls_styles-style = lo_style.
+ INSERT ls_styles INTO TABLE wt_styles.
+ ENDIF.
+ ENDIF.
+ENDMETHOD.
+
+
+
+
+
+
+ METHOD loop_normal.
+ DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr,
+ lo_data TYPE REF TO data,
+ l_row_header TYPE zexcel_cell_row VALUE '2',
+ l_col_header TYPE zexcel_cell_column_alpha VALUE 'B',
+ l_row_int_start TYPE zexcel_cell_row,
+ l_row_int_end TYPE zexcel_cell_row,
+ l_row_int TYPE zexcel_cell_row,
+ l_col_int TYPE zexcel_cell_column,
+ l_col_alpha TYPE zexcel_cell_column_alpha,
+ l_col_alpha_start TYPE zexcel_cell_column_alpha,
+ l_cell_value TYPE zexcel_cell_value,
+ l_s_color TYPE abap_bool,
+ lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
+ lo_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi,
+ l_formula TYPE zexcel_cell_formula,
+ l_style TYPE zexcel_cell_style,
+ l_cells TYPE i,
+ l_count TYPE i,
+ l_table_row TYPE i.
+
+ FIELD-SYMBOLS: <fs_stab> TYPE ANY,
+ <fs_tab> TYPE STANDARD TABLE,
+ <fs_sfcat> TYPE zexcel_s_converter_fcat,
+ <fs_fldval> TYPE ANY,
+ <fs_cell_value> TYPE zexcel_cell_value.
+
+ ASSIGN wo_data->* TO <fs_tab> .
+
+ DESCRIBE TABLE wt_fieldcatalog LINES l_cells.
+ DESCRIBE TABLE <fs_tab> LINES l_count.
+ l_cells = l_cells * l_count.
+
+* It is better to loop column by column
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_sfcat>.
+ l_row_int = i_row_int.
+ l_col_int = i_col_int + <fs_sfcat>-position - 1.
+
+* Freeze panes
+ IF <fs_sfcat>-fix_column = abap_true.
+ ADD 1 TO r_freeze_col.
+ ENDIF.
+ l_s_color = abap_true.
+ l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
+ " First of all write column header
+ l_cell_value = <fs_sfcat>-scrtext_m.
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_value = l_cell_value
+ ip_style = <fs_sfcat>-style_hdr ).
+ ADD 1 TO l_row_int.
+ LOOP AT <fs_tab> ASSIGNING <fs_stab>.
+ l_table_row = sy-tabix.
+* Now the cell values
+ ASSIGN COMPONENT <fs_sfcat>-columnname OF STRUCTURE <fs_stab> TO <fs_fldval>.
+* Now let's write the cell values
+ IF ws_layout-is_stripped = abap_true AND l_s_color = abap_true.
+ l_style = get_color_style( i_row = l_table_row
+ i_fieldname = <fs_sfcat>-columnname
+ i_style = <fs_sfcat>-style_stripped ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_value = <fs_fldval>
+ ip_style = l_style ).
+ CLEAR l_s_color.
+ ELSE.
+ l_style = get_color_style( i_row = l_table_row
+ i_fieldname = <fs_sfcat>-columnname
+ i_style = <fs_sfcat>-style_normal ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_value = <fs_fldval>
+ ip_style = l_style ).
+ l_s_color = abap_true.
+ ENDIF.
+ READ TABLE wt_filter TRANSPORTING NO FIELDS WITH TABLE KEY rownumber = l_table_row
+ columnname = <fs_sfcat>-columnname.
+ IF sy-subrc = 0.
+ wo_worksheet->get_cell( EXPORTING
+ ip_column = l_col_alpha
+ ip_row = l_row_int
+ IMPORTING
+ ep_value = l_cell_value ).
+ wo_autofilter->set_value( i_column = l_col_int
+ i_value = l_cell_value ).
+ ENDIF.
+ ADD 1 TO l_row_int.
+ ENDLOOP.
+* Now let's check for optimized
+ IF <fs_sfcat>-is_optimized = abap_true .
+ lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
+ lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
+ ENDIF.
+* Now let's check for visible
+ IF <fs_sfcat>-is_hidden = abap_true.
+ lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
+ lo_col_dim->set_visible( ip_visible = abap_false ) .
+ ENDIF.
+* Now let's check for total versus subtotal.
+ IF <fs_sfcat>-totals_function IS NOT INITIAL.
+ l_row_int_end = l_row_int - 1.
+
+ l_formula = create_formular_total( i_row_int = l_row_int_end
+ i_column = l_col_alpha
+ i_totals_function = <fs_sfcat>-totals_function ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_formula = l_formula
+ ip_style = <fs_sfcat>-style_total ).
+ ENDIF.
+ ENDLOOP.
+ENDMETHOD.
+
+
+
+
+
+
+ METHOD loop_subtotal.
+ TYPES: BEGIN OF ts_line,
+ sort_level TYPE int4,
+ text TYPE string,
+ is_collapsed TYPE flag,
+ is_visible TYPE flag,
+ row_int_start TYPE zexcel_cell_row,
+ col_alpha TYPE zexcel_cell_column_alpha,
+ columnname TYPE fieldname,
+ END OF ts_line,
+ tt_line TYPE STANDARD TABLE OF ts_line.
+ DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr,
+ lo_data TYPE REF TO data,
+ l_row_header TYPE zexcel_cell_row VALUE '2',
+ l_col_header TYPE zexcel_cell_column_alpha VALUE 'B',
+ l_row_int_start TYPE zexcel_cell_row,
+ l_row_int_end TYPE zexcel_cell_row,
+ l_row_int TYPE zexcel_cell_row,
+ l_col_int TYPE zexcel_cell_column,
+ l_col_alpha TYPE zexcel_cell_column_alpha,
+ l_col_alpha_start TYPE zexcel_cell_column_alpha,
+ l_cell_value TYPE zexcel_cell_value,
+ l_s_color TYPE abap_bool,
+ lo_col_dim TYPE REF TO zcl_excel_worksheet_columndime,
+ lo_row_dim TYPE REF TO zcl_excel_worksheet_rowdimensi,
+ l_formula TYPE zexcel_cell_formula,
+ l_style TYPE zexcel_cell_style,
+ l_subtotalled TYPE flag,
+ l_text TYPE string,
+ ls_sort_values TYPE ts_sort_values,
+ ls_subtotal_rows TYPE ts_subtotal_rows,
+ l_sort_level TYPE int4,
+ ls_line TYPE ts_line,
+ lt_line TYPE tt_line,
+ l_line TYPE i,
+ l_guid TYPE guid_22,
+ l_tabix TYPE sy-tabix,
+ l_cells TYPE i,
+ l_count TYPE i,
+ l_table_row TYPE i.
+
+ FIELD-SYMBOLS: <fs_stab> TYPE ANY,
+ <fs_tab> TYPE STANDARD TABLE,
+ <fs_sfcat> TYPE zexcel_s_converter_fcat,
+ <fs_fldval> TYPE ANY,
+ <fs_sortval> TYPE ANY,
+ <fs_sortv> TYPE ts_sort_values,
+ <fs_cell_value> TYPE zexcel_cell_value.
+
+ ASSIGN wo_data->* TO <fs_tab> .
+
+ REFRESH: wt_sort_values,
+ wt_subtotal_rows.
+
+ DESCRIBE TABLE wt_fieldcatalog LINES l_cells.
+ DESCRIBE TABLE <fs_tab> LINES l_count.
+ l_cells = l_cells * l_count.
+
+ READ TABLE <fs_tab> ASSIGNING <fs_stab> INDEX 1.
+ IF sy-subrc = 0.
+ l_row_int = i_row_int + 1.
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_sfcat> WHERE is_subtotalled = abap_true.
+ ASSIGN COMPONENT <fs_sfcat>-columnname OF STRUCTURE <fs_stab> TO <fs_fldval>.
+ ls_sort_values-fieldname = <fs_sfcat>-columnname.
+ ls_sort_values-row_int = l_row_int.
+ CREATE DATA ls_sort_values-value LIKE <fs_fldval>.
+ ASSIGN ls_sort_values-value->* TO <fs_sortval>.
+ <fs_sortval> = <fs_fldval>.
+ INSERT ls_sort_values INTO TABLE wt_sort_values.
+ ENDLOOP.
+ ENDIF.
+ l_row_int = i_row_int.
+* First loop without formular only addtional rows with subtotal text.
+ LOOP AT <fs_tab> ASSIGNING <fs_stab>.
+ l_table_row = sy-tabix.
+ ADD 1 TO l_row_int. " 1 is for header row.
+ REFRESH lt_line.
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_sfcat> WHERE is_subtotalled = abap_true.
+ l_col_int = i_col_int + <fs_sfcat>-position - 1.
+ l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
+* Now the cell values
+ ASSIGN COMPONENT <fs_sfcat>-columnname OF STRUCTURE <fs_stab> TO <fs_fldval>.
+ IF sy-subrc = 0.
+ READ TABLE wt_sort_values ASSIGNING <fs_sortv> WITH TABLE KEY fieldname = <fs_sfcat>-columnname.
+ IF sy-subrc = 0.
+ ASSIGN <fs_sortv>-value->* TO <fs_sortval>.
+ IF <fs_sortval> <> <fs_fldval> OR <fs_sortv>-new = abap_true.
+* First let's write the value as it has to appear.
+ CLEAR ls_line.
+ ls_line-text = create_text_subtotal( i_value = <fs_sortval>
+ i_totals_function = <fs_sfcat>-totals_function ).
+ ls_line-col_alpha = l_col_alpha.
+ ls_line-sort_level = <fs_sfcat>-sort_level.
+ ls_line-is_collapsed = <fs_sfcat>-is_collapsed.
+ ls_line-row_int_start = <fs_sortv>-row_int.
+ ls_line-columnname = <fs_sfcat>-columnname.
+
+ INSERT ls_line INTO TABLE lt_line.
+* Now let's change the key
+ <fs_sortval> = <fs_fldval>.
+ <fs_sortv>-new = abap_false.
+ <fs_sortv>-row_int = l_row_int.
+ ENDIF.
+ ENDIF.
+ ENDIF.
+ ENDLOOP.
+* Now we must write the lines in correct sequence.
+ l_row_int_start = l_row_int.
+ SORT lt_line BY sort_level DESCENDING.
+ DESCRIBE TABLE lt_line LINES l_line.
+ LOOP AT lt_line INTO ls_line.
+ l_tabix = sy-tabix.
+ ls_subtotal_rows-row_int = l_row_int.
+ ls_subtotal_rows-row_int_start = ls_line-row_int_start.
+ ls_subtotal_rows-columnname = ls_line-columnname.
+ INSERT ls_subtotal_rows INTO TABLE wt_subtotal_rows.
+
+ wo_worksheet->set_cell( ip_column = ls_line-col_alpha
+ ip_row = l_row_int
+ ip_value = ls_line-text
+ ip_abap_type = cl_abap_typedescr=>typekind_string
+ ip_style = <fs_sfcat>-style_subtotal ).
+ READ TABLE wt_sort_values ASSIGNING <fs_sortv> WITH TABLE KEY fieldname = ls_line-columnname.
+ IF sy-subrc = 0.
+ IF l_line > l_tabix . " Only if we have more than 1 and subtotal does not change on lower level but on higher does
+ <fs_sortv>-new = abap_true.
+ ENDIF.
+ <fs_sortv>-row_int = l_row_int_start + l_line.
+ ENDIF.
+ l_sort_level = ls_line-sort_level.
+ lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
+ lo_row_dim->set_outline_level( ip_outline_level = l_sort_level ) .
+ lo_row_dim->set_collapsed( ip_collapsed = ls_line-is_collapsed ) .
+ ADD 1 TO l_row_int.
+ ENDLOOP.
+ ENDLOOP.
+ ADD 1 TO l_row_int.
+ REFRESH lt_line.
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_sfcat> WHERE is_subtotalled = abap_true.
+ l_col_int = i_col_int + <fs_sfcat>-position - 1.
+ l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
+ READ TABLE wt_sort_values ASSIGNING <fs_sortv> WITH TABLE KEY fieldname = <fs_sfcat>-columnname.
+ IF sy-subrc = 0.
+ ASSIGN <fs_sortv>-value->* TO <fs_sortval>.
+* First let's write the value as it has to appear.
+ CLEAR ls_line.
+ ls_line-text = create_text_subtotal( i_value = <fs_sortval>
+ i_totals_function = <fs_sfcat>-totals_function ).
+ ls_line-col_alpha = l_col_alpha.
+ ls_line-sort_level = <fs_sfcat>-sort_level.
+ ls_line-is_collapsed = <fs_sfcat>-is_collapsed.
+ ls_line-row_int_start = <fs_sortv>-row_int.
+ ls_line-columnname = <fs_sfcat>-columnname.
+ INSERT ls_line INTO TABLE lt_line.
+ ENDIF.
+ ENDLOOP.
+* Now we must write the lines in correct sequence.
+ l_row_int_start = l_row_int.
+ SORT lt_line BY sort_level DESCENDING.
+ DESCRIBE TABLE lt_line LINES l_line.
+ LOOP AT lt_line INTO ls_line.
+ ls_subtotal_rows-row_int = l_row_int.
+ ls_subtotal_rows-row_int_start = ls_line-row_int_start.
+ ls_subtotal_rows-columnname = ls_line-columnname.
+ INSERT ls_subtotal_rows INTO TABLE wt_subtotal_rows.
+
+ wo_worksheet->set_cell( ip_column = ls_line-col_alpha
+ ip_row = l_row_int
+ ip_value = ls_line-text
+ ip_abap_type = cl_abap_typedescr=>typekind_string
+ ip_style = <fs_sfcat>-style_subtotal ).
+
+ l_sort_level = ls_line-sort_level.
+ lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
+ lo_row_dim->set_outline_level( ip_outline_level = l_sort_level ) .
+ lo_row_dim->set_collapsed( ip_collapsed = ls_line-is_collapsed ) .
+ ADD 1 TO l_row_int.
+ ENDLOOP.
+* Let's write the Grand total
+ l_sort_level = 0.
+ lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
+ lo_row_dim->set_outline_level( ip_outline_level = l_sort_level ) .
+ lo_row_dim->set_collapsed( ip_collapsed = <fs_sfcat>-is_collapsed ) .
+
+ l_text = create_text_subtotal( i_value = 'Grand'(002)
+ i_totals_function = <fs_sfcat>-totals_function ).
+
+ l_col_alpha_start = zcl_excel_common=>convert_column2alpha( i_col_int ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha_start
+ ip_row = l_row_int
+ ip_value = l_text
+ ip_abap_type = cl_abap_typedescr=>typekind_string
+ ip_style = <fs_sfcat>-style_subtotal ).
+
+* It is better to loop column by column second time around
+* Second loop with formular and data.
+ LOOP AT wt_fieldcatalog ASSIGNING <fs_sfcat>.
+ l_row_int = i_row_int.
+ l_col_int = i_col_int + <fs_sfcat>-position - 1.
+* Freeze panes
+ IF <fs_sfcat>-fix_column = abap_true.
+ ADD 1 TO r_freeze_col.
+ ENDIF.
+ l_s_color = abap_true.
+ l_col_alpha = zcl_excel_common=>convert_column2alpha( l_col_int ).
+ " First of all write column header
+ l_cell_value = <fs_sfcat>-scrtext_m.
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_value = l_cell_value
+ ip_abap_type = cl_abap_typedescr=>typekind_string
+ ip_style = <fs_sfcat>-style_hdr ).
+ ADD 1 TO l_row_int.
+ LOOP AT <fs_tab> ASSIGNING <fs_stab>.
+ l_table_row = sy-tabix.
+* Now the cell values
+ ASSIGN COMPONENT <fs_sfcat>-columnname OF STRUCTURE <fs_stab> TO <fs_fldval>.
+* Let's check for subtotal lines
+ DO.
+ READ TABLE wt_subtotal_rows TRANSPORTING NO FIELDS WITH TABLE KEY row_int = l_row_int.
+ IF sy-subrc = 0.
+ IF <fs_sfcat>-is_subtotalled = abap_false AND
+ <fs_sfcat>-totals_function IS NOT INITIAL.
+ DO.
+ READ TABLE wt_subtotal_rows INTO ls_subtotal_rows WITH TABLE KEY row_int = l_row_int.
+ IF sy-subrc = 0.
+ l_row_int_start = ls_subtotal_rows-row_int_start.
+ l_row_int_end = l_row_int - 1.
+
+ l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start
+ i_row_int_end = l_row_int_end
+ i_column = l_col_alpha
+ i_totals_function = <fs_sfcat>-totals_function ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_formula = l_formula
+ ip_style = <fs_sfcat>-style_subtotal ).
+ ADD 1 TO l_row_int.
+ ELSE.
+ EXIT.
+ ENDIF.
+ ENDDO.
+ ELSE.
+ ADD 1 TO l_row_int.
+ ENDIF.
+ ELSE.
+ EXIT.
+ ENDIF.
+ ENDDO.
+ lo_row_dim = wo_worksheet->get_row_dimension( ip_row = l_row_int ).
+ lo_row_dim->set_outline_level( ip_outline_level = ws_layout-max_subtotal_level ) .
+ lo_row_dim->set_collapsed( ip_collapsed = <fs_sfcat>-is_collapsed ) .
+* Now let's write the cell values
+ IF ws_layout-is_stripped = abap_true AND l_s_color = abap_true.
+ l_style = get_color_style( i_row = l_table_row
+ i_fieldname = <fs_sfcat>-columnname
+ i_style = <fs_sfcat>-style_stripped ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_value = <fs_fldval>
+ ip_style = l_style ).
+ CLEAR l_s_color.
+ ELSE.
+ l_style = get_color_style( i_row = l_table_row
+ i_fieldname = <fs_sfcat>-columnname
+ i_style = <fs_sfcat>-style_normal ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_value = <fs_fldval>
+ ip_style = l_style ).
+ l_s_color = abap_true.
+ ENDIF.
+ READ TABLE wt_filter TRANSPORTING NO FIELDS WITH TABLE KEY rownumber = l_table_row
+ columnname = <fs_sfcat>-columnname.
+ IF sy-subrc = 0.
+ wo_worksheet->get_cell( EXPORTING
+ ip_column = l_col_alpha
+ ip_row = l_row_int
+ IMPORTING
+ ep_value = l_cell_value ).
+ wo_autofilter->set_value( i_column = l_col_int
+ i_value = l_cell_value ).
+ ENDIF.
+ ADD 1 TO l_row_int.
+ ENDLOOP.
+* Let's check for subtotal lines
+ DO.
+ READ TABLE wt_subtotal_rows TRANSPORTING NO FIELDS WITH TABLE KEY row_int = l_row_int.
+ IF sy-subrc = 0.
+ IF <fs_sfcat>-is_subtotalled = abap_false AND
+ <fs_sfcat>-totals_function IS NOT INITIAL.
+ DO.
+ READ TABLE wt_subtotal_rows INTO ls_subtotal_rows WITH TABLE KEY row_int = l_row_int.
+ IF sy-subrc = 0.
+ l_row_int_start = ls_subtotal_rows-row_int_start.
+ l_row_int_end = l_row_int - 1.
+
+ l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start
+ i_row_int_end = l_row_int_end
+ i_column = l_col_alpha
+ i_totals_function = <fs_sfcat>-totals_function ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_formula = l_formula
+ ip_style = <fs_sfcat>-style_subtotal ).
+ ADD 1 TO l_row_int.
+ ELSE.
+ EXIT.
+ ENDIF.
+ ENDDO.
+ ELSE.
+ ADD 1 TO l_row_int.
+ ENDIF.
+ ELSE.
+ EXIT.
+ ENDIF.
+ ENDDO.
+* Now let's check for Grand total
+ IF <fs_sfcat>-is_subtotalled = abap_false AND
+ <fs_sfcat>-totals_function IS NOT INITIAL.
+ l_row_int_start = i_row_int + 1.
+ l_row_int_end = l_row_int - 1.
+
+ l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start
+ i_row_int_end = l_row_int_end
+ i_column = l_col_alpha
+ i_totals_function = <fs_sfcat>-totals_function ).
+ wo_worksheet->set_cell( ip_column = l_col_alpha
+ ip_row = l_row_int
+ ip_formula = l_formula
+ ip_style = <fs_sfcat>-style_subtotal ).
+ ENDIF.
+* Now let's check for optimized
+ IF <fs_sfcat>-is_optimized = abap_true.
+ lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
+ lo_col_dim->set_auto_size( ip_auto_size = abap_true ) .
+ ENDIF.
+* Now let's check for visible
+ IF <fs_sfcat>-is_hidden = abap_true.
+ lo_col_dim = wo_worksheet->get_column_dimension( ip_column = l_col_alpha ).
+ lo_col_dim->set_visible( ip_visible = abap_false ) .
+ ENDIF.
+ ENDLOOP.
+
+ENDMETHOD.
+
+
+ method open_file.
data: l_bytecount type i,
lt_file type solix_tab,
l_dir type string,
@@ -783,29 +1695,117 @@ endmethod.
endmethod.
-
- method SET_FIELDCATALOG.
- data: lt_fieldcat type zexcel_t_fieldcatalog,
- ls_fieldcat type zexcel_s_fieldcatalog,
- ls_fcat type zexcel_s_converter_fcat.
+
+ METHOD set_autofilter_area.
+ DATA: ls_area TYPE zexcel_s_autofilter_area,
+ l_lines TYPE i,
+ lt_values TYPE zexcel_t_autofilter_values,
+ ls_values TYPE zexcel_s_autofilter_values.
+* Let's check for filter.
+ IF wo_autofilter IS BOUND.
+ ls_area-row_start = 1.
+ lt_values = wo_autofilter->get_values( ) .
+ SORT lt_values BY column ASCENDING.
+ DESCRIBE TABLE lt_values LINES l_lines.
+ READ TABLE lt_values INTO ls_values INDEX 1.
+ IF sy-subrc = 0.
+ ls_area-col_start = ls_values-column.
+ ENDIF.
+ READ TABLE lt_values INTO ls_values INDEX l_lines.
+ IF sy-subrc = 0.
+ ls_area-col_end = ls_values-column.
+ ENDIF.
+ wo_autofilter->set_filter_area( is_area = ls_area ) .
+ ENDIF.
- field-symbols: <fs_tab> type any table.
-
- assign wo_data->* to <fs_tab> .
-
- lt_fieldcat = zcl_excel_common=>get_fieldcatalog( ip_table = <fs_tab> ).
-
- loop at lt_fieldcat into ls_fieldcat.
- move-corresponding ls_fieldcat to ls_fcat.
- insert ls_fcat into table wt_fieldcatalog.
- endloop.
+ENDMETHOD.
+
+
+
+
+
+ method set_cell_format.
+ data: l_format type zexcel_number_format.
+ clear r_format.
+ case i_inttype.
+ when cl_abap_typedescr=>typekind_date.
+ r_format = wo_worksheet->get_default_excel_date_format( ).
+ when cl_abap_typedescr=>typekind_time.
+ r_format = zcl_excel_style_number_format=>c_format_date_time6.
+ when cl_abap_typedescr=>typekind_float or cl_abap_typedescr=>typekind_packed.
+ if i_decimals > 0 .
+ l_format = '#,##0.'.
+ do i_decimals times.
+ concatenate l_format '0' into l_format.
+ enddo.
+ r_format = l_format.
+ endif.
+ endcase.
endmethod.
-
-
- method WRITE_FILE.
+
+ METHOD set_fieldcatalog.
+ DATA: lr_data TYPE REF TO data,
+ lo_structdescr TYPE REF TO cl_abap_structdescr,
+ lo_elemdescr TYPE REF TO cl_abap_elemdescr,
+ lt_dfies TYPE ddfields,
+ ls_dfies TYPE dfies,
+ lv_sytabix TYPE sytabix,
+ lt_components TYPE abap_component_tab,
+ ls_component LIKE LINE OF lt_components.
+
+ DATA: ls_fcat TYPE zexcel_s_converter_fcat.
+
+
+ FIELD-SYMBOLS: <fs_tab> TYPE ANY TABLE.
+
+ ASSIGN wo_data->* TO <fs_tab> .
+
+ CREATE DATA lr_data LIKE LINE OF <fs_tab>.
+
+ lo_structdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
+
+ "for DDIC structure get the info directly
+ IF lo_structdescr->is_ddic_type( ) = abap_true.
+ lt_dfies = lo_structdescr->get_ddic_field_list( ).
+
+ LOOP AT lt_dfies INTO ls_dfies.
+ MOVE-CORRESPONDING ls_dfies TO ls_fcat.
+ ls_fcat-columnname = ls_dfies-fieldname.
+ INSERT ls_fcat INTO TABLE wt_fieldcatalog.
+ ENDLOOP.
+ ELSE.
+ "if structure is not DDIC check components
+ lt_components = lo_structdescr->get_components( ).
+ LOOP AT lt_components INTO ls_component.
+ lv_sytabix = sy-tabix.
+ CLEAR ls_fcat.
+ lo_elemdescr ?= ls_component-type.
+ "component is DDIC
+ IF lo_elemdescr->is_ddic_type( ) = abap_true.
+ ls_dfies = lo_elemdescr->get_ddic_field( ).
+ MOVE-CORRESPONDING ls_dfies TO ls_fcat.
+ ls_fcat-columnname = ls_component-name.
+ ELSE.
+ "component is not DDIC -> return minimum information required
+ ls_fcat-fieldname = ls_component-name.
+ ls_fcat-columnname = ls_component-name.
+ ls_fcat-scrtext_m = ls_component-name.
+ ENDIF.
+ ls_fcat-position = lv_sytabix.
+ INSERT ls_fcat INTO TABLE wt_fieldcatalog.
+ ENDLOOP.
+ ENDIF.
+
+ clean_fieldcatalog( ).
+
+ENDMETHOD.
+
+
+
+ method write_file.
data: l_bytecount type i,
lt_file type solix_tab,
l_dir type string.
diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk
new file mode 100644
index 0000000..2fe4c1c
--- /dev/null
+++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV.slnk
@@ -0,0 +1,561 @@
+
+
+
+ class ZCL_EXCEL_CONVERTER_ALV definition
+ public
+ abstract
+ create public .
+
+*"* public components of class ZCL_EXCEL_CONVERTER_ALV
+*"* do not include other source files here!!!
+public section.
+ type-pools ABAP .
+ type-pools KKBLO .
+
+ interfaces ZIF_EXCEL_CONVERTER
+ all methods abstract .
+
+ class-methods CLASS_CONSTRUCTOR .
+ *"* protected components of class ZCL_EXCEL_CONVERTER_ALV
+*"* do not include other source files here!!!
+protected section.
+
+ data WT_SORT type LVC_T_SORT .
+ data WT_FILT type LVC_T_FILT .
+ data WT_FCAT type LVC_T_FCAT .
+ data WS_LAYO type LVC_S_LAYO .
+
+ methods UPDATE_CATALOG
+ changing
+ !CS_LAYOUT type ZEXCEL_S_CONVERTER_LAYO
+ !CT_FIELDCATALOG type ZEXCEL_T_CONVERTER_FCAT .
+ methods APPLY_SORT
+ importing
+ !IT_TABLE type STANDARD TABLE
+ exporting
+ !EO_TABLE type ref to DATA .
+ methods GET_COLOR
+ importing
+ !IO_TABLE type ref to DATA
+ exporting
+ !ET_COLORS type ZEXCEL_T_CONVERTER_COL .
+ methods GET_FILTER
+ importing
+ !IO_TABLE type ref to DATA
+ exporting
+ !ET_FILTER type ZEXCEL_T_CONVERTER_FIL .
+ *"* private components of class ZCL_EXCEL_CONVERTER_ALV
+*"* do not include other source files here!!!
+private section.
+
+ class-data WT_COLORS type TT_COL_CONVERTER .
+ *"* 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
+TYPES: BEGIN OF ts_col_converter,
+ col TYPE lvc_col,
+ int TYPE lvc_int,
+ inv TYPE lvc_inv,
+ fontcolor TYPE zexcel_style_color_argb,
+ fillcolor TYPE zexcel_style_color_argb,
+ END OF ts_col_converter,
+
+ tt_col_converter TYPE HASHED TABLE OF ts_col_converter WITH UNIQUE KEY col int inv.
+ *"* use this source file for any macro definitions you need
+*"* in the implementation part of the class
+
+
+ ABAP
+ KKBLO
+
+
+
+
+
+
+
+
+ METHOD apply_sort.
+ DATA: lt_otab TYPE abap_sortorder_tab,
+ ls_otab TYPE abap_sortorder.
+
+ FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE,
+ <fs_sort> TYPE lvc_s_sort.
+
+ CREATE DATA eo_table LIKE it_table.
+ ASSIGN eo_table->* TO <fs_table>.
+
+ <fs_table> = it_table.
+
+ sort wt_sort by spos.
+ LOOP AT wt_sort ASSIGNING <fs_sort>.
+ IF <fs_sort>-up = abap_true.
+ ls_otab-name = <fs_sort>-fieldname.
+ ls_otab-descending = abap_false.
+* ls_otab-astext = abap_true. " not only text fields
+ INSERT ls_otab INTO TABLE lt_otab.
+ ENDIF.
+ IF <fs_sort>-down = abap_true.
+ ls_otab-name = <fs_sort>-fieldname.
+ ls_otab-descending = abap_true.
+* ls_otab-astext = abap_true. " not only text fields
+ INSERT ls_otab INTO TABLE lt_otab.
+ ENDIF.
+ ENDLOOP.
+ IF lt_otab IS NOT INITIAL.
+ SORT <fs_table> BY (lt_otab).
+ ENDIF.
+ENDMETHOD.
+
+
+ METHOD class_constructor.
+* let's fill the color conversion routines.
+ DATA: ls_color TYPE ts_col_converter.
+* 0 all combination the same
+ ls_color-col = 0.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 0.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 0.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 0.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+* Blue
+ ls_color-col = 1.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFB0E4FC'. " 176 228 252 blue
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 1.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFB0E4FC'. " 176 228 252 blue
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 1.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FF5FCBFE'. " 095 203 254 Int blue
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 1.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FF5FCBFE'. " 095 203 254
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255
+ INSERT ls_color INTO TABLE wt_colors.
+
+* Gray
+ ls_color-col = 2.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'.
+ ls_color-fillcolor = 'FFE5EAF0'. " 229 234 240 gray
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 2.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFE5EAF0'. " 229 234 240 gray
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 2.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFD8E8F4'. " 216 234 244 int gray
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 2.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFD8E8F4'. " 216 234 244 int gray
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+*Yellow
+ ls_color-col = 3.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFEFEB8'. " 254 254 184 yellow
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 3.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFFEFEB8'. " 254 254 184 yellow
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 3.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFF9ED5D'. " 249 237 093 int yellow
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 3.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFF9ED5D'. " 249 237 093 int yellow
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+* light blue
+ ls_color-col = 4.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFCEE7FB'. " 206 231 251 light blue
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 4.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFCEE7FB'. " 206 231 251 light blue
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 4.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FF9ACCEF'. " 154 204 239 int light blue
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 4.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FF9ACCEF'. " 154 204 239 int light blue
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+* Green
+ ls_color-col = 5.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFCEF8AE'. " 206 248 174 Green
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 5.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFCEF8AE'. " 206 248 174 Green
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 5.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FF7AC769'. " 122 199 105 int Green
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 5.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FF7AC769'. " 122 199 105 int Green
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+* Red
+ ls_color-col = 6.
+ ls_color-int = 0.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFDBBBC'. " 253 187 188 Red
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 6.
+ ls_color-int = 0.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFFDBBBC'. " 253 187 188 Red
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 6.
+ ls_color-int = 1.
+ ls_color-inv = 0.
+ ls_color-fontcolor = 'FF000000'. " 000 000 000 Black
+ ls_color-fillcolor = 'FFFB6B6B'. " 251 107 107 int Red
+ INSERT ls_color INTO TABLE wt_colors.
+
+ ls_color-col = 6.
+ ls_color-int = 1.
+ ls_color-inv = 1.
+ ls_color-fontcolor = 'FFFB6B6B'. " 251 107 107 int Red
+ ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White
+ INSERT ls_color INTO TABLE wt_colors.
+
+ENDMETHOD.
+
+
+
+
+ METHOD get_color.
+ DATA: ls_con_col TYPE zexcel_s_converter_col,
+ ls_color TYPE ts_col_converter,
+ l_line TYPE i.
+ FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE,
+ <fs_stab> TYPE ANY,
+ <fs> TYPE ANY,
+ <fs_tcol> TYPE lvc_t_scol,
+ <fs_scol> TYPE lvc_s_scol.
+* Loop trough the table to set the color properties of each line. The color properties field is
+* Char 4 and the characters is set as follows:
+* Char 1 = C = This is a color property
+* Char 2 = 6 = Color code (1 - 7)
+* Char 3 = Intensified on/of = 1 = on
+* Char 4 = Inverse display = 0 = of
+
+ ASSIGN io_table->* TO <fs_tab>.
+
+ IF ws_layo-info_fname IS NOT INITIAL OR
+ ws_layo-ctab_fname IS NOT INITIAL.
+ LOOP AT <fs_tab> ASSIGNING <fs_stab>.
+ l_line = sy-tabix.
+ IF ws_layo-info_fname IS NOT INITIAL.
+ ASSIGN COMPONENT ws_layo-info_fname OF STRUCTURE <fs_stab> TO <fs>.
+ IF sy-subrc = 0.
+ IF <fs> IS NOT INITIAL.
+ READ TABLE wt_colors INTO ls_color WITH TABLE KEY col = <fs>+1(1)
+ int = <fs>+2(1)
+ inv = <fs>+3(1).
+ IF sy-subrc = 0.
+ ls_con_col-rownumber = l_line.
+ ls_con_col-columnname = space.
+ ls_con_col-fontcolor = ls_color-fontcolor.
+ ls_con_col-fillcolor = ls_color-fillcolor.
+ INSERT ls_con_col INTO TABLE et_colors.
+ ENDIF.
+ ENDIF.
+ ENDIF.
+ ENDIF.
+ IF ws_layo-ctab_fname IS NOT INITIAL.
+ ASSIGN COMPONENT ws_layo-ctab_fname OF STRUCTURE <fs_stab> TO <fs_tcol>.
+ IF sy-subrc = 0.
+ LOOP AT <fs_tcol> ASSIGNING <fs_scol>.
+ READ TABLE wt_colors INTO ls_color WITH TABLE KEY col = <fs_scol>-color-col
+ int = <fs_scol>-color-int
+ inv = <fs_scol>-color-inv.
+ IF sy-subrc = 0.
+ ls_con_col-rownumber = l_line.
+ ls_con_col-columnname = <fs_scol>-fname.
+ ls_con_col-fontcolor = ls_color-fontcolor.
+ ls_con_col-fillcolor = ls_color-fillcolor.
+ ls_con_col-nokeycol = <fs_scol>-nokeycol.
+ INSERT ls_con_col INTO TABLE et_colors.
+ ENDIF.
+ ENDLOOP.
+ ENDIF.
+ ENDIF.
+ ENDLOOP.
+ ENDIF.
+ENDMETHOD.
+
+
+
+
+ METHOD get_filter.
+ DATA: ls_filt TYPE lvc_s_filt,
+ l_line TYPE i,
+ ls_filter TYPE zexcel_s_converter_fil.
+ DATA: lo_addit TYPE REF TO cl_abap_elemdescr,
+ lt_components_tab TYPE cl_abap_structdescr=>component_table,
+ ls_components TYPE abap_componentdescr,
+ lo_table TYPE REF TO cl_abap_tabledescr,
+ lo_struc TYPE REF TO cl_abap_structdescr,
+ lo_tdata TYPE REF TO data,
+ lo_sdata TYPE REF TO data.
+
+ FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE,
+ <fs_stab> TYPE ANY,
+ <fs> TYPE ANY,
+ <fs1> TYPE ANY,
+ <fs_srange> TYPE ANY,
+ <fs_trange> TYPE STANDARD TABLE.
+
+ ASSIGN io_table->* TO <fs_tab>.
+
+ LOOP AT wt_filt INTO ls_filt.
+ LOOP AT <fs_tab> ASSIGNING <fs_stab>.
+ l_line = sy-tabix.
+ ASSIGN COMPONENT ls_filt-fieldname OF STRUCTURE <fs_stab> TO <fs>.
+ IF sy-subrc = 0.
+ IF l_line = 1.
+ REFRESH lt_components_tab.
+ ls_components-name = 'SIGN'.
+ lo_addit ?= cl_abap_typedescr=>describe_by_data( ls_filt-sign ).
+ ls_components-type = lo_addit .
+ INSERT ls_components INTO TABLE lt_components_tab.
+ ls_components-name = 'OPTION'.
+ lo_addit ?= cl_abap_typedescr=>describe_by_data( ls_filt-option ).
+ ls_components-type = lo_addit .
+ INSERT ls_components INTO TABLE lt_components_tab.
+ ls_components-name = 'LOW'.
+ lo_addit ?= cl_abap_typedescr=>describe_by_data( <fs> ).
+ ls_components-type = lo_addit .
+ INSERT ls_components INTO TABLE lt_components_tab.
+ ls_components-name = 'HIGH'.
+ lo_addit ?= cl_abap_typedescr=>describe_by_data( <fs> ).
+ ls_components-type = lo_addit .
+ INSERT ls_components INTO TABLE lt_components_tab.
+ "create new line type
+ lo_struc = cl_abap_structdescr=>create( lt_components_tab ).
+ lo_table = cl_abap_tabledescr=>create( lo_struc ).
+
+ CREATE DATA lo_tdata TYPE HANDLE lo_table.
+ CREATE DATA lo_sdata TYPE HANDLE lo_struc.
+
+ ASSIGN lo_tdata->* TO <fs_trange>.
+ ASSIGN lo_sdata->* TO <fs_srange>.
+ ENDIF.
+ REFRESH <fs_trange>.
+ ASSIGN COMPONENT 'SIGN' OF STRUCTURE <fs_srange> TO <fs1>.
+ <fs1> = ls_filt-sign.
+ ASSIGN COMPONENT 'OPTION' OF STRUCTURE <fs_srange> TO <fs1>.
+ <fs1> = ls_filt-option.
+ ASSIGN COMPONENT 'LOW' OF STRUCTURE <fs_srange> TO <fs1>.
+ <fs1> = ls_filt-low.
+ ASSIGN COMPONENT 'HIGH' OF STRUCTURE <fs_srange> TO <fs1>.
+ <fs1> = ls_filt-high.
+ INSERT <fs_srange> INTO TABLE <fs_trange>.
+ IF <fs> IN <fs_trange>.
+ ls_filter-rownumber = l_line.
+ ls_filter-columnname = ls_filt-fieldname.
+ INSERT ls_filter INTO TABLE et_filter.
+ ENDIF.
+ ENDIF.
+ ENDLOOP.
+ ENDLOOP.
+
+ENDMETHOD.
+
+
+
+
+ METHOD update_catalog.
+ DATA: ls_fieldcatalog TYPE zexcel_s_converter_fcat,
+ ls_ref TYPE salv_s_ddic_reference,
+ ls_fcat TYPE lvc_s_fcat,
+ ls_sort TYPE lvc_s_sort,
+ l_decimals TYPE lvc_decmls.
+
+ FIELD-SYMBOLS: <fs_scat> TYPE zexcel_s_converter_fcat.
+
+ IF ws_layo-zebra IS NOT INITIAL.
+ cs_layout-is_stripped = abap_true.
+ ENDIF.
+ IF ws_layo-no_keyfix IS INITIAL OR
+ ws_layo-no_keyfix = '0'.
+ cs_layout-is_fixed = abap_true.
+ ENDIF.
+ LOOP AT wt_fcat INTO ls_fcat.
+ CLEAR: ls_fieldcatalog,
+ l_decimals.
+ IF ls_fcat-tech = abap_false.
+ ls_fieldcatalog-tabname = ls_fcat-tabname.
+ ls_fieldcatalog-fieldname = ls_fcat-fieldname .
+ ls_fieldcatalog-columnname = ls_fcat-fieldname .
+ ls_fieldcatalog-position = ls_fcat-col_pos.
+ ls_fieldcatalog-col_id = ls_fcat-col_id.
+ ls_fieldcatalog-convexit = ls_fcat-convexit.
+ ls_fieldcatalog-inttype = ls_fcat-inttype.
+ ls_fieldcatalog-scrtext_s = ls_fcat-scrtext_s .
+ ls_fieldcatalog-scrtext_m = ls_fcat-scrtext_m .
+ ls_fieldcatalog-scrtext_l = ls_fcat-scrtext_l.
+ l_decimals = ls_fcat-decimals_o.
+ IF l_decimals IS NOT INITIAL.
+ ls_fieldcatalog-decimals = l_decimals.
+ ELSE.
+ ls_fieldcatalog-decimals = ls_fcat-decimals .
+ ENDIF.
+ CASE ls_fcat-do_sum.
+ WHEN abap_true.
+ ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_sum.
+ WHEN 'A'.
+ ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_min.
+ WHEN 'B' .
+ ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_average.
+ WHEN 'C' .
+ ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_max.
+ WHEN OTHERS.
+ CLEAR ls_fieldcatalog-totals_function .
+ ENDCASE.
+ ls_fieldcatalog-fix_column = ls_fcat-fix_column.
+ IF ws_layo-cwidth_opt IS INITIAL.
+ IF ls_fcat-col_opt IS NOT INITIAL.
+ ls_fieldcatalog-is_optimized = abap_true.
+ ENDIF.
+ ELSE.
+ ls_fieldcatalog-is_optimized = abap_true.
+ ENDIF.
+ IF ls_fcat-no_out IS NOT INITIAL.
+ ls_fieldcatalog-is_hidden = abap_true.
+ ls_fieldcatalog-position = ls_fieldcatalog-col_id. " We hide based on orginal data structure
+ ENDIF.
+* Alignment in each cell
+ CASE ls_fcat-just.
+ WHEN 'R'.
+ ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_right.
+ WHEN 'L'.
+ ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_left.
+ WHEN 'C'.
+ ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_center.
+ WHEN OTHERS.
+ CLEAR ls_fieldcatalog-alignment.
+ ENDCASE.
+* Check for subtotals.
+ READ TABLE wt_sort INTO ls_sort WITH KEY fieldname = ls_fcat-fieldname.
+ IF sy-subrc = 0.
+ ls_fieldcatalog-sort_level = 0 .
+ ls_fieldcatalog-is_subtotalled = ls_sort-subtot.
+ ls_fieldcatalog-is_collapsed = ls_sort-comp.
+ IF ls_fieldcatalog-is_subtotalled = abap_true.
+ ls_fieldcatalog-sort_level = ls_sort-spos.
+ ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_sum. " we need function for text
+ ENDIF.
+ ENDIF.
+ APPEND ls_fieldcatalog TO ct_fieldcatalog.
+ ENDIF.
+ ENDLOOP.
+ SORT ct_fieldcatalog BY sort_level ASCENDING.
+ cs_layout-max_subtotal_level = 0.
+ LOOP AT ct_fieldcatalog ASSIGNING <fs_scat> WHERE sort_level > 0.
+ cs_layout-max_subtotal_level = cs_layout-max_subtotal_level + 1.
+ <fs_scat>-sort_level = cs_layout-max_subtotal_level.
+ ENDLOOP.
+
+ENDMETHOD.
+
+
diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk
index 866be54..b85d1a4 100644
--- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk
+++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_ALV_GRID.slnk
@@ -1,16 +1,19 @@
-
-
+
class ZCL_EXCEL_CONVERTER_ALV_GRID definition
public
+ inheriting from ZCL_EXCEL_CONVERTER_ALV
final
create public .
-public section.
*"* public components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*"* do not include other source files here!!!
+public section.
- interfaces ZIF_EXCEL_CONVERTER .
+ methods ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT
+ redefinition .
+ methods ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG
+ redefinition .
*"* protected components of class ZCL_EXCEL_CONVERTER_ALV_GRID
*"* do not include other source files here!!!
protected section.
@@ -25,6 +28,10 @@ private section.
*"* implementation or private method's signature
*"* use this source file for any macro definitions you need
*"* in the implementation part of the class
+
+
+
+
method ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT.
data: lo_alv type REF TO cl_gui_alv_grid.
@@ -40,12 +47,7 @@ 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.
@@ -56,57 +58,23 @@ endmethod.
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.
+ lo_alv->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = wt_fcat ).
+ lo_alv->get_frontend_layout( IMPORTING es_layout = ws_layo ).
+ lo_alv->get_sort_criteria( IMPORTING et_sort = wt_sort ) .
+ lo_alv->get_filter_criteria( IMPORTING et_filter = wt_filt ) .
+ apply_sort( EXPORTING it_table = it_table
+ IMPORTING eo_table = eo_table ) .
+
+ get_color( EXPORTING io_table = eo_table
+ IMPORTING et_colors = et_colors ) .
+
+ get_filter( EXPORTING io_table = eo_table
+ IMPORTING et_filter = et_filter ) .
+
+ update_catalog( CHANGING cs_layout = es_layout
+ ct_fieldcatalog = et_fieldcatalog ).
+ ENDIF.
ENDMETHOD.
diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_EX_RESULT.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_EX_RESULT.slnk
new file mode 100644
index 0000000..1664e60
--- /dev/null
+++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_EX_RESULT.slnk
@@ -0,0 +1,95 @@
+
+
+ class ZCL_EXCEL_CONVERTER_EX_RESULT definition
+ public
+ inheriting from ZCL_EXCEL_CONVERTER_ALV
+ final
+ create public .
+
+*"* public components of class ZCL_EXCEL_CONVERTER_EX_RESULT
+*"* do not include other source files here!!!
+public section.
+
+ methods ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT
+ redefinition .
+ methods ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG
+ redefinition .
+ *"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE
+*"* do not include other source files here!!!
+protected section.
+ *"* private components of class ZCL_EXCEL_CONVERTER_EX_RESULT
+*"* 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 class
+
+
+
+
+
+ METHOD zif_excel_converter~can_convert_object.
+
+ DATA: lo_result TYPE REF TO cl_salv_ex_result_data_table.
+
+ TRY.
+ lo_result ?= io_object.
+ CATCH cx_sy_move_cast_error .
+ RAISE EXCEPTION TYPE zcx_excel.
+ ENDTRY.
+
+ENDMETHOD.
+
+
+ METHOD zif_excel_converter~create_fieldcatalog.
+ DATA: lo_result TYPE REF TO cl_salv_ex_result_data_table,
+ lo_bs_data TYPE REF TO cl_salv_bs_data_table,
+ lo_ex_cm TYPE REF TO cl_salv_ex_cm,
+ lo_data TYPE REF TO data.
+
+ FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
+
+ TRY.
+ zif_excel_converter~can_convert_object( io_object = io_object ).
+ ENDTRY.
+
+ lo_result ?= io_object.
+
+ CLEAR: es_layout,
+ et_fieldcatalog.
+
+ IF lo_result IS BOUND.
+ lo_bs_data ?= lo_result->r_model->r_data.
+ lo_data = lo_bs_data->get_ref_to_table( ) .
+ ASSIGN lo_data->* TO <fs_table> .
+
+ lo_ex_cm ?= lo_result->r_model->r_model.
+ ws_layo = lo_ex_cm->s_layo.
+* T_DRDN Instance Attribute Public Type LVC_T_DROP
+ wt_fcat = lo_ex_cm->t_fcat.
+ wt_filt = lo_ex_cm->t_filt.
+* T_HYPE Instance Attribute Public Type LVC_T_HYPE
+* T_SELECTED_CELLS Instance Attribute Public Type LVC_T_CELL
+* T_SELECTED_COLUMNS Instance Attribute Public Type LVC_T_COL
+ wt_sort = lo_ex_cm->t_sort.
+
+ apply_sort( EXPORTING it_table = <fs_table>
+ IMPORTING eo_table = eo_table ) .
+
+ get_color( EXPORTING io_table = eo_table
+ IMPORTING et_colors = et_colors ) .
+
+ get_filter( EXPORTING io_table = eo_table
+ IMPORTING et_filter = et_filter ) .
+
+ update_catalog( CHANGING cs_layout = es_layout
+ ct_fieldcatalog = et_fieldcatalog ).
+ ENDIF.
+ENDMETHOD.
+
+
diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk
index 689ad2e..a68e430 100644
--- a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk
+++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_SALV_TABLE.slnk
@@ -1,22 +1,30 @@
-
-
+
class ZCL_EXCEL_CONVERTER_SALV_TABLE definition
public
+ inheriting from ZCL_EXCEL_CONVERTER_ALV
final
create public .
-public section.
*"* public components of class ZCL_EXCEL_CONVERTER_SALV_TABLE
*"* do not include other source files here!!!
+public section.
- interfaces ZIF_EXCEL_CONVERTER .
+ methods ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT
+ redefinition .
+ methods ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG
+ redefinition .
*"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE
*"* do not include other source files here!!!
protected section.
*"* private components of class ZCL_EXCEL_CONVERTER_SALV_TABLE
*"* do not include other source files here!!!
-private section.
+private section.
+
+ methods LOAD_DATA
+ importing
+ !IO_SALV type ref to CL_SALV_TABLE
+ !IT_TABLE type STANDARD TABLE .
*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes
@@ -25,39 +33,27 @@ private section.
*"* implementation or private method's signature
*"* use this source file for any macro definitions you need
*"* in the implementation part of the class
+
+
+
+
- method ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT.
- data: lo_salv type ref to cl_salv_table.
+ METHOD zif_excel_converter~can_convert_object.
- try.
+ DATA: lo_salv TYPE REF TO cl_salv_table.
+
+ TRY.
lo_salv ?= io_object.
- catch cx_sy_move_cast_error .
- raise exception type zcx_excel.
- endtry.
+ CATCH cx_sy_move_cast_error .
+ RAISE EXCEPTION TYPE zcx_excel.
+ ENDTRY.
-endmethod.
+ENDMETHOD.
METHOD zif_excel_converter~create_fieldcatalog.
DATA: lo_salv TYPE REF TO cl_salv_table.
- DATA: lo_columns TYPE REF TO cl_salv_columns_table,
- lo_column TYPE REF TO cl_salv_column_table,
- lo_aggregations TYPE REF TO cl_salv_aggregations,
- lo_aggregation TYPE REF TO cl_salv_aggregation,
- lo_sorts TYPE REF TO cl_salv_sorts,
- lo_sort TYPE REF TO cl_salv_sort,
- lo_display TYPE REF TO cl_salv_display_settings,
- l_agre TYPE salv_de_aggregation,
- lt_column TYPE salv_t_column_ref,
- ls_column TYPE salv_s_column_ref,
- ls_fieldcatalog TYPE zexcel_s_converter_fcat,
- ls_ref TYPE salv_s_ddic_reference,
- l_alignment TYPE salv_de_alignment,
- l_fix TYPE sap_bool,
- l_optimized TYPE sap_bool.
-
- FIELD-SYMBOLS: <fs_stable> TYPE any.
TRY.
zif_excel_converter~can_convert_object( io_object = io_object ).
ENDTRY.
@@ -65,87 +61,206 @@ endmethod.
lo_salv ?= io_object.
CLEAR: es_layout,
- et_fieldcatalog.
+ et_fieldcatalog,
+ et_colors .
IF lo_salv IS BOUND.
- lo_columns = lo_salv->get_columns( ).
- lt_column = lo_columns->get( ) .
- lo_aggregations = lo_salv->get_aggregations( ) .
- lo_display = lo_salv->get_display_settings( ) .
- es_layout-is_stripped = lo_display->is_striped_pattern( ) .
- l_optimized = lo_columns->is_optimized( ).
- LOOP AT lt_column INTO ls_column.
- CLEAR ls_fieldcatalog.
- IF ls_column-r_column->is_technical( ) = abap_false.
- TRY.
- lo_column ?= lo_columns->get_column( columnname = ls_column-columnname ).
- CATCH cx_salv_not_found.
- RAISE EXCEPTION TYPE zcx_excel.
- ENDTRY.
- ls_ref = ls_column-r_column->get_ddic_reference( ).
- ls_fieldcatalog-tabname = ls_ref-table.
- ls_fieldcatalog-fieldname = ls_ref-field.
- ls_fieldcatalog-columnname = ls_column-columnname.
- TRY.
- ls_fieldcatalog-position = lo_columns->get_column_position( columnname = ls_column-columnname ).
- CATCH cx_salv_not_found.
- RAISE EXCEPTION TYPE zcx_excel.
- ENDTRY.
- ls_fieldcatalog-inttype = ls_column-r_column->get_ddic_inttype( ).
- ls_fieldcatalog-scrtext_s = ls_column-r_column->get_short_text( ) .
- ls_fieldcatalog-scrtext_m = ls_column-r_column->get_medium_text( ) .
- ls_fieldcatalog-scrtext_l = ls_column-r_column->get_long_text( ).
- TRY.
- lo_aggregation = lo_aggregations->get_aggregation( columnname = ls_column-columnname ) .
- CATCH cx_salv_not_found.
- CLEAR lo_aggregation.
- ENDTRY.
- IF lo_aggregation IS BOUND.
- l_agre = lo_aggregation->get( ).
- CASE l_agre.
- WHEN if_salv_c_aggregation=>total. " Total
- ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_sum.
- WHEN if_salv_c_aggregation=>minimum. " Minimum
- ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_min.
- WHEN if_salv_c_aggregation=>maximum. " Maximum
- ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_max.
- WHEN if_salv_c_aggregation=>average. " Mean Value
- ls_fieldcatalog-totals_function = zcl_excel_table=>totals_function_average.
- WHEN OTHERS.
- CLEAR ls_fieldcatalog-totals_function.
- ENDCASE.
- ENDIF.
- ls_fieldcatalog-is_visible = ls_column-r_column->is_visible( ).
- ls_fieldcatalog-fix_column = lo_column->is_key( ).
- l_fix = lo_column->is_key_presence_required( ).
+ load_data( EXPORTING io_salv = lo_salv
+ it_table = it_table ).
+ apply_sort( EXPORTING it_table = it_table
+ IMPORTING eo_table = eo_table ) .
- IF l_optimized = '1' OR l_optimized = abap_true.
- ls_fieldcatalog-is_optimized = abap_true.
- ELSE.
- l_optimized = ls_column-r_column->is_optimized( ).
- IF l_optimized = '1' OR l_optimized = abap_true.
- ls_fieldcatalog-is_optimized = abap_true.
- ENDIF.
- ENDIF.
- l_alignment = ls_column-r_column->get_alignment( ) .
- CASE l_alignment.
- WHEN if_salv_c_alignment=>left. " Align left
- ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_left.
- WHEN if_salv_c_alignment=>right. " Align right
- ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_right.
- WHEN if_salv_c_alignment=>centered. " Centered
- ls_fieldcatalog-alignment = zcl_excel_style_alignment=>c_horizontal_center.
- WHEN OTHERS.
- CLEAR ls_fieldcatalog-alignment.
- ENDCASE.
- APPEND ls_fieldcatalog TO et_fieldcatalog.
- ENDIF.
- ENDLOOP.
- IF l_fix IS NOT INITIAL.
- es_layout-is_fixed = abap_true.
+ get_color( EXPORTING io_table = eo_table
+ IMPORTING et_colors = et_colors ) .
+
+ get_filter( EXPORTING io_table = eo_table
+ IMPORTING et_filter = et_filter ) .
+
+ update_catalog( CHANGING cs_layout = es_layout
+ ct_fieldcatalog = et_fieldcatalog ).
+ ENDIF.
+ENDMETHOD.
+
+
+
+
+ METHOD load_data.
+ DATA: lo_columns TYPE REF TO cl_salv_columns_table,
+ lo_aggregations TYPE REF TO cl_salv_aggregations,
+ lo_sorts TYPE REF TO cl_salv_sorts,
+ lo_filters TYPE REF TO cl_salv_filters,
+ lo_functional TYPE REF TO cl_salv_functional_settings,
+ lo_display TYPE REF TO cl_salv_display_settings,
+ lo_selections TYPE REF TO cl_salv_selections.
+
+ DATA: ls_vari TYPE disvariant,
+ lo_layout TYPE REF TO cl_salv_layout.
+
+ DATA: lr_form_tol TYPE REF TO cl_salv_form,
+ lr_form_eol TYPE REF TO cl_salv_form.
+
+ DATA lt_kkblo_fieldcat TYPE kkblo_t_fieldcat.
+ DATA ls_kkblo_layout TYPE kkblo_layout.
+ DATA lt_kkblo_filter TYPE kkblo_t_filter.
+ DATA lt_kkblo_sort TYPE kkblo_t_sortinfo.
+
+ lo_layout = io_salv->get_layout( ) .
+ lo_columns = io_salv->get_columns( ).
+ lo_aggregations = io_salv->get_aggregations( ) .
+ lo_sorts = io_salv->get_sorts( ) .
+ lo_filters = io_salv->get_filters( ) .
+ lo_display = io_salv->get_display_settings( ) .
+ lo_functional = io_salv->get_functional_settings( ) .
+
+ REFRESH: wt_fcat,
+ wt_sort,
+ wt_filt.
+
+* First update metadata if we can.
+ IF io_salv->is_offline( ) = abap_false.
+ io_salv->get_metadata( ) .
+ ELSE.
+* If we are offline we need to build this.
+ cl_salv_controller_metadata=>get_variant(
+ EXPORTING
+ r_layout = lo_layout
+ CHANGING
+ s_variant = ls_vari ).
+ ENDIF.
+
+*... get the column information
+ wt_fcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog(
+ r_columns = lo_columns
+ r_aggregations = lo_aggregations ).
+
+*... get the layout information
+ cl_salv_controller_metadata=>get_lvc_layout(
+ EXPORTING
+ r_functional_settings = lo_functional
+ r_display_settings = lo_display
+ r_columns = lo_columns
+ r_aggregations = lo_aggregations
+ CHANGING
+ s_layout = ws_layo ).
+
+* the fieldcatalog is not complete yet!
+ CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
+ EXPORTING
+ i_complete = 'X'
+ i_refresh_buffer = space
+ i_buffer_active = space
+ is_layout = ws_layo
+ i_test = '1'
+ i_fcat_complete = 'X'
+ IMPORTING
+* E_EDIT =
+ es_layout = ws_layo
+ CHANGING
+ ct_fieldcat = wt_fcat.
+
+
+ IF ls_vari IS NOT INITIAL AND io_salv->is_offline( ) = abap_true.
+ CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
+ EXPORTING
+ it_fieldcat_lvc = wt_fcat
+ is_layout_lvc = ws_layo
+ IMPORTING
+ et_fieldcat_kkblo = lt_kkblo_fieldcat
+ es_layout_kkblo = ls_kkblo_layout
+ TABLES
+ it_data = it_table
+ EXCEPTIONS
+ it_data_missing = 1
+ it_fieldcat_lvc_missing = 2
+ OTHERS = 3.
+ IF sy-subrc <> 0.
+* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
+* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
+
+ CALL FUNCTION 'LT_VARIANT_LOAD'
+ EXPORTING
+* I_TOOL = 'LT'
+ i_tabname = '1'
+* I_TABNAME_SLAVE =
+ i_dialog = ' '
+* I_USER_SPECIFIC = ' '
+* I_DEFAULT = 'X'
+* I_NO_REPTEXT_OPTIMIZE =
+* I_VIA_GRID =
+ i_fcat_complete = 'X'
+ IMPORTING
+* E_EXIT =
+ et_fieldcat = lt_kkblo_fieldcat
+ et_sort = lt_kkblo_sort
+ et_filter = lt_kkblo_filter
+ CHANGING
+ cs_layout = ls_kkblo_layout
+ ct_default_fieldcat = lt_kkblo_fieldcat
+ cs_variant = ls_vari
+ EXCEPTIONS
+ wrong_input = 1
+ fc_not_complete = 2
+ not_found = 3
+ OTHERS = 4
+ .
+ IF sy-subrc <> 0.
+* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
+* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
+ ENDIF.
+
+ CALL FUNCTION 'LVC_TRANSFER_FROM_KKBLO'
+ EXPORTING
+* I_TECH_COMPLETE =
+* I_STRUCTURE_NAME =
+ it_fieldcat_kkblo = lt_kkblo_fieldcat
+ it_sort_kkblo = lt_kkblo_sort
+ it_filter_kkblo = lt_kkblo_filter
+* IT_SPECIAL_GROUPS_KKBLO =
+* IT_FILTERED_ENTRIES_KKBLO =
+* IT_GROUPLEVELS_KKBLO =
+* IS_SUBTOT_OPTIONS_KKBLO =
+ is_layout_kkblo = ls_kkblo_layout
+* IS_REPREP_ID_KKBLO =
+* I_CALLBACK_PROGRAM_KKBLO =
+* IT_ADD_FIELDCAT =
+* IT_EXCLUDING_KKBLO =
+* IT_EXCEPT_QINFO_KKBLO =
+ IMPORTING
+ et_fieldcat_lvc = wt_fcat
+ et_sort_lvc = wt_sort
+ et_filter_lvc = wt_filt
+* ET_SPECIAL_GROUPS_LVC =
+* ET_FILTER_INDEX_LVC =
+* ET_GROUPLEVELS_LVC =
+* ES_TOTAL_OPTIONS_LVC =
+ es_layout_lvc = ws_layo
+* ES_VARIANT_LVC =
+* E_VARIANT_SAVE_LVC =
+* ES_PRINT_INFO_LVC =
+* ES_REPREP_LVC =
+* E_REPREP_ACTIVE_LVC =
+* ET_EXCLUDING_LVC =
+* ET_EXCEPT_QINFO_LVC =
+ TABLES
+ it_data = it_table
+ EXCEPTIONS
+ it_data_missing = 1
+ OTHERS = 2
+ .
+ IF sy-subrc <> 0.
+* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
+* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
+ ENDIF.
+
+ ELSE.
+* ... get the sort information
+ wt_sort = cl_salv_controller_metadata=>get_lvc_sort( lo_sorts ).
+
+* ... get the filter information
+ wt_filt = cl_salv_controller_metadata=>get_lvc_filter( lo_filters ).
ENDIF.
ENDMETHOD.
-
+
diff --git a/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_WD_RESULT.slnk b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_WD_RESULT.slnk
new file mode 100644
index 0000000..92aead8
--- /dev/null
+++ b/ZA2X/CLAS/ZCL_EXCEL_CONVERTER_WD_RESULT.slnk
@@ -0,0 +1,97 @@
+
+
+ class ZCL_EXCEL_CONVERTER_WD_RESULT definition
+ public
+ inheriting from ZCL_EXCEL_CONVERTER_ALV
+ final
+ create public .
+
+*"* public components of class ZCL_EXCEL_CONVERTER_WD_RESULT
+*"* do not include other source files here!!!
+public section.
+
+ methods ZIF_EXCEL_CONVERTER~CAN_CONVERT_OBJECT
+ redefinition .
+ methods ZIF_EXCEL_CONVERTER~CREATE_FIELDCATALOG
+ redefinition .
+ *"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE
+*"* do not include other source files here!!!
+protected section.
+ *"* private components of class ZCL_EXCEL_CONVERTER_EX_RESULT
+*"* 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 class
+
+
+
+
+
+ METHOD zif_excel_converter~can_convert_object.
+
+ DATA: lo_result TYPE REF TO cl_salv_wd_result_data_table.
+
+ TRY.
+ lo_result ?= io_object.
+ CATCH cx_sy_move_cast_error .
+ RAISE EXCEPTION TYPE zcx_excel.
+ ENDTRY.
+
+ENDMETHOD.
+
+
+ METHOD zif_excel_converter~create_fieldcatalog.
+ DATA: lo_result TYPE REF TO cl_salv_wd_result_data_table,
+ lo_bs_data TYPE REF TO cl_salv_bs_data_table,
+ lo_ex_cm TYPE REF TO cl_salv_ex_cm,
+ lo_data TYPE REF TO data.
+
+ FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
+
+ TRY.
+ zif_excel_converter~can_convert_object( io_object = io_object ).
+ ENDTRY.
+
+ lo_result ?= io_object.
+
+ CLEAR: es_layout,
+ et_fieldcatalog.
+
+ IF lo_result IS BOUND.
+ lo_bs_data ?= lo_result->r_model->r_data.
+ lo_data = lo_bs_data->get_ref_to_table( ) .
+ ASSIGN lo_data->* TO <fs_table> .
+
+* CL_SALV_WD_C_TABLE_V_TABLE " If we want to do it we need this
+* if_salv_wd_comp_table_events~on_export_excel( ).
+* lo_ex_cm ?= lo_result->r_model->r_model.
+* ws_layo = lo_ex_cm->s_layo.
+* T_DRDN Instance Attribute Public Type LVC_T_DROP
+* wt_fcat = lo_ex_cm->t_fcat.
+* wt_filt = lo_ex_cm->t_filt.
+* T_HYPE Instance Attribute Public Type LVC_T_HYPE
+* T_SELECTED_CELLS Instance Attribute Public Type LVC_T_CELL
+* T_SELECTED_COLUMNS Instance Attribute Public Type LVC_T_COL
+* wt_sort = lo_ex_cm->t_sort.
+
+ apply_sort( EXPORTING it_table = <fs_table>
+ IMPORTING eo_table = eo_table ) .
+
+ get_color( EXPORTING io_table = eo_table
+ IMPORTING et_colors = et_colors ) .
+
+ get_filter( EXPORTING io_table = eo_table
+ IMPORTING et_filter = et_filter ) .
+
+ update_catalog( CHANGING cs_layout = es_layout
+ ct_fieldcatalog = et_fieldcatalog ).
+ ENDIF.
+ENDMETHOD.
+
+
diff --git a/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk b/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk
index 8c44540..3402b21 100644
--- a/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk
+++ b/ZA2X/INTF/ZIF_EXCEL_CONVERTER.slnk
@@ -1,14 +1,17 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/ZA2X/TABL/ZEXCEL_S_CONVERTER_COL.slnk b/ZA2X/TABL/ZEXCEL_S_CONVERTER_COL.slnk
new file mode 100644
index 0000000..a25e511
--- /dev/null
+++ b/ZA2X/TABL/ZEXCEL_S_CONVERTER_COL.slnk
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/ZA2X/TABL/ZEXCEL_S_CONVERTER_FCAT.slnk b/ZA2X/TABL/ZEXCEL_S_CONVERTER_FCAT.slnk
index 532c6c3..a8c067c 100644
--- a/ZA2X/TABL/ZEXCEL_S_CONVERTER_FCAT.slnk
+++ b/ZA2X/TABL/ZEXCEL_S_CONVERTER_FCAT.slnk
@@ -1,19 +1,30 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZA2X/TABL/ZEXCEL_S_CONVERTER_FIL.slnk b/ZA2X/TABL/ZEXCEL_S_CONVERTER_FIL.slnk
new file mode 100644
index 0000000..077ffcb
--- /dev/null
+++ b/ZA2X/TABL/ZEXCEL_S_CONVERTER_FIL.slnk
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/ZA2X/TABL/ZEXCEL_S_CONVERTER_LAYO.slnk b/ZA2X/TABL/ZEXCEL_S_CONVERTER_LAYO.slnk
index 0c0ad98..62f05e1 100644
--- a/ZA2X/TABL/ZEXCEL_S_CONVERTER_LAYO.slnk
+++ b/ZA2X/TABL/ZEXCEL_S_CONVERTER_LAYO.slnk
@@ -1,6 +1,7 @@
-
+
-
-
+
+
+
diff --git a/ZA2X/TTYP/ZEXCEL_T_CONVERTER_COL.slnk b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_COL.slnk
new file mode 100644
index 0000000..7752997
--- /dev/null
+++ b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_COL.slnk
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FCAT.slnk b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FCAT.slnk
index bec7d8f..812e864 100644
--- a/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FCAT.slnk
+++ b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FCAT.slnk
@@ -1,2 +1,2 @@
-
+
diff --git a/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FIL.slnk b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FIL.slnk
new file mode 100644
index 0000000..5eaac82
--- /dev/null
+++ b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_FIL.slnk
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/ZA2X/TTYP/ZEXCEL_T_CONVERTER_LAYO.slnk b/ZA2X/TTYP/ZEXCEL_T_CONVERTER_LAYO.slnk
deleted file mode 100644
index d4afd2b..0000000
--- a/ZA2X/TTYP/ZEXCEL_T_CONVERTER_LAYO.slnk
+++ /dev/null
@@ -1,2 +0,0 @@
-
-