diff --git a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk index 3783eda..661dcf2 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk @@ -1,13 +1,13 @@ - - + + class ZCL_EXCEL_COMMON definition public final create public . -public section. *"* public components of class ZCL_EXCEL_COMMON *"* do not include other source files here!!! +public section. constants C_EXCEL_BASELINE_DATE type D value '19000101'. "#EC NOTEXT class-data C_EXCEL_NUMFMT_OFFSET type INT1 value 164. "#EC NOTEXT . @@ -23,9 +23,11 @@ public section. value(EP_COLUMN) type ZEXCEL_CELL_COLUMN_ALPHA . class-methods CONVERT_COLUMN2INT importing - !IP_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA + !IP_COLUMN type SIMPLE returning - value(EP_COLUMN) type ZEXCEL_CELL_COLUMN . + value(EP_COLUMN) type ZEXCEL_CELL_COLUMN + raising + ZCX_EXCEL . class-methods CONVERT_COLUMNROW2COLUMN_A_ROW importing !I_COLUMNROW type STRING @@ -125,16 +127,16 @@ protected 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 CHAR2HEX. IF o_conv IS NOT BOUND. @@ -149,9 +151,9 @@ protected section. endmethod. - - - + + + method CONVERT_COLUMN2ALPHA. DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce, @@ -173,45 +175,88 @@ endmethod. endmethod. - - - - method CONVERT_COLUMN2INT. + + + + + METHOD convert_column2int. DATA: lv_uccpi TYPE i, lv_factor TYPE i, lv_offset TYPE i, lv_char TYPE c, - lv_column TYPE ZEXCEL_CELL_COLUMN_ALPHA. + lv_column TYPE zexcel_cell_column_alpha, + mod TYPE i. +* If a number gets passed, just convert it to an integer, +* Otherwise try to interpret it as if ZEXCEL_CELL_COLUMN_ALPHA was passed +* if both fails raise exception + +* First try - convert to number + TRY. + ep_column = ip_column. + IF ep_column > 0. + EXIT. + ENDIF. + CATCH cx_sy_conversion_no_number. + " Too bad - try the character-approach + ENDTRY. * Upper case lv_column = ip_column. + TRANSLATE lv_column TO UPPER CASE. CONDENSE lv_column NO-GAPS. -* Get string lenght and align to right - lv_offset = 3 - STRLEN( lv_column ). +** Get string lenght and align to right +* lv_offset = 3 - STRLEN( lv_column ). +* +* SHIFT lv_column RIGHT BY lv_offset PLACES. +* +** Calculate column position +* DO 3 TIMES. +* lv_offset = sy-index - 1. +* lv_char = lv_column+lv_offset(1). +* if lv_char IS INITIAL. +* CONTINUE. +* ENDIF. +* lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). +* lv_factor = 26 ** ( 3 - sy-index ). +* ep_column = ep_column + ( lv_uccpi MOD zcl_excel_common=>c_excel_col_module ) * lv_factor. +* ENDDO. - SHIFT lv_column RIGHT BY lv_offset PLACES. +* Raise error if unexpected character turns up + mod = cl_abap_conv_out_ce=>uccpi( lv_column+0(1) ) MOD zcl_excel_common=>c_excel_col_module. + IF mod < 1 OR mod > 26. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Unable to interpret column'. + ENDIF. + ep_column = mod. -* Claculate column position - DO 3 TIMES. - lv_offset = sy-index - 1. - lv_char = lv_column+lv_offset(1). - if lv_char IS INITIAL. - CONTINUE. - ENDIF. - lv_uccpi = cl_abap_conv_out_ce=>uccpi( lv_char ). - lv_factor = 26 ** ( 3 - sy-index ). - ep_column = ep_column + ( lv_uccpi MOD zcl_excel_common=>c_excel_col_module ) * lv_factor. - ENDDO. + CHECK lv_column+1(1) IS NOT INITIAL. " No need to continue if string ended + mod = cl_abap_conv_out_ce=>uccpi( lv_column+1(1) ) MOD zcl_excel_common=>c_excel_col_module. + IF mod < 1 OR mod > 26. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Unable to interpret column'. + ENDIF. + ep_column = 26 * ep_column + mod. -endmethod. + CHECK lv_column+2(1) IS NOT INITIAL. " No need to continue if string ended + mod = cl_abap_conv_out_ce=>uccpi( lv_column+2(1) ) MOD zcl_excel_common=>c_excel_col_module. + IF mod < 1 OR mod > 26. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Unable to interpret column'. + ENDIF. + ep_column = 26 * ep_column + mod. + +ENDMETHOD. - - - - + + + + method CONVERT_COLUMNROW2COLUMN_A_ROW. DATA: width TYPE i, col_width TYPE i, @@ -230,14 +275,14 @@ endmethod. e_row = row_str. endmethod. - - - - - - - - METHOD convert_range2column_a_row. + + + + + + + + method CONVERT_RANGE2COLUMN_A_ROW. DATA: sheet TYPE string, range TYPE string, @@ -273,11 +318,11 @@ endmethod. e_column = e_column_end e_row = e_row_end ). -ENDMETHOD. +endmethod. - - - + + + method DATE_TO_EXCEL_STRING. DATA: lv_date_diff TYPE i. @@ -286,9 +331,9 @@ ENDMETHOD. ep_value = zcl_excel_common=>number_to_excel_string( ip_value = lv_date_diff ). endmethod. - - - + + + method ENCRYPT_PASSWORD. DATA lv_curr_offset TYPE i. @@ -328,9 +373,9 @@ endmethod. endmethod. - - - + + + method ESCAPE_STRING. DATA lv_value TYPE string. @@ -346,9 +391,9 @@ endmethod. endmethod. - - - + + + method EXCEL_STRING_TO_DATE. DATA: lv_date_int TYPE i. @@ -360,9 +405,9 @@ endmethod. ENDTRY. endmethod. - - - + + + method EXCEL_STRING_TO_TIME. DATA: lv_seconds_in_day TYPE i, lv_day_fraction TYPE f, @@ -380,9 +425,9 @@ lc_seconds_in_day TYPE i VALUE 86400. ENDTRY. endmethod. - - - + + + method GET_FIELDCATALOG. DATA: lr_data TYPE REF TO data, @@ -433,9 +478,9 @@ endmethod. endmethod. - - - + + + method NUMBER_TO_EXCEL_STRING. DATA: lv_value_c TYPE c LENGTH 100. @@ -452,11 +497,11 @@ endmethod. ENDIF. endmethod. - - - - - METHOD recursive_class_to_struct. + + + + + method RECURSIVE_CLASS_TO_STRUCT. " # issue 139 * is working for me - but after looking through this coding I guess * I'll rewrite this to a version w/o recursion @@ -509,13 +554,13 @@ endmethod. ENDCASE. ENDLOOP. -ENDMETHOD. +endmethod. - - - - - METHOD recursive_struct_to_class. + + + + + method RECURSIVE_STRUCT_TO_CLASS. " # issue 139 * is working for me - but after looking through this coding I guess * I'll rewrite this to a version w/o recursion @@ -569,11 +614,11 @@ ENDMETHOD. ENDCASE. ENDLOOP. -ENDMETHOD. +endmethod. - - - + + + method SHL01. DATA: @@ -591,9 +636,9 @@ ENDMETHOD. endmethod. - - - + + + method SHR14. DATA: @@ -618,9 +663,9 @@ endmethod. endmethod. - - - + + + method TIME_TO_EXCEL_STRING. DATA: lv_seconds_in_day TYPE i, lv_day_fraction TYPE f, diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk index 67abf9d..8ece7b0 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_COLUMNDIME.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_WORKSHEET_COLUMNDIME definition public final @@ -59,9 +59,11 @@ public section. value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . methods SET_WIDTH importing - !IP_WIDTH type FLOAT + !IP_WIDTH type SIMPLE returning - value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . + value(R_WORKSHEET_COLUMNDIME) type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME + raising + ZCX_EXCEL . methods SET_XF_INDEX importing !IP_XF_INDEX type INT4 @@ -92,15 +94,15 @@ private section. *"* in the implementation part of the class ABAP - - - - - - - - - + + + + + + + + + method CONSTRUCTOR. me->column_index = zcl_excel_common=>convert_column2int( ip_index ). me->width = -1. @@ -113,97 +115,104 @@ private section. me->xf_index = 0. endmethod. - - + + method GET_AUTO_SIZE. r_auto_size = me->auto_size. endmethod. - - + + method GET_COLLAPSED. r_Collapsed = me->Collapsed. endmethod. - - + + method GET_COLUMN_INDEX. r_column_index = me->column_index. endmethod. - - + + method GET_OUTLINE_LEVEL. r_outline_level = me->outline_level. endmethod. - - + + method GET_VISIBLE. r_Visible = me->Visible. endmethod. - - + + method GET_WIDTH. r_WIDTH = me->WIDTH. endmethod. - - + + method GET_XF_INDEX. r_xf_index = me->xf_index. endmethod. - - - + + + method SET_AUTO_SIZE. me->auto_size = ip_auto_size. r_worksheet_columndime = me. endmethod. - - - + + + method SET_COLLAPSED. me->Collapsed = ip_Collapsed. r_worksheet_columndime = me. endmethod. - - - + + + method SET_COLUMN_INDEX. me->column_index = zcl_excel_common=>convert_column2int( ip_index ). r_worksheet_columndime = me. endmethod. - - + + method SET_OUTLINE_LEVEL. me->outline_level = ip_outline_level. endmethod. - - - + + + method SET_VISIBLE. me->Visible = ip_Visible. r_worksheet_columndime = me. endmethod. - - - - method SET_WIDTH. - me->width = ip_width. - r_worksheet_columndime = me. -endmethod. + + + + + METHOD set_width. + TRY. + me->width = ip_width. + r_worksheet_columndime = me. + CATCH cx_sy_conversion_no_number. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Unable to interpret ip_row_height as number'. + ENDTRY. +ENDMETHOD. - - - + + + method SET_XF_INDEX. me->XF_INDEX = ip_XF_INDEX. r_worksheet_columndime = me. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk index b53547c..0a79258 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET_ROWDIMENSI.slnk @@ -1,5 +1,5 @@ - - + + class ZCL_EXCEL_WORKSHEET_ROWDIMENSI definition public final @@ -16,12 +16,12 @@ public section. methods GET_OUTLINE_LEVEL returning value(R_OUTLINE_LEVEL) type INT4 . - methods GET_ROW_INDEX - returning - value(R_ROW_INDEX) type INT4 . methods GET_XF_INDEX returning value(R_XF_INDEX) type INT4 . + methods GET_ROW_INDEX + returning + value(R_ROW_INDEX) type INT4 . methods SET_OUTLINE_LEVEL importing !IP_OUTLINE_LEVEL type INT4 @@ -38,7 +38,9 @@ public section. value(R_ROW_HEIGHT) type FLOAT . methods SET_ROW_HEIGHT importing - !IP_ROW_HEIGHT type FLOAT . + !IP_ROW_HEIGHT type SIMPLE + raising + ZCX_EXCEL . methods GET_COLLAPSED returning value(R_COLLAPSED) type BOOLEAN . @@ -72,18 +74,17 @@ 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 - ABAP - - - - - - - - - METHOD constructor. + + + + + + + + + method CONSTRUCTOR. " Initialise values me->row_index = ip_index. me->row_height = -1. @@ -93,54 +94,54 @@ private section. " set row dimension as unformatted by default me->xf_index = 0. -ENDMETHOD. +endmethod. - - - METHOD get_collapsed. + + + method GET_COLLAPSED. r_collapsed = me->collapsed. -ENDMETHOD. +endmethod. - - - METHOD get_outline_level. + + + method GET_OUTLINE_LEVEL. r_outline_level = me->outline_level. -ENDMETHOD. +endmethod. - - - METHOD get_row_height. + + + method GET_ROW_HEIGHT. r_row_height = me->row_height. -ENDMETHOD. +endmethod. - - - METHOD get_row_index. + + + method GET_ROW_INDEX. r_row_index = me->row_index. -ENDMETHOD. +endmethod. - - - METHOD get_visible. + + + method GET_VISIBLE. r_visible = me->visible. -ENDMETHOD. +endmethod. - - - METHOD get_xf_index. + + + method GET_XF_INDEX. r_xf_index = me->xf_index. -ENDMETHOD. +endmethod. - - - METHOD set_collapsed. + + + method SET_COLLAPSED. me->collapsed = ip_collapsed. -ENDMETHOD. +endmethod. - - - - METHOD set_outline_level. + + + + method SET_OUTLINE_LEVEL. IF ip_outline_level < 0 OR ip_outline_level > 7. @@ -150,30 +151,37 @@ ENDMETHOD. ENDIF. me->outline_level = ip_outline_level. -ENDMETHOD. +endmethod. - - + + + METHOD set_row_height. - me->row_height = ip_row_height. + TRY. + me->row_height = ip_row_height. + CATCH cx_sy_conversion_no_number. + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + error = 'Unable to interpret ip_row_height as number'. + ENDTRY. ENDMETHOD. - - - METHOD set_row_index. + + + method SET_ROW_INDEX. me->row_index = ip_index. -ENDMETHOD. +endmethod. - - - METHOD set_visible. + + + method SET_VISIBLE. me->visible = ip_visible. -ENDMETHOD. +endmethod. - - - METHOD SET_XF_INDEX. + + + method SET_XF_INDEX. me->XF_INDEX = ip_XF_INDEX. -ENDMETHOD. +endmethod.