From 5ee365d8316efbd7d628ecf6d6f40a1ffe436a85 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Mon, 5 Aug 2024 19:06:55 +0200 Subject: [PATCH 1/5] update npm dependencies (#1207) --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f5817ab..935f0ad 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "url": "git+https://github.com/abap2xlsx/abap2xlsx.git" }, "devDependencies": { - "@abaplint/cli": "^2.105.14", - "@abaplint/transpiler-cli": "^2.7.153", - "@abaplint/runtime": "^2.7.153" + "@abaplint/cli": "^2.112.10", + "@abaplint/transpiler-cli": "^2.10.7", + "@abaplint/runtime": "^2.10.7" } } From 0f19081a043341b8e773a9bd3dfd358a12cbdc5e Mon Sep 17 00:00:00 2001 From: sandraros <34005250+sandraros@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:12:23 +0200 Subject: [PATCH 2/5] Code to handle the UTCLONG type added in ABAP 7.54 (#1253) Fix #1252 --- abap_transpile.json | 1 + package.json | 4 +-- src/zcl_excel_common.clas.abap | 20 +++++++++++ src/zcl_excel_common.clas.testclasses.abap | 41 ++++++++++++++++++++++ src/zcl_excel_worksheet.clas.abap | 36 +++++++++++++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) diff --git a/abap_transpile.json b/abap_transpile.json index 3bc587c..db1ca88 100644 --- a/abap_transpile.json +++ b/abap_transpile.json @@ -54,6 +54,7 @@ {"object": "ZCL_EXCEL_WRITER_2007", "class": "ltc_column_formula", "method": "one_column_formula", "note": "?? CALL TRANSFORMATION xml_header = 'no'"}, {"object": "ZCL_EXCEL_WRITER_2007", "class": "ltc_column_formula", "method": "two_column_formulas", "note": "??"}, + {"object": "ZCL_EXCEL_COMMON", "class": "ltc_utclong_to_excel_string", "method": "simple", "note": "?? missing method CL_ABAP_TSTMP=>UTCLONG2TSTMP_SHORT, I'm too lazy to add it today"}, {"object": "ZCL_EXCEL_COMMON", "class": "lcl_excel_common_test", "method": "convert_column2int_oob_empty", "note": "?? sy value defaults"} ] } diff --git a/package.json b/package.json index 935f0ad..d96f562 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@abaplint/cli": "^2.112.10", - "@abaplint/transpiler-cli": "^2.10.7", - "@abaplint/runtime": "^2.10.7" + "@abaplint/transpiler-cli": "^2.10.9", + "@abaplint/runtime": "^2.10.9" } } diff --git a/src/zcl_excel_common.clas.abap b/src/zcl_excel_common.clas.abap index 67a9e6c..917486b 100644 --- a/src/zcl_excel_common.clas.abap +++ b/src/zcl_excel_common.clas.abap @@ -166,6 +166,11 @@ CLASS zcl_excel_common DEFINITION !ip_value TYPE t RETURNING VALUE(ep_value) TYPE zexcel_cell_value . + CLASS-METHODS utclong_to_excel_string + IMPORTING + !ip_utclong TYPE any + RETURNING + VALUE(ep_value) TYPE zexcel_cell_value . TYPES: t_char10 TYPE c LENGTH 10. TYPES: t_char255 TYPE c LENGTH 255. CLASS-METHODS split_file @@ -1725,4 +1730,19 @@ CLASS zcl_excel_common IMPLEMENTATION. ENDMETHOD. + METHOD utclong_to_excel_string. + DATA lv_timestamp TYPE timestamp. + DATA lv_date TYPE d. + DATA lv_time TYPE t. + + " The data type UTCLONG and the method UTCLONG2TSTMP_SHORT are not available before ABAP 7.54 + " -> Need of a dynamic call to avoid compilation error before ABAP 7.54 + + CALL METHOD cl_abap_tstmp=>('UTCLONG2TSTMP_SHORT') + EXPORTING utclong = ip_utclong + RECEIVING timestamp = lv_timestamp. + CONVERT TIME STAMP lv_timestamp TIME ZONE 'UTC ' INTO DATE lv_date TIME lv_time. + ep_value = |{ date_to_excel_string( lv_date ) + time_to_excel_string( lv_time ) }|. + ENDMETHOD. + ENDCLASS. diff --git a/src/zcl_excel_common.clas.testclasses.abap b/src/zcl_excel_common.clas.testclasses.abap index bf5f471..a6e2970 100644 --- a/src/zcl_excel_common.clas.testclasses.abap +++ b/src/zcl_excel_common.clas.testclasses.abap @@ -136,6 +136,17 @@ CLASS lcl_excel_common_test DEFINITION FOR TESTING ENDCLASS. +CLASS ltc_utclong_to_excel_string DEFINITION + FOR TESTING + RISK LEVEL HARMLESS + DURATION SHORT. + + PRIVATE SECTION. + + METHODS simple FOR TESTING. + +ENDCLASS. + *----------------------------------------------------------------------* * CLASS lcl_Excel_Common_Test IMPLEMENTATION @@ -1812,3 +1823,33 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ENDMETHOD. ENDCLASS. + + +CLASS ltc_utclong_to_excel_string IMPLEMENTATION. + METHOD simple. + FIELD-SYMBOLS TYPE abap_typekind. + FIELD-SYMBOLS TYPE simple. + DATA lo_rtti_utclong TYPE REF TO cl_abap_datadescr. + DATA lv_variable_utclong TYPE REF TO data. + DATA lv_excel_string TYPE zexcel_cell_value. + + " Skip this test before ABAP 7.54 (UTCLONG does not exist). + " Need of dynamic referencing and dynamic call to avoid compilation error before ABAP 7.54. + + ASSIGN ('CL_ABAP_TYPEDESCR=>TYPEKIND_UTCLONG') TO . + IF sy-subrc <> 0. + RETURN. + ENDIF. + + CALL METHOD cl_abap_elemdescr=>('GET_UTCLONG') + RECEIVING p_result = lo_rtti_utclong. + CREATE DATA lv_variable_utclong TYPE HANDLE lo_rtti_utclong. + ASSIGN lv_variable_utclong->* TO . + + = '2024-08-04 19:47:00.9999999'. + lv_excel_string = zcl_excel_common=>utclong_to_excel_string( ). + + cl_abap_unit_assert=>assert_equals( exp = '45508.82430555555556' + act = lv_excel_string ). + ENDMETHOD. +ENDCLASS. diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index ec2e692..169e293 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -708,6 +708,10 @@ CLASS zcl_excel_worksheet DEFINITION *"* private components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! TYPES ty_table_settings TYPE STANDARD TABLE OF zexcel_s_table_settings WITH DEFAULT KEY. + + CLASS-DATA typekind_utclong TYPE abap_typekind. + CLASS-DATA variable_utclong TYPE REF TO data. + DATA active_cell TYPE zexcel_s_cell_data . DATA charts TYPE REF TO zcl_excel_drawings . DATA columns TYPE REF TO zcl_excel_columns . @@ -2023,12 +2027,21 @@ CLASS zcl_excel_worksheet IMPLEMENTATION. METHOD class_constructor. + FIELD-SYMBOLS TYPE abap_typekind. + DATA lo_rtti TYPE REF TO cl_abap_datadescr. c_messages-formula_id_only_is_possible = |{ 'If Formula ID is used, value and formula must be empty'(008) }|. c_messages-column_formula_id_not_found = |{ 'The Column Formula does not exist'(009) }|. c_messages-formula_not_in_this_table = |{ 'The cell uses a Column Formula which should be part of the same table'(010) }|. c_messages-formula_in_other_column = |{ 'The cell uses a Column Formula which is in a different column'(011) }|. + ASSIGN ('CL_ABAP_TYPEDESCR=>TYPEKIND_UTCLONG') TO . + IF sy-subrc = 0. + typekind_utclong = . + CALL METHOD cl_abap_elemdescr=>('GET_UTCLONG') RECEIVING p_result = lo_rtti. + CREATE DATA variable_utclong TYPE HANDLE lo_rtti. + ENDIF. + ENDMETHOD. @@ -3847,6 +3860,7 @@ CLASS zcl_excel_worksheet IMPLEMENTATION. TYPE abap_typekind. FIELD-SYMBOLS: TYPE mty_s_column_formula. FIELD-SYMBOLS: TYPE zexcel_s_fieldcatalog. + FIELD-SYMBOLS TYPE simple. IF ip_value IS NOT SUPPLIED AND ip_formula IS NOT SUPPLIED @@ -3990,6 +4004,13 @@ CLASS zcl_excel_worksheet IMPLEMENTATION. * ENDIF. * End of change issue #152 - don't touch exisiting style if only value is passed + WHEN typekind_utclong. + ASSIGN variable_utclong->* TO . + IF sy-subrc = 0. + = . + lv_value = zcl_excel_common=>utclong_to_excel_string( ). + ENDIF. + WHEN OTHERS. zcx_excel=>raise_text( 'Invalid data type of input value' ). ENDCASE. @@ -4095,6 +4116,21 @@ CLASS zcl_excel_worksheet IMPLEMENTATION. ip_row = lv_row ip_number_format_format_code = lo_format_code_datetime ). + WHEN typekind_utclong. + TRY. + stylemapping = me->excel->get_style_to_guid( -cell_style ). + CATCH zcx_excel . + ENDTRY. + IF stylemapping-complete_stylex-number_format-format_code IS INITIAL OR + stylemapping-complete_style-number_format-format_code IS INITIAL. + lo_format_code_datetime = zcl_excel_style_number_format=>c_format_date_datetime. + ELSE. + lo_format_code_datetime = stylemapping-complete_style-number_format-format_code. + ENDIF. + me->change_cell_style( ip_column = lv_column + ip_row = lv_row + ip_number_format_format_code = lo_format_code_datetime ). + ENDCASE. * End of change issue #152 - don't touch exisiting style if only value is passed From 4e1931af159498bca2359eba60c9932ccceee61a Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Wed, 7 Aug 2024 09:05:50 +0200 Subject: [PATCH 3/5] font class cleanup (#1125) --- src/zcl_excel_font.clas.abap | 30 ++++++++++++++++-------------- src/zcl_excel_worksheet.clas.abap | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/zcl_excel_font.clas.abap b/src/zcl_excel_font.clas.abap index b670008..343d90e 100644 --- a/src/zcl_excel_font.clas.abap +++ b/src/zcl_excel_font.clas.abap @@ -5,6 +5,21 @@ CLASS zcl_excel_font DEFINITION PUBLIC SECTION. + TYPES ty_font_height TYPE n LENGTH 3. + CONSTANTS lc_default_font_height TYPE ty_font_height VALUE '110' ##NO_TEXT. + CONSTANTS lc_default_font_name TYPE zexcel_style_font_name VALUE 'Calibri' ##NO_TEXT. + + CLASS-METHODS calculate_text_width + IMPORTING + !iv_font_name TYPE zexcel_style_font_name + !iv_font_height TYPE ty_font_height + !iv_flag_bold TYPE abap_bool + !iv_flag_italic TYPE abap_bool + !iv_cell_value TYPE zexcel_cell_value + RETURNING + VALUE(rv_width) TYPE f . + PROTECTED SECTION. + PRIVATE SECTION. TYPES: BEGIN OF mty_s_font_metric, char TYPE c LENGTH 1, @@ -17,7 +32,7 @@ CLASS zcl_excel_font DEFINITION TYPES: BEGIN OF mty_s_font_cache, font_name TYPE zexcel_style_font_name, - font_height TYPE tdfontsize, + font_height TYPE ty_font_height, flag_bold TYPE abap_bool, flag_italic TYPE abap_bool, th_font_metrics TYPE mty_th_font_metrics, @@ -27,21 +42,8 @@ CLASS zcl_excel_font DEFINITION TYPE HASHED TABLE OF mty_s_font_cache WITH UNIQUE KEY font_name font_height flag_bold flag_italic . - CONSTANTS lc_default_font_height TYPE tdfontsize VALUE '110' ##NO_TEXT. - CONSTANTS lc_default_font_name TYPE zexcel_style_font_name VALUE 'Calibri' ##NO_TEXT. CLASS-DATA mth_font_cache TYPE mty_th_font_cache . - CLASS-METHODS calculate_text_width - IMPORTING - !iv_font_name TYPE zexcel_style_font_name - !iv_font_height TYPE tdfontsize - !iv_flag_bold TYPE abap_bool - !iv_flag_italic TYPE abap_bool - !iv_cell_value TYPE zexcel_cell_value - RETURNING - VALUE(rv_width) TYPE f . - PROTECTED SECTION. - PRIVATE SECTION. ENDCLASS. diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index 169e293..3da076d 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -1303,7 +1303,7 @@ CLASS zcl_excel_worksheet IMPLEMENTATION. ld_flag_italic TYPE abap_bool VALUE abap_false, ld_date TYPE d, ld_date_char TYPE c LENGTH 50, - ld_font_height TYPE tdfontsize VALUE zcl_excel_font=>lc_default_font_height, + ld_font_height TYPE zcl_excel_font=>ty_font_height VALUE zcl_excel_font=>lc_default_font_height, ld_font_name TYPE zexcel_style_font_name VALUE zcl_excel_font=>lc_default_font_name. " Determine cell content and cell style From 3d2926c5a676daa47680a3f0a028c027d254c138 Mon Sep 17 00:00:00 2001 From: Bernd <135710507+darnoc312@users.noreply.github.com> Date: Sat, 17 Aug 2024 17:07:05 +0200 Subject: [PATCH 4/5] Update ZEXCEL_FILL_TYPE 'cornerRB' (#1258) Fix #1257 --- src/zcl_excel_style_fill.clas.abap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/zcl_excel_style_fill.clas.abap b/src/zcl_excel_style_fill.clas.abap index f20b06d..0ca8cc7 100644 --- a/src/zcl_excel_style_fill.clas.abap +++ b/src/zcl_excel_style_fill.clas.abap @@ -135,10 +135,10 @@ CLASS zcl_excel_style_fill IMPLEMENTATION. gradtype-type = c_fill_gradient_path. gradtype-position1 = '0'. gradtype-position2 = '1'. - gradtype-bottom = '0.5'. - gradtype-top = '0.5'. - gradtype-left = '0.5'. - gradtype-right = '0.5'. + gradtype-bottom = '1'. + gradtype-top = '1'. + gradtype-left = '1'. + gradtype-right = '1'. ENDCASE. ENDMETHOD. "build_gradient From b5f5d11e1c7c91a139231f4e628c754bed91aa22 Mon Sep 17 00:00:00 2001 From: sandraros <34005250+sandraros@users.noreply.github.com> Date: Sun, 18 Aug 2024 14:52:53 +0200 Subject: [PATCH 5/5] Fix default cell format to not use UTCLONG (#1262) Fix #1261 Co-authored-by: sandraros --- src/zcl_excel_worksheet.clas.abap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index 3da076d..acd45fb 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -709,7 +709,8 @@ CLASS zcl_excel_worksheet DEFINITION *"* do not include other source files here!!! TYPES ty_table_settings TYPE STANDARD TABLE OF zexcel_s_table_settings WITH DEFAULT KEY. - CLASS-DATA typekind_utclong TYPE abap_typekind. + CONSTANTS typekind_utclong TYPE abap_typekind VALUE 'p'. + CLASS-DATA variable_utclong TYPE REF TO data. DATA active_cell TYPE zexcel_s_cell_data . @@ -2037,7 +2038,6 @@ CLASS zcl_excel_worksheet IMPLEMENTATION. ASSIGN ('CL_ABAP_TYPEDESCR=>TYPEKIND_UTCLONG') TO . IF sy-subrc = 0. - typekind_utclong = . CALL METHOD cl_abap_elemdescr=>('GET_UTCLONG') RECEIVING p_result = lo_rtti. CREATE DATA variable_utclong TYPE HANDLE lo_rtti. ENDIF.