From 8c45483af818098c7fd3813466f7e5ca4c593de4 Mon Sep 17 00:00:00 2001 From: Alessandro Iannacci Date: Thu, 29 Nov 2012 09:00:09 +0000 Subject: [PATCH] git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@370 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk | 109 +++++++++++++++++------------ 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk index 579d9ba..a4519d0 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -20,15 +20,11 @@ public section. constants C_BREAK_COLUMN type ZEXCEL_BREAK value 2. "#EC NOTEXT constants C_BREAK_NONE type ZEXCEL_BREAK value 0. "#EC NOTEXT constants C_BREAK_ROW type ZEXCEL_BREAK value 1. "#EC NOTEXT - constants C_SHEET_STATE_HIDDEN type ZEXCEL_SHEET_STATE value 'hidden'. "#EC NOTEXT - constants C_SHEET_STATE_VERYHIDDEN type ZEXCEL_SHEET_STATE value 'veryHidden'. "#EC NOTEXT - constants C_SHEET_STATE_VISIBLE type ZEXCEL_SHEET_STATE value 'visible'. "#EC NOTEXT data EXCEL type ref to ZCL_EXCEL read-only . data PRINT_GRIDLINES type ZEXCEL_PRINT_GRIDLINES read-only value ABAP_FALSE. "#EC NOTEXT . data SHEET_CONTENT type ZEXCEL_T_CELL_DATA . data SHEET_CONTENT_MERGE type ZEXCEL_T_CELL_DATA_UNSORTED . data SHEET_SETUP type ref to ZCL_EXCEL_SHEET_SETUP . - data SHEET_STATE type ZEXCEL_SHEET_STATE . data SHOW_GRIDLINES type ZEXCEL_SHOW_GRIDLINES read-only value ABAP_TRUE. "#EC NOTEXT . data SHOW_ROWCOLHEADERS type ZEXCEL_SHOW_GRIDLINES read-only value ABAP_TRUE. "#EC NOTEXT . data STYLES type ZEXCEL_T_SHEET_STYLE . @@ -617,35 +613,31 @@ endclass. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + method ZIF_EXCEL_SHEET_PROPERTIES~GET_STYLE. IF zif_excel_sheet_properties~style IS NOT INITIAL. @@ -2869,7 +2861,7 @@ endmethod. - method BIND_TABLE. + METHOD bind_table. DATA: lv_row_int TYPE zexcel_cell_row, @@ -2887,6 +2879,13 @@ endmethod. lv_value TYPE string, lv_syindex TYPE char3. + DATA lv_columns TYPE i. + DATA lt_columns TYPE zexcel_t_fieldcatalog. + DATA lv_maxcol TYPE i. + DATA lv_maxrow TYPE i. + DATA lo_iterator TYPE REF TO cl_object_collection_iterator. + DATA lo_curtable TYPE REF TO zcl_excel_table. + CONSTANTS: lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'B', lc_top_left_row TYPE zexcel_cell_row VALUE '3'. @@ -2918,6 +2917,38 @@ endmethod. SORT lt_field_catalog BY position. + "Get the number of columns for the current table + lt_columns = lt_field_catalog. + DELETE lt_columns WHERE dynpfld NE abap_true. + DESCRIBE TABLE lt_columns LINES lv_columns. + + "Calculate the top left row of the current table + lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ). + lv_row_int = ls_settings-top_left_row. + + "Get number of row for the current table + DESCRIBE TABLE ip_table LINES lv_rows. + + "Calculate the bottom right row for the current table + lv_maxcol = lv_column_int + lv_columns - 1. + lv_maxrow = lv_row_int + lv_rows - 1. + ls_settings-bottom_right_column = zcl_excel_common=>convert_column2alpha( lv_maxcol ). + ls_settings-bottom_right_row = lv_maxrow. + + "Check if overlapping areas exist + lo_iterator = me->tables->if_object_collection~get_iterator( ). + WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true. + lo_curtable ?= lo_iterator->if_object_collection_iterator~get_next( ). + IF ls_settings-top_left_row GE lo_curtable->settings-top_left_row AND ls_settings-top_left_row LE lo_curtable->settings-bottom_right_row + OR ls_settings-bottom_right_row GE lo_curtable->settings-top_left_row AND ls_settings-bottom_right_row LE lo_curtable->settings-bottom_right_row. + ELSEIF lv_column_int GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_column_int LE lo_curtable->settings-bottom_right_column + OR lv_maxcol GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_maxcol LE lo_curtable->settings-bottom_right_column. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'It is not possible to bind two tables to an excelsheet with overlapping areas.'. + ENDIF. + ENDWHILE. + CREATE OBJECT lo_table. lo_table->settings = ls_settings. lo_table->set_data( ir_data = ip_table ). @@ -2927,12 +2958,6 @@ endmethod. me->tables->add( lo_table ). - lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ). - lv_row_int = ls_settings-top_left_row. - - " get the row number - DESCRIBE TABLE ip_table LINES lv_rows. - * It is better to loop column by column (only visible column) LOOP AT lt_field_catalog ASSIGNING <ls_field_catalog> WHERE dynpfld EQ abap_true. @@ -3036,7 +3061,7 @@ endmethod. es_table_settings-bottom_right_row = ls_settings-top_left_row + lv_rows + 1. "Last rows -endmethod. +ENDMETHOD. @@ -3567,8 +3592,6 @@ endmethod. me->set_title( ip_title = lv_title ). - sheet_state = me->c_sheet_state_visible. - CREATE OBJECT sheet_setup. CREATE OBJECT conditional_styles. CREATE OBJECT data_validations.