diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk index 9e12f7d..2d4e23f 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -1,15 +1,15 @@ - - - + + + class ZCL_EXCEL_WORKSHEET definition public final create public . +public section. *"* public components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! -public section. type-pools ABAP . interfaces ZIF_EXCEL_SHEET_PROPERTIES . @@ -189,7 +189,8 @@ public section. importing !IP_COLUMN_START type ZEXCEL_CELL_COLUMN_ALPHA optional !IP_COLUMN_END type ZEXCEL_CELL_COLUMN_ALPHA optional - !IP_ROW type ZEXCEL_CELL_ROW optional . + !IP_ROW type ZEXCEL_CELL_ROW optional + !IP_ROW_TO type ZEXCEL_CELL_ROW optional . methods SET_TABLE importing !IP_TABLE type STANDARD TABLE @@ -388,43 +389,45 @@ class lcl_gui_alv_grid definition inheriting from cl_gui_alv_grid. endclass. *"* use this source file for any macro definitions you need *"* in the implementation part of the class + + ABAP SLIS SOI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method ZIF_EXCEL_SHEET_PROPERTIES~GET_STYLE. ep_style = zif_excel_sheet_properties~style. @@ -465,48 +468,51 @@ endmethod. endmethod. - - + + method ADD_DRAWING. drawings->add( ip_drawing ). endmethod. + - - + + method ADD_NEW_CONDITIONAL_STYLE. CREATE OBJECT eo_conditional_style. conditional_styles->add( eo_conditional_style ). endmethod. + - - + + method ADD_NEW_DATA_VALIDATION. CREATE OBJECT eo_data_validation. data_validations->add( eo_data_validation ). endmethod. + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + method BIND_ALV. *--------------------------------------------------------------------* * Method description: @@ -2575,12 +2581,13 @@ endmethod. close_document. endmethod. + - - - - - + + + + + method BIND_TABLE. DATA: @@ -2722,8 +2729,9 @@ endmethod. endmethod. + - + method CALCULATE_COLUMN_WIDTHS. TYPES: BEGIN OF t_auto_size, @@ -2784,10 +2792,11 @@ endmethod. ENDIF. endmethod. + - - - + + + method CONSTRUCTOR. DATA: lv_title TYPE zexcel_sheet_title. @@ -2826,19 +2835,21 @@ endmethod. upper_cell-cell_row = 1. upper_cell-cell_column = 1. endmethod. + - + method DELETE_MERGE. DELETE sheet_content_merge INDEX 1. DELETE sheet_content_merge INDEX 1. endmethod. + - - - - + + + + method FREEZE_PANES. data: lv_xsplit type i, lv_ysplit type i. @@ -2864,9 +2875,10 @@ endmethod. freeze_pane_cell_column = ip_num_columns + 1. freeze_pane_cell_row = ip_num_rows + 1. endmethod. + - - + + method GET_ACTIVE_CELL. DATA: lv_active_column TYPE zexcel_cell_column_alpha, @@ -2879,12 +2891,13 @@ endmethod. CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. endmethod. + - - - - - + + + + + method GET_CELL. DATA: lv_column TYPE zexcel_cell_column, @@ -2900,10 +2913,11 @@ endmethod. ep_rc = sy-subrc. ep_value = ls_sheet_content-cell_value. endmethod. + - - - + + + method GET_COLUMN_DIMENSION. FIELD-SYMBOLS: <fs_column_dimension> LIKE LINE OF column_dimensions. @@ -2922,41 +2936,47 @@ endmethod. ENDIF. endmethod. + - - + + method GET_COLUMN_DIMENSIONS. r_column_dimension[] = me->column_dimensions[]. endmethod. + - - + + method GET_COND_STYLES_ITERATOR. eo_iterator = me->conditional_styles->get_iterator( ). endmethod. + - - + + method GET_DATA_VALIDATIONS_ITERATOR. eo_iterator = me->data_validations->get_iterator( ). endmethod. + - - + + method GET_DATA_VALIDATIONS_SIZE. ep_size = me->data_validations->size( ). endmethod. + - - + + method GET_DEFAULT_COLUMN_DIMENSION. r_column_dimension = me->default_column_dimension. endmethod. + - - + + method GET_DEFAULT_EXCEL_DATE_FORMAT. CONSTANTS: c_lang_e TYPE lang VALUE 'E'. @@ -2980,15 +3000,17 @@ endmethod. ep_default_excel_date_format = default_excel_date_format. endmethod. + - - + + method GET_DEFAULT_ROW_DIMENSION. r_row_dimension = me->default_row_dimension. endmethod. + - - + + method GET_DIMENSION_RANGE. me->update_dimension_range( ). @@ -3004,63 +3026,72 @@ endmethod. ENDIF. endmethod. + - - + + method GET_DRAWINGS. r_drawings = drawings. endmethod. + - - + + method GET_DRAWINGS_ITERATOR. eo_iterator = drawings->get_iterator( ). endmethod. + - - - + + + method GET_FREEZE_CELL. ep_row = me->freeze_pane_cell_row. ep_column = me->freeze_pane_cell_column. endmethod. + - - + + method GET_GUID. ep_guid = me->guid. endmethod. + - - + + method GET_HIGHEST_COLUMN. me->update_dimension_range( ). r_highest_column = me->lower_cell-cell_column. endmethod. + - - + + method GET_HIGHEST_ROW. me->update_dimension_range( ). r_highest_row = me->lower_cell-cell_row. endmethod. + - - + + method GET_HYPERLINKS_ITERATOR. eo_iterator = hyperlinks->get_iterator( ). endmethod. + - - + + method GET_HYPERLINKS_SIZE. ep_size = hyperlinks->size( ). endmethod. + - - + + method GET_MERGE. DATA: lv_column_start TYPE string, @@ -3093,8 +3124,11 @@ endmethod. lv_index = lv_index + 1. READ TABLE sheet_content_merge ASSIGNING <fs_sheet_content> INDEX lv_index. lv_column_end = zcl_excel_common=>convert_column2alpha( <fs_sheet_content>-cell_column ). + lv_row = <fs_sheet_content>-cell_row. SHIFT lv_column_end RIGHT DELETING TRAILING space. SHIFT lv_column_end LEFT DELETING LEADING space. + SHIFT lv_row RIGHT DELETING TRAILING space. + SHIFT lv_row LEFT DELETING LEADING space. CONCATENATE lv_column_end lv_row INTO range_to. @@ -3130,10 +3164,11 @@ endmethod. * ENDIF. endmethod. + - - - + + + method GET_ROW_DIMENSION. FIELD-SYMBOLS: <fs_row_dimension> LIKE LINE OF row_dimensions. @@ -3152,28 +3187,32 @@ endmethod. ENDIF. endmethod. + - - + + method GET_ROW_DIMENSIONS. r_row_dimension[] = me->row_dimensions[]. endmethod. + - - + + method GET_TABLES_ITERATOR. eo_iterator = tables->if_object_collection~get_iterator( ). endmethod. + - - + + method GET_TABLES_SIZE. ep_size = tables->if_object_collection~size( ). endmethod. + - - - + + + method GET_TITLE. DATA lv_value TYPE string. IF ip_escaped EQ abap_true. @@ -3183,14 +3222,15 @@ endmethod. ep_title = me->title. ENDIF. endmethod. + - - - - - - - + + + + + + + method SET_CELL. DATA: lv_column TYPE zexcel_cell_column, @@ -3283,12 +3323,13 @@ endmethod. ENDIF. endmethod. + - - - - - + + + + + method SET_CELL_STYLE. DATA: lv_column TYPE zexcel_cell_column, @@ -3313,9 +3354,10 @@ endmethod. ENDIF. endmethod. + - - + + method SET_DEFAULT_EXCEL_DATE_FORMAT. IF ip_default_excel_date_format IS INITIAL. @@ -3326,12 +3368,14 @@ endmethod. default_excel_date_format = ip_default_excel_date_format. endmethod. + - - - - - method SET_MERGE. + + + + + + METHOD set_merge. DATA: lv_column_start TYPE zexcel_cell_column, lv_column_end TYPE zexcel_cell_column, @@ -3351,35 +3395,44 @@ endmethod. CONCATENATE ip_column_start lv_row_alpha INTO ls_sheet_content-cell_coords. INSERT ls_sheet_content INTO TABLE sheet_content_merge. - ls_sheet_content-cell_row = ip_row. ls_sheet_content-cell_column = lv_column_end. - lv_row_alpha = ip_row. + IF ip_row_to IS SUPPLIED. + ls_sheet_content-cell_row = ip_row_to. + lv_row_alpha = ip_row_to. + ELSE. + lv_row_alpha = ip_row. + ls_sheet_content-cell_row = ip_row. + ENDIF. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. SHIFT lv_row_alpha LEFT DELETING LEADING space. CONCATENATE ip_column_end lv_row_alpha INTO ls_sheet_content-cell_coords. - INSERT ls_sheet_content INTO TABLE sheet_content_merge. + INSERT ls_sheet_content INTO TABLE sheet_content_merge. -endmethod. +ENDMETHOD. + - - + + method SET_PRINT_GRIDLINES. me->print_gridlines = i_print_gridlines. endmethod. + - - + + method SET_SHOW_GRIDLINES. me->show_gridlines = i_show_gridlines. endmethod. + - - - - - - - + + + + + + + method SET_TABLE. DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, @@ -3435,14 +3488,16 @@ endmethod. ENDLOOP. endmethod. + - - + + method SET_TITLE. me->title = ip_title. endmethod. + - + method UPDATE_DIMENSION_RANGE. DATA: ls_sheet_content TYPE zexcel_s_cell_data, @@ -3481,5 +3536,6 @@ endmethod. CONCATENATE lv_column_alpha lv_row_alpha INTO lower_cell-cell_coords. endmethod. + diff --git a/ZA2X/PROG/ZDEMO_EXCEL13.slnk b/ZA2X/PROG/ZDEMO_EXCEL13.slnk index 7457f85..cf5a131 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL13.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL13.slnk @@ -1,5 +1,5 @@ - + @@ -93,7 +93,11 @@ START-OF-SELECTION. " Test also if merge works when oher merged chells are empty lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 'Tomato' ). - lo_worksheet->set_merge( ip_row = 2 ip_column_start = 'B' ip_column_end = 'G' ). + lo_worksheet->set_merge( ip_row = 6 ip_column_start = 'B' ip_column_end = 'G' ). + + " Test the patch provided by Victor Alekhin to merge cells in one column + lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = 'Merge cells also over multiple rows by Victor Alekhin' ). + lo_worksheet->set_merge( ip_row = 8 ip_column_start = 'B' ip_column_end = 'G' ip_row_to = 10 ). CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. lv_file = lo_excel_writer->write_file( lo_excel ).