From e02733290f14283a3e547985328a98d6393ad1fc Mon Sep 17 00:00:00 2001 From: striezl Date: Tue, 24 Sep 2019 22:37:49 +0200 Subject: [PATCH] Fix as discussed in issue #623 (#624) Convert exponential number from excel to ABAP datatype P (packed number) --- src/zcl_excel_worksheet.clas.abap | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index 80030fa..0d6303f 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -4327,6 +4327,9 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. DATA lv_delta_col TYPE int4. DATA lv_value TYPE zexcel_cell_value. DATA lv_rc TYPE sysubrc. + DATA lx_conversion_error TYPE REF TO cx_sy_conversion_error. + DATA lv_float TYPE f. + DATA lv_type. lv_max_col = me->get_highest_column( ). @@ -4405,7 +4408,18 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. zcx_excel=>raise_text( lv_errormessage ). ENDIF. - = lv_value. + TRY. + = lv_value. "Will raise exception if data type of is not float (or decfloat16/34) and excel delivers exponential number e.g. -2.9398924194538267E-2 + CATCH cx_sy_conversion_error INTO lx_conversion_error. + "Another try with conversion to float... + DESCRIBE FIELD TYPE lv_type. + IF lv_type = 'P'. + = lv_float = lv_value. + ELSE. + RAISE EXCEPTION lx_conversion_error. "Pass on original exception + ENDIF. + ENDTRY. + * CATCH zcx_excel. " ADD 1 TO lv_actual_col. ENDWHILE.