diff --git a/.abapgit.xml b/.abapgit.xml index 43805e1..a16c371 100644 --- a/.abapgit.xml +++ b/.abapgit.xml @@ -12,6 +12,7 @@ /package.json /.travis.yml /_config.yml + /abaplint.json diff --git a/abaplint.json b/abaplint.json new file mode 100644 index 0000000..0ac937f --- /dev/null +++ b/abaplint.json @@ -0,0 +1,119 @@ +{ + "global": { + "version": "v700", + "skipGeneratedGatewayClasses": true, + "skipGeneratedPersistentClasses": true + }, + "rules": { + "7bit_ascii": { + "enabled": false + }, + "contains_tab": { + "enabled": false + }, + "functional_writing": { + "enabled": false, + "ignoreExceptions": true + }, + "line_length": { + "enabled": false, + "length": 120 + }, + "max_one_statement": { + "enabled": false + }, + "parser_error": { + "enabled": true + }, + "space_before_colon": { + "enabled": false + }, + "colon_missing_space": { + "enabled": false + }, + "exit_or_check": { + "enabled": false + }, + "line_only_punc": { + "enabled": false, + "ignoreExceptions": true + }, + "obsolete_statement": { + "enabled": false, + "refresh": true, + "compute": true, + "add": true, + "subtract": true, + "multiply": true, + "move": true, + "divide": true, + "requested": true + }, + "start_at_tab": { + "enabled": false + }, + "whitespace_end": { + "enabled": true + }, + "exporting": { + "enabled": false + }, + "empty_statement": { + "enabled": false + }, + "sequential_blank": { + "enabled": false, + "lines": 4 + }, + "definitions_top": { + "enabled": false + }, + "breakpoint": { + "enabled": false + }, + "nesting": { + "enabled": false, + "depth": 5 + }, + "keywords_upper": { + "enabled": false, + "ignoreExceptions": true + }, + "cloud_types": { + "enabled": true + }, + "method_length": { + "enabled": false, + "statements": 100 + }, + "mix_returning": { + "enabled": true + }, + "method_parameter_names": { + "enabled": false, + "ignoreExceptions": true, + "importing": "^I._.*$", + "returning": "^R._.*$", + "changing": "^C._.*$", + "exporting": "^E._.*$", + "ignoreNames": [ + "P_TASK" + ] + }, + "inline_data_old_versions": { + "enabled": true + }, + "local_variable_names": { + "enabled": false, + "expectedData": "^L._.*$", + "expectedConstant": "^LC_.*$", + "expectedFS": "^$" + }, + "class_attribute_names": { + "enabled": false, + "ignoreExceptions": true, + "statics": "^G._.*$", + "instance": "^M._.*$" + } + } +} diff --git a/src/zcl_excel_worksheet.clas.abap b/src/zcl_excel_worksheet.clas.abap index e2149e1..d0b84c6 100644 --- a/src/zcl_excel_worksheet.clas.abap +++ b/src/zcl_excel_worksheet.clas.abap @@ -4217,7 +4217,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. endmethod. - method GET_TABLE. + METHOD get_table. *--------------------------------------------------------------------* * Comment D. Rauchenstein * With this method, we get a fully functional Excel Upload, which solves @@ -4230,116 +4230,128 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION. * CL_EXCEL_READER_2007->ZIF_EXCEL_READER~LOAD_FILE() *--------------------------------------------------------------------* - field-symbols: type DATA. - field-symbols: type DATA. + FIELD-SYMBOLS: TYPE data. + FIELD-SYMBOLS: TYPE data. - data LV_ACTUAL_ROW type INT4. - data LV_ACTUAL_COL type INT4. - data LV_ERRORMESSAGE type STRING. - data LV_MAX_COL type ZEXCEL_CELL_COLUMN. - data LV_MAX_ROW type INT4. - data LV_DELTA_COL type INT4. - data LV_VALUE type ZEXCEL_CELL_VALUE. - data LV_RC type SYSUBRC. + DATA lv_actual_row TYPE int4. + DATA lv_actual_row_string TYPE string. + DATA lv_actual_col TYPE int4. + DATA lv_actual_col_string TYPE string. + DATA lv_errormessage TYPE string. + DATA lv_max_col TYPE zexcel_cell_column. + DATA lv_max_row TYPE int4. + DATA lv_delta_col TYPE int4. + DATA lv_value TYPE zexcel_cell_value. + DATA lv_rc TYPE sysubrc. - LV_MAX_COL = ME->GET_HIGHEST_COLUMN( ). - LV_MAX_ROW = ME->GET_HIGHEST_ROW( ). + lv_max_col = me->get_highest_column( ). + lv_max_row = me->get_highest_row( ). *--------------------------------------------------------------------* * The row counter begins with 1 and should be corrected with the skips *--------------------------------------------------------------------* - LV_ACTUAL_ROW = IV_SKIPPED_ROWS + 1. - LV_ACTUAL_COL = IV_SKIPPED_COLS + 1. + lv_actual_row = iv_skipped_rows + 1. + lv_actual_col = iv_skipped_cols + 1. - try. + TRY. *--------------------------------------------------------------------* * Check if we the basic features are possible with given "any table" *--------------------------------------------------------------------* - append initial line to ET_TABLE assigning . - if SY-SUBRC <> 0 or is not assigned. + APPEND INITIAL LINE TO et_table ASSIGNING . + IF sy-subrc <> 0 OR IS NOT ASSIGNED. - LV_ERRORMESSAGE = 'Error at inserting new Line to internal Table'(002). + lv_errormessage = 'Error at inserting new Line to internal Table'(002). zcx_excel=>raise_text( lv_errormessage ). - else. - LV_DELTA_COL = LV_MAX_COL - IV_SKIPPED_COLS. - assign component LV_DELTA_COL of structure to . - if SY-SUBRC <> 0 or is not assigned. - LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003). + ELSE. + lv_delta_col = lv_max_col - iv_skipped_cols. + ASSIGN COMPONENT lv_delta_col OF STRUCTURE TO . + IF sy-subrc <> 0 OR IS NOT ASSIGNED. + lv_errormessage = 'Internal table has less columns than excel'(003). zcx_excel=>raise_text( lv_errormessage ). - else. + ELSE. *--------------------------------------------------------------------* *now we are ready for handle the table data *--------------------------------------------------------------------* - refresh ET_TABLE. + REFRESH et_table. *--------------------------------------------------------------------* * Handle each Row until end on right side *--------------------------------------------------------------------* - while LV_ACTUAL_ROW <= LV_MAX_ROW . + WHILE lv_actual_row <= lv_max_row . *--------------------------------------------------------------------* * Handle each Column until end on bottom * First step is to step back on first column *--------------------------------------------------------------------* - LV_ACTUAL_COL = IV_SKIPPED_COLS + 1. + lv_actual_col = iv_skipped_cols + 1. - unassign . - append initial line to ET_TABLE assigning . - if SY-SUBRC <> 0 or is not assigned. - LV_ERRORMESSAGE = 'Error at inserting new Line to internal Table'(002). + UNASSIGN . + APPEND INITIAL LINE TO et_table ASSIGNING . + IF sy-subrc <> 0 OR IS NOT ASSIGNED. + lv_errormessage = 'Error at inserting new Line to internal Table'(002). zcx_excel=>raise_text( lv_errormessage ). - endif. - while LV_ACTUAL_COL <= LV_MAX_COL. + ENDIF. + WHILE lv_actual_col <= lv_max_col. - LV_DELTA_COL = LV_ACTUAL_COL - IV_SKIPPED_COLS. - assign component LV_DELTA_COL of structure to . - if SY-SUBRC <> 0. - LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + lv_delta_col = lv_actual_col - iv_skipped_cols. + ASSIGN COMPONENT lv_delta_col OF STRUCTURE TO . + IF sy-subrc <> 0. + lv_actual_col_string = lv_actual_col. + lv_actual_row_string = lv_actual_row. + CONCATENATE 'Error at assigning field (Col:'(004) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage. zcx_excel=>raise_text( lv_errormessage ). - endif. + ENDIF. - ME->GET_CELL( - exporting - IP_COLUMN = LV_ACTUAL_COL " Cell Column - IP_ROW = LV_ACTUAL_ROW " Cell Row - importing - EP_VALUE = LV_VALUE " Cell Value - EP_RC = LV_RC " Return Value of ABAP Statements + me->get_cell( + EXPORTING + ip_column = lv_actual_col " Cell Column + ip_row = lv_actual_row " Cell Row + IMPORTING + ep_value = lv_value " Cell Value + ep_rc = lv_rc " Return Value of ABAP Statements ). - if LV_RC <> 0 - and LV_RC <> 4. "No found error means, zero/no value in cell - LV_ERRORMESSAGE = |{ 'Error at reading field value (Col:'(007) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + IF lv_rc <> 0 + AND lv_rc <> 4. "No found error means, zero/no value in cell + lv_actual_col_string = lv_actual_col. + lv_actual_row_string = lv_actual_row. + CONCATENATE 'Error at reading field value (Col:'(007) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage. zcx_excel=>raise_text( lv_errormessage ). - endif. + ENDIF. - = LV_VALUE. + = lv_value. * CATCH zcx_excel. " - add 1 to LV_ACTUAL_COL. - endwhile. - add 1 to LV_ACTUAL_ROW. - endwhile. - endif. + ADD 1 TO lv_actual_col. + ENDWHILE. + ADD 1 TO lv_actual_row. + ENDWHILE. + ENDIF. - endif. + ENDIF. - catch CX_SY_ASSIGN_CAST_ILLEGAL_CAST. - LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + CATCH cx_sy_assign_cast_illegal_cast. + lv_actual_col_string = lv_actual_col. + lv_actual_row_string = lv_actual_row. + CONCATENATE 'Error at assigning field (Col:'(004) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage. zcx_excel=>raise_text( lv_errormessage ). - catch CX_SY_ASSIGN_CAST_UNKNOWN_TYPE. - LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + CATCH cx_sy_assign_cast_unknown_type. + lv_actual_col_string = lv_actual_col. + lv_actual_row_string = lv_actual_row. + CONCATENATE 'Error at assigning field (Col:'(004) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage. zcx_excel=>raise_text( lv_errormessage ). - catch CX_SY_ASSIGN_OUT_OF_RANGE. - LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003). + CATCH cx_sy_assign_out_of_range. + lv_errormessage = 'Internal table has less columns than excel'(003). zcx_excel=>raise_text( lv_errormessage ). - catch CX_SY_CONVERSION_ERROR. - LV_ERRORMESSAGE = |{ 'Error at converting field value (Col:'(006) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. + CATCH cx_sy_conversion_error. + lv_actual_col_string = lv_actual_col. + lv_actual_row_string = lv_actual_row. + CONCATENATE 'Error at converting field value (Col:'(006) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage. zcx_excel=>raise_text( lv_errormessage ). - endtry. - endmethod. + ENDTRY. + ENDMETHOD. method GET_TABLES_ITERATOR. diff --git a/src/zcl_excel_writer_2007.clas.abap b/src/zcl_excel_writer_2007.clas.abap index a2f7b17..b95af7f 100644 --- a/src/zcl_excel_writer_2007.clas.abap +++ b/src/zcl_excel_writer_2007.clas.abap @@ -2298,7 +2298,8 @@ METHOD create_xl_comments. lo_iterator TYPE REF TO cl_object_collection_iterator, lo_comments TYPE REF TO zcl_excel_comments, lo_comment TYPE REF TO zcl_excel_comment. - DATA: lv_rel_id TYPE i. + DATA: lv_rel_id TYPE i, + lv_author TYPE string. DEFINE add_1_val_child_node. * &1: parent element @@ -2344,7 +2345,8 @@ METHOD create_xl_comments. lo_element_author = lo_document->create_simple_element( name = lc_xml_node_author parent = lo_document ). - lo_element_author->set_value( |{ sy-uname }| ). + lv_author = sy-uname. + lo_element_author->set_value( lv_author ). lo_element_authors->append_child( new_child = lo_element_author ). lo_element_root->append_child( new_child = lo_element_authors ). @@ -2890,59 +2892,59 @@ method CREATE_XL_DRAWING_ANCHOR. METHOD create_xl_drawing_for_comments. ** Constant node name - CONSTANTS: lc_xml_node_xml TYPE string VALUE 'xml', - lc_xml_node_ns_v TYPE string VALUE 'urn:schemas-microsoft-com:vml', - lc_xml_node_ns_o TYPE string VALUE 'urn:schemas-microsoft-com:office:office', - lc_xml_node_ns_x TYPE string VALUE 'urn:schemas-microsoft-com:office:excel', - " shapelayout - lc_xml_node_shapelayout TYPE string VALUE 'o:shapelayout', - lc_xml_node_idmap TYPE string VALUE 'o:idmap', - " shapetype - lc_xml_node_shapetype TYPE string VALUE 'v:shapetype', - lc_xml_node_stroke TYPE string VALUE 'v:stroke', - lc_xml_node_path TYPE string VALUE 'v:path', - " shape - lc_xml_node_shape TYPE string VALUE 'v:shape', - lc_xml_node_fill TYPE string VALUE 'v:fill', - lc_xml_node_shadow TYPE string VALUE 'v:shadow', - lc_xml_node_textbox TYPE string VALUE 'v:textbox', - lc_xml_node_div TYPE string VALUE 'div', - lc_xml_node_clientdata TYPE string VALUE 'x:ClientData', - lc_xml_node_movewithcells TYPE string VALUE 'x:MoveWithCells', - lc_xml_node_sizewithcells TYPE string VALUE 'x:SizeWithCells', - lc_xml_node_anchor TYPE string VALUE 'x:Anchor', - lc_xml_node_autofill TYPE string VALUE 'x:AutoFill', - lc_xml_node_row TYPE string VALUE 'x:Row', - lc_xml_node_column TYPE string VALUE 'x:Column', - " attributes, - lc_xml_attr_vext TYPE string VALUE 'v:ext', - lc_xml_attr_data TYPE string VALUE 'data', - lc_xml_attr_id TYPE string VALUE 'id', - lc_xml_attr_coordsize TYPE string VALUE 'coordsize', - lc_xml_attr_ospt TYPE string VALUE 'o:spt', - lc_xml_attr_joinstyle TYPE string VALUE 'joinstyle', - lc_xml_attr_path TYPE string VALUE 'path', - lc_xml_attr_gradientshapeok TYPE string VALUE 'gradientshapeok', - lc_xml_attr_oconnecttype TYPE string VALUE 'o:connecttype', - lc_xml_attr_type TYPE string VALUE 'type', - lc_xml_attr_style TYPE string VALUE 'style', - lc_xml_attr_fillcolor TYPE string VALUE 'fillcolor', - lc_xml_attr_oinsetmode TYPE string VALUE 'o:insetmode', - lc_xml_attr_color TYPE string VALUE 'color', - lc_xml_attr_color2 TYPE string VALUE 'color2', - lc_xml_attr_on TYPE string VALUE 'on', - lc_xml_attr_obscured TYPE string VALUE 'obscured', - lc_xml_attr_objecttype TYPE string VALUE 'ObjectType', - " attributes values - lc_xml_attr_val_edit TYPE string VALUE 'edit', - lc_xml_attr_val_rect TYPE string VALUE 'rect', - lc_xml_attr_val_t TYPE string VALUE 't', - lc_xml_attr_val_miter TYPE string VALUE 'miter', - lc_xml_attr_val_auto TYPE string VALUE 'auto', - lc_xml_attr_val_black TYPE string VALUE 'black', - lc_xml_attr_val_none TYPE string VALUE 'none', - lc_xml_attr_val_msodir TYPE string VALUE 'mso-direction-alt:auto', - lc_xml_attr_val_note TYPE string VALUE 'Note'. + CONSTANTS: lc_xml_node_xml TYPE string VALUE 'xml', + lc_xml_node_ns_v TYPE string VALUE 'urn:schemas-microsoft-com:vml', + lc_xml_node_ns_o TYPE string VALUE 'urn:schemas-microsoft-com:office:office', + lc_xml_node_ns_x TYPE string VALUE 'urn:schemas-microsoft-com:office:excel', + " shapelayout + lc_xml_node_shapelayout TYPE string VALUE 'o:shapelayout', + lc_xml_node_idmap TYPE string VALUE 'o:idmap', + " shapetype + lc_xml_node_shapetype TYPE string VALUE 'v:shapetype', + lc_xml_node_stroke TYPE string VALUE 'v:stroke', + lc_xml_node_path TYPE string VALUE 'v:path', + " shape + lc_xml_node_shape TYPE string VALUE 'v:shape', + lc_xml_node_fill TYPE string VALUE 'v:fill', + lc_xml_node_shadow TYPE string VALUE 'v:shadow', + lc_xml_node_textbox TYPE string VALUE 'v:textbox', + lc_xml_node_div TYPE string VALUE 'div', + lc_xml_node_clientdata TYPE string VALUE 'x:ClientData', + lc_xml_node_movewithcells TYPE string VALUE 'x:MoveWithCells', + lc_xml_node_sizewithcells TYPE string VALUE 'x:SizeWithCells', + lc_xml_node_anchor TYPE string VALUE 'x:Anchor', + lc_xml_node_autofill TYPE string VALUE 'x:AutoFill', + lc_xml_node_row TYPE string VALUE 'x:Row', + lc_xml_node_column TYPE string VALUE 'x:Column', + " attributes, + lc_xml_attr_vext TYPE string VALUE 'v:ext', + lc_xml_attr_data TYPE string VALUE 'data', + lc_xml_attr_id TYPE string VALUE 'id', + lc_xml_attr_coordsize TYPE string VALUE 'coordsize', + lc_xml_attr_ospt TYPE string VALUE 'o:spt', + lc_xml_attr_joinstyle TYPE string VALUE 'joinstyle', + lc_xml_attr_path TYPE string VALUE 'path', + lc_xml_attr_gradientshapeok TYPE string VALUE 'gradientshapeok', + lc_xml_attr_oconnecttype TYPE string VALUE 'o:connecttype', + lc_xml_attr_type TYPE string VALUE 'type', + lc_xml_attr_style TYPE string VALUE 'style', + lc_xml_attr_fillcolor TYPE string VALUE 'fillcolor', + lc_xml_attr_oinsetmode TYPE string VALUE 'o:insetmode', + lc_xml_attr_color TYPE string VALUE 'color', + lc_xml_attr_color2 TYPE string VALUE 'color2', + lc_xml_attr_on TYPE string VALUE 'on', + lc_xml_attr_obscured TYPE string VALUE 'obscured', + lc_xml_attr_objecttype TYPE string VALUE 'ObjectType', + " attributes values + lc_xml_attr_val_edit TYPE string VALUE 'edit', + lc_xml_attr_val_rect TYPE string VALUE 'rect', + lc_xml_attr_val_t TYPE string VALUE 't', + lc_xml_attr_val_miter TYPE string VALUE 'miter', + lc_xml_attr_val_auto TYPE string VALUE 'auto', + lc_xml_attr_val_black TYPE string VALUE 'black', + lc_xml_attr_val_none TYPE string VALUE 'none', + lc_xml_attr_val_msodir TYPE string VALUE 'mso-direction-alt:auto', + lc_xml_attr_val_note TYPE string VALUE 'Note'. DATA: lo_ixml TYPE REF TO if_ixml, @@ -2978,7 +2980,11 @@ METHOD create_xl_drawing_for_comments. lv_row TYPE zexcel_cell_row, lv_str_column TYPE zexcel_cell_column_alpha, lv_column TYPE zexcel_cell_column, - lv_index TYPE i. + lv_index TYPE i, + lv_attr_id_index TYPE i, + lv_attr_id TYPE string, + lv_int_value TYPE i, + lv_int_value_string TYPE string. DATA: lv_rel_id TYPE i. DEFINE add_1_val_child_node. @@ -3072,7 +3078,10 @@ METHOD create_xl_drawing_for_comments. lo_element_shape = lo_document->create_simple_element( name = lc_xml_node_shape parent = lo_document ). - lo_element_shape->set_attribute_ns( : name = lc_xml_attr_id value = |_x0000_s{ 1024 + lv_index }| ), + lv_attr_id_index = 1024 + lv_index. + lv_attr_id = lv_attr_id_index. + CONCATENATE '_x0000_s' lv_attr_id INTO lv_attr_id. + lo_element_shape->set_attribute_ns( : name = lc_xml_attr_id value = lv_attr_id ), name = lc_xml_attr_type value = '#_x0000_t202' ), name = lc_xml_attr_style value = 'size:auto;width:auto;height:auto;position:absolute;margin-left:117pt;margin-top:172.5pt;z-index:1;visibility:hidden' ), name = lc_xml_attr_fillcolor value = '#ffffe1' ), @@ -3124,13 +3133,15 @@ METHOD create_xl_drawing_for_comments. lo_element_clientdata->append_child( new_child = lo_element_autofill ). lo_element_row = lo_document->create_simple_element( name = lc_xml_node_row parent = lo_document ). -* lo_element_row->set_value( '12' ). - lo_element_row->set_value( |{ lv_row - 1 }| ). + lv_int_value = lv_row - 1. + lv_int_value_string = lv_int_value. + lo_element_row->set_value( lv_int_value_string ). lo_element_clientdata->append_child( new_child = lo_element_row ). lo_element_column = lo_document->create_simple_element( name = lc_xml_node_column parent = lo_document ). -* lo_element_column->set_value( '1' ). - lo_element_column->set_value( |{ lv_column - 1 }| ). + lv_int_value = lv_column - 1. + lv_int_value_string = lv_int_value. + lo_element_column->set_value( lv_int_value_string ). lo_element_clientdata->append_child( new_child = lo_element_column ). lo_element_shape->append_child( new_child = lo_element_clientdata ). diff --git a/src/zdemo_excel_comments.prog.abap b/src/zdemo_excel_comments.prog.abap index 783b7ec..d1afa28 100644 --- a/src/zdemo_excel_comments.prog.abap +++ b/src/zdemo_excel_comments.prog.abap @@ -10,7 +10,8 @@ REPORT zdemo_excel_comments. DATA: lo_excel TYPE REF TO zcl_excel, lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_comment TYPE REF TO zcl_excel_comment, - lo_hyperlink TYPE REF TO zcl_excel_hyperlink. + lo_hyperlink TYPE REF TO zcl_excel_hyperlink, + lv_comment TYPE string. CONSTANTS: gc_save_file_name TYPE string VALUE 'Comments.xlsx'. INCLUDE zdemo_excel_outputopt_incl. @@ -37,8 +38,8 @@ START-OF-SELECTION. lo_comment->set_text( ip_ref = 'C18' ip_text = 'Another comment' ). lo_worksheet->add_comment( lo_comment ). lo_comment = lo_excel->add_new_comment( ). - lo_comment->set_text( ip_ref = 'F6' ip_text = |A comment split{ cl_abap_char_utilities=>cr_lf }on 2 lines?| ). - lo_worksheet->add_comment( lo_comment ). + CONCATENATE 'A comment split' cl_abap_char_utilities=>cr_lf 'on 2 lines?' INTO lv_comment. + lo_comment->set_text( ip_ref = 'F6' ip_text = lv_comment ). " Second sheet lo_worksheet = lo_excel->add_new_worksheet( ).