diff --git a/src/abap2xlsx/foo.txt b/src/abap2xlsx/foo.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/abap2xlsx/package.devc.xml b/src/abap2xlsx/package.devc.xml new file mode 100644 index 0000000..8298ba0 --- /dev/null +++ b/src/abap2xlsx/package.devc.xml @@ -0,0 +1,10 @@ + + + + + + Objects which cannot work in SAP Cloud + + + + diff --git a/src/abap2xlsx/ycl_ecb.clas.abap b/src/abap2xlsx/ycl_ecb.clas.abap new file mode 100644 index 0000000..e9196b6 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb.clas.abap @@ -0,0 +1,700 @@ +CLASS ycl_ecb DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + +*"* public components of class ZCL_EXCEL +*"* do not include other source files here!!! + INTERFACES yif_ecb_book_properties . + INTERFACES yif_ecb_book_protection . + INTERFACES yif_ecb_book_vba_project . + + DATA legacy_palette TYPE REF TO ycl_ecb_legacy_palette READ-ONLY . + DATA security TYPE REF TO ycl_ecb_security . + DATA use_template TYPE abap_bool . + CONSTANTS version TYPE c LENGTH 10 VALUE '7.16.0'. "#EC NOTEXT + + METHODS add_new_autofilter + IMPORTING + !io_sheet TYPE REF TO ycl_ecb_worksheet + RETURNING + VALUE(ro_autofilter) TYPE REF TO ycl_ecb_autofilter + RAISING + ycx_ecb . + METHODS add_new_comment + RETURNING + VALUE(eo_comment) TYPE REF TO ycl_ecb_comment . + METHODS add_new_drawing + IMPORTING + !ip_type TYPE yecb_drawing_type DEFAULT ycl_ecb_drawing=>type_image + !ip_title TYPE clike OPTIONAL + RETURNING + VALUE(eo_drawing) TYPE REF TO ycl_ecb_drawing . + METHODS add_new_range + RETURNING + VALUE(eo_range) TYPE REF TO ycl_ecb_range . + METHODS add_new_style + IMPORTING + !ip_guid TYPE yecb_cell_style OPTIONAL + !io_clone_of TYPE REF TO ycl_ecb_style OPTIONAL + PREFERRED PARAMETER !ip_guid + RETURNING + VALUE(eo_style) TYPE REF TO ycl_ecb_style . + METHODS add_new_worksheet + IMPORTING + !ip_title TYPE yecb_sheet_title OPTIONAL + RETURNING + VALUE(eo_worksheet) TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS add_static_styles . + METHODS constructor . + METHODS delete_worksheet + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS delete_worksheet_by_index + IMPORTING + !iv_index TYPE numeric + RAISING + ycx_ecb . + METHODS delete_worksheet_by_name + IMPORTING + !iv_title TYPE clike + RAISING + ycx_ecb . + METHODS get_active_sheet_index + RETURNING + VALUE(r_active_worksheet) TYPE yecb_active_worksheet . + METHODS get_active_worksheet + RETURNING + VALUE(eo_worksheet) TYPE REF TO ycl_ecb_worksheet . + METHODS get_autofilters_reference + RETURNING + VALUE(ro_autofilters) TYPE REF TO ycl_ecb_autofilters . + METHODS get_default_style + RETURNING + VALUE(ep_style) TYPE yecb_cell_style . + METHODS get_drawings_iterator + IMPORTING + !ip_type TYPE yecb_drawing_type + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_next_table_id + RETURNING + VALUE(ep_id) TYPE i . + METHODS get_ranges_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_static_cellstyle_guid + IMPORTING + !ip_cstyle_complete TYPE yecb_s_cstyle_complete + !ip_cstylex_complete TYPE yecb_s_cstylex_complete + RETURNING + VALUE(ep_guid) TYPE yecb_cell_style . + METHODS get_styles_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_style_index_in_styles + IMPORTING + !ip_guid TYPE yecb_cell_style + RETURNING + VALUE(ep_index) TYPE i + RAISING + ycx_ecb . + METHODS get_style_to_guid + IMPORTING + !ip_guid TYPE yecb_cell_style + RETURNING + VALUE(ep_stylemapping) TYPE yecb_s_stylemapping + RAISING + ycx_ecb . + METHODS get_theme + EXPORTING + !eo_theme TYPE REF TO ycl_ecb_theme . + METHODS get_worksheets_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_worksheets_name + RETURNING + VALUE(ep_name) TYPE yecb_worksheets_name . + METHODS get_worksheets_size + RETURNING + VALUE(ep_size) TYPE i . + METHODS get_worksheet_by_index + IMPORTING + !iv_index TYPE numeric + RETURNING + VALUE(eo_worksheet) TYPE REF TO ycl_ecb_worksheet . + METHODS get_worksheet_by_name + IMPORTING + !ip_sheet_name TYPE yecb_sheet_title + RETURNING + VALUE(eo_worksheet) TYPE REF TO ycl_ecb_worksheet . + METHODS set_active_sheet_index + IMPORTING + !i_active_worksheet TYPE yecb_active_worksheet + RAISING + ycx_ecb . + METHODS set_active_sheet_index_by_name + IMPORTING + !i_worksheet_name TYPE yecb_worksheets_name . + METHODS set_default_style + IMPORTING + !ip_style TYPE yecb_cell_style + RAISING + ycx_ecb . + METHODS set_theme + IMPORTING + !io_theme TYPE REF TO ycl_ecb_theme . + METHODS fill_template + IMPORTING + !iv_data TYPE REF TO ycl_ecb_template_data + RAISING + ycx_ecb . + PROTECTED SECTION. + + DATA worksheets TYPE REF TO ycl_ecb_worksheets . + PRIVATE SECTION. + + DATA autofilters TYPE REF TO ycl_ecb_autofilters . + DATA charts TYPE REF TO ycl_ecb_drawings . + DATA default_style TYPE yecb_cell_style . +*"* private components of class ZCL_EXCEL +*"* do not include other source files here!!! + DATA drawings TYPE REF TO ycl_ecb_drawings . + DATA ranges TYPE REF TO ycl_ecb_ranges . + DATA styles TYPE REF TO ycl_ecb_styles . + DATA t_stylemapping1 TYPE yecb_t_stylemapping1 . + DATA t_stylemapping2 TYPE yecb_t_stylemapping2 . + DATA theme TYPE REF TO ycl_ecb_theme . + DATA comments TYPE REF TO ycl_ecb_comments . + + METHODS get_style_from_guid + IMPORTING + !ip_guid TYPE yecb_cell_style + RETURNING + VALUE(eo_style) TYPE REF TO ycl_ecb_style . + METHODS stylemapping_dynamic_style + IMPORTING + !ip_style TYPE REF TO ycl_ecb_style + RETURNING + VALUE(eo_style2) TYPE yecb_s_stylemapping . +ENDCLASS. + + + +CLASS ycl_ecb IMPLEMENTATION. + + + METHOD add_new_autofilter. +* Check for autofilter reference: new or overwrite; only one per sheet + ro_autofilter = autofilters->add( io_sheet ) . + ENDMETHOD. + + + METHOD add_new_comment. + CREATE OBJECT eo_comment. + + comments->add( eo_comment ). + ENDMETHOD. + + + METHOD add_new_drawing. +* Create default blank worksheet + CREATE OBJECT eo_drawing + EXPORTING + ip_type = ip_type + ip_title = ip_title. + + CASE ip_type. + WHEN 'image'. + drawings->add( eo_drawing ). + WHEN 'hd_ft'. + drawings->add( eo_drawing ). + WHEN 'chart'. + charts->add( eo_drawing ). + ENDCASE. + ENDMETHOD. + + + METHOD add_new_range. +* Create default blank range + CREATE OBJECT eo_range. + ranges->add( eo_range ). + ENDMETHOD. + + + METHOD add_new_style. +* Start of deletion # issue 139 - Dateretention of cellstyles +* CREATE OBJECT eo_style. +* styles->add( eo_style ). +* End of deletion # issue 139 - Dateretention of cellstyles +* Start of insertion # issue 139 - Dateretention of cellstyles +* Create default style + CREATE OBJECT eo_style + EXPORTING + ip_guid = ip_guid + io_clone_of = io_clone_of. + styles->add( eo_style ). + + DATA: style2 TYPE yecb_s_stylemapping. +* Copy to new representations + style2 = stylemapping_dynamic_style( eo_style ). + INSERT style2 INTO TABLE t_stylemapping1. + INSERT style2 INTO TABLE t_stylemapping2. +* End of insertion # issue 139 - Dateretention of cellstyles + + ENDMETHOD. + + + METHOD add_new_worksheet. + +* Create default blank worksheet + CREATE OBJECT eo_worksheet + EXPORTING + ip_excel = me + ip_title = ip_title. + + worksheets->add( eo_worksheet ). + worksheets->active_worksheet = worksheets->size( ). + ENDMETHOD. + + + METHOD add_static_styles. + " # issue 139 + FIELD-SYMBOLS: LIKE LINE OF t_stylemapping1, + LIKE LINE OF t_stylemapping2. + DATA: style TYPE REF TO ycl_ecb_style. + + LOOP AT me->t_stylemapping1 ASSIGNING WHERE added_to_iterator IS INITIAL. + READ TABLE me->t_stylemapping2 ASSIGNING WITH TABLE KEY guid = -guid. + CHECK sy-subrc = 0. " Should always be true since these tables are being filled parallel + + style = me->add_new_style( -guid ). + + ycl_ecb_common=>recursive_struct_to_class( EXPORTING i_source = -complete_style + i_sourcex = -complete_stylex + CHANGING e_target = style ). + + ENDLOOP. + ENDMETHOD. + + + METHOD constructor. + DATA: lo_style TYPE REF TO ycl_ecb_style. + +* Inizialize instance objects + CREATE OBJECT security. + CREATE OBJECT worksheets. + CREATE OBJECT ranges. + CREATE OBJECT styles. + CREATE OBJECT drawings + EXPORTING + ip_type = ycl_ecb_drawing=>type_image. + CREATE OBJECT charts + EXPORTING + ip_type = ycl_ecb_drawing=>type_chart. + CREATE OBJECT comments. + CREATE OBJECT legacy_palette. + CREATE OBJECT autofilters. + + me->yif_ecb_book_protection~initialize( ). + me->yif_ecb_book_properties~initialize( ). + + TRY. + me->add_new_worksheet( ). + CATCH ycx_ecb. " suppress syntax check error + ASSERT 1 = 2. " some error processing anyway + ENDTRY. + + me->add_new_style( ). " Standard style + lo_style = me->add_new_style( ). " Standard style with fill gray125 + lo_style->fill->filltype = ycl_ecb_style_fill=>c_fill_pattern_gray125. + + ENDMETHOD. + + + METHOD delete_worksheet. + + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet, + l_size TYPE i, + lv_errormessage TYPE string. + + l_size = get_worksheets_size( ). + IF l_size = 1. " Only 1 worksheet left --> check whether this is the worksheet to be deleted + lo_worksheet = me->get_worksheet_by_index( 1 ). + IF lo_worksheet = io_worksheet. + lv_errormessage = 'Deleting last remaining worksheet is not allowed'(002). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + ENDIF. + + me->worksheets->remove( io_worksheet ). + + ENDMETHOD. + + + METHOD delete_worksheet_by_index. + + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lv_errormessage TYPE string. + + lo_worksheet = me->get_worksheet_by_index( iv_index ). + IF lo_worksheet IS NOT BOUND. + lv_errormessage = 'Worksheet not existing'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + me->delete_worksheet( lo_worksheet ). + + ENDMETHOD. + + + METHOD delete_worksheet_by_name. + + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lv_errormessage TYPE string. + + lo_worksheet = me->get_worksheet_by_name( iv_title ). + IF lo_worksheet IS NOT BOUND. + lv_errormessage = 'Worksheet not existing'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + me->delete_worksheet( lo_worksheet ). + + ENDMETHOD. + + + METHOD fill_template. + + DATA: lo_template_filler TYPE REF TO ycl_ecb_fill_template. + + FIELD-SYMBOLS: + TYPE yecb_sheet_title, + TYPE ycl_ecb_template_data=>ts_template_data_sheet. + + + lo_template_filler = ycl_ecb_fill_template=>create( me ). + + LOOP AT lo_template_filler->mt_sheet ASSIGNING . + + READ TABLE iv_data->mt_data ASSIGNING WITH KEY sheet = . + CHECK sy-subrc = 0. + lo_template_filler->fill_sheet( ). + + ENDLOOP. + + ENDMETHOD. + + + METHOD get_active_sheet_index. + r_active_worksheet = me->worksheets->active_worksheet. + ENDMETHOD. + + + METHOD get_active_worksheet. + + eo_worksheet = me->worksheets->get( me->worksheets->active_worksheet ). + + ENDMETHOD. + + + METHOD get_autofilters_reference. + + ro_autofilters = autofilters. + + ENDMETHOD. + + + METHOD get_default_style. + ep_style = me->default_style. + ENDMETHOD. + + + METHOD get_drawings_iterator. + + CASE ip_type. + WHEN ycl_ecb_drawing=>type_image. + eo_iterator = me->drawings->get_iterator( ). + WHEN ycl_ecb_drawing=>type_chart. + eo_iterator = me->charts->get_iterator( ). + WHEN OTHERS. + ENDCASE. + + ENDMETHOD. + + + METHOD get_next_table_id. + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator, + lv_tables_count TYPE i. + + lo_iterator = me->get_worksheets_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_worksheet ?= lo_iterator->get_next( ). + + lv_tables_count = lo_worksheet->get_tables_size( ). + ADD lv_tables_count TO ep_id. + + ENDWHILE. + + ADD 1 TO ep_id. + + ENDMETHOD. + + + METHOD get_ranges_iterator. + + eo_iterator = me->ranges->get_iterator( ). + + ENDMETHOD. + + + METHOD get_static_cellstyle_guid. + " # issue 139 + DATA: style LIKE LINE OF me->t_stylemapping1. + + READ TABLE me->t_stylemapping1 INTO style + WITH TABLE KEY dynamic_style_guid = style-guid " no dynamic style --> look for initial guid here + complete_style = ip_cstyle_complete + complete_stylex = ip_cstylex_complete. + IF sy-subrc <> 0. + style-complete_style = ip_cstyle_complete. + style-complete_stylex = ip_cstylex_complete. + style-guid = ycl_ecb_obsolete_func_wrap=>guid_create( ). " ins issue #379 - replacement for outdated function call + INSERT style INTO TABLE me->t_stylemapping1. + INSERT style INTO TABLE me->t_stylemapping2. + + ENDIF. + + ep_guid = style-guid. + ENDMETHOD. + + + METHOD get_styles_iterator. + + eo_iterator = me->styles->get_iterator( ). + + ENDMETHOD. + + + METHOD get_style_from_guid. + + DATA: lo_style TYPE REF TO ycl_ecb_style, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator. + + lo_iterator = styles->get_iterator( ). + WHILE lo_iterator->has_next( ) = abap_true. + lo_style ?= lo_iterator->get_next( ). + IF lo_style->get_guid( ) = ip_guid. + eo_style = lo_style. + RETURN. + ENDIF. + ENDWHILE. + + ENDMETHOD. + + + METHOD get_style_index_in_styles. + DATA: index TYPE i. + DATA: lo_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_style TYPE REF TO ycl_ecb_style. + + CHECK ip_guid IS NOT INITIAL. + + + lo_iterator = me->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) = 'X'. + ADD 1 TO index. + lo_style ?= lo_iterator->get_next( ). + IF lo_style->get_guid( ) = ip_guid. + ep_index = index. + EXIT. + ENDIF. + ENDWHILE. + + IF ep_index IS INITIAL. + ycx_ecb=>raise_text( 'Index not found' ). + ELSE. + SUBTRACT 1 FROM ep_index. " In excel list starts with "0" + ENDIF. + ENDMETHOD. + + + METHOD get_style_to_guid. + DATA: lo_style TYPE REF TO ycl_ecb_style. + " # issue 139 + READ TABLE me->t_stylemapping2 INTO ep_stylemapping WITH TABLE KEY guid = ip_guid. + IF sy-subrc <> 0. + ycx_ecb=>raise_text( 'GUID not found' ). + ENDIF. + + IF ep_stylemapping-dynamic_style_guid IS NOT INITIAL. + lo_style = me->get_style_from_guid( ip_guid ). + ycl_ecb_common=>recursive_class_to_struct( EXPORTING i_source = lo_style + CHANGING e_target = ep_stylemapping-complete_style + e_targetx = ep_stylemapping-complete_stylex ). + ENDIF. + ENDMETHOD. + + + METHOD get_theme. + eo_theme = theme. + ENDMETHOD. + + + METHOD get_worksheets_iterator. + + eo_iterator = me->worksheets->get_iterator( ). + + ENDMETHOD. + + + METHOD get_worksheets_name. + + ep_name = me->worksheets->name. + + ENDMETHOD. + + + METHOD get_worksheets_size. + + ep_size = me->worksheets->size( ). + + ENDMETHOD. + + + METHOD get_worksheet_by_index. + + + DATA: lv_index TYPE yecb_active_worksheet. + + lv_index = iv_index. + eo_worksheet = me->worksheets->get( lv_index ). + + ENDMETHOD. + + + METHOD get_worksheet_by_name. + + DATA: lv_index TYPE yecb_active_worksheet, + l_size TYPE i. + + l_size = get_worksheets_size( ). + + DO l_size TIMES. + lv_index = sy-index. + eo_worksheet = me->worksheets->get( lv_index ). + IF eo_worksheet->get_title( ) = ip_sheet_name. + RETURN. + ENDIF. + ENDDO. + + CLEAR eo_worksheet. + + ENDMETHOD. + + + METHOD set_active_sheet_index. + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lv_errormessage TYPE string. + +*--------------------------------------------------------------------* +* Check whether worksheet exists +*--------------------------------------------------------------------* + lo_worksheet = me->get_worksheet_by_index( i_active_worksheet ). + IF lo_worksheet IS NOT BOUND. + lv_errormessage = 'Worksheet not existing'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + + me->worksheets->active_worksheet = i_active_worksheet. + + ENDMETHOD. + + + METHOD set_active_sheet_index_by_name. + + DATA: ws_it TYPE REF TO ycl_ecb_collection_iterator, + ws TYPE REF TO ycl_ecb_worksheet, + lv_title TYPE yecb_sheet_title, + count TYPE i VALUE 1. + + ws_it = me->worksheets->get_iterator( ). + + WHILE ws_it->has_next( ) = abap_true. + ws ?= ws_it->get_next( ). + lv_title = ws->get_title( ). + IF lv_title = i_worksheet_name. + me->worksheets->active_worksheet = count. + EXIT. + ENDIF. + count = count + 1. + ENDWHILE. + + ENDMETHOD. + + + METHOD set_default_style. + me->default_style = ip_style. + ENDMETHOD. + + + METHOD set_theme. + theme = io_theme. + ENDMETHOD. + + + METHOD stylemapping_dynamic_style. + " # issue 139 + eo_style2-dynamic_style_guid = ip_style->get_guid( ). + eo_style2-guid = eo_style2-dynamic_style_guid. + eo_style2-added_to_iterator = abap_true. + +* don't care about attributes here, since this data may change +* dynamically + + ENDMETHOD. + + + METHOD yif_ecb_book_properties~initialize. + DATA: lv_timestamp TYPE timestampl. + + me->yif_ecb_book_properties~application = 'Microsoft Excel'. + me->yif_ecb_book_properties~appversion = '12.0000'. + + GET TIME STAMP FIELD lv_timestamp. + me->yif_ecb_book_properties~created = lv_timestamp. + me->yif_ecb_book_properties~creator = sy-uname. + me->yif_ecb_book_properties~description = ycl_ecb=>version. + me->yif_ecb_book_properties~modified = lv_timestamp. + me->yif_ecb_book_properties~lastmodifiedby = sy-uname. + ENDMETHOD. + + + METHOD yif_ecb_book_protection~initialize. + me->yif_ecb_book_protection~protected = yif_ecb_book_protection=>c_unprotected. + me->yif_ecb_book_protection~lockrevision = yif_ecb_book_protection=>c_unlocked. + me->yif_ecb_book_protection~lockstructure = yif_ecb_book_protection=>c_unlocked. + me->yif_ecb_book_protection~lockwindows = yif_ecb_book_protection=>c_unlocked. + CLEAR me->yif_ecb_book_protection~workbookpassword. + CLEAR me->yif_ecb_book_protection~revisionspassword. + ENDMETHOD. + + + METHOD yif_ecb_book_vba_project~set_codename. + me->yif_ecb_book_vba_project~codename = ip_codename. + ENDMETHOD. + + + METHOD yif_ecb_book_vba_project~set_codename_pr. + me->yif_ecb_book_vba_project~codename_pr = ip_codename_pr. + ENDMETHOD. + + + METHOD yif_ecb_book_vba_project~set_vbaproject. + me->yif_ecb_book_vba_project~vbaproject = ip_vbaproject. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb.clas.testclasses.abap new file mode 100644 index 0000000..a0c080e --- /dev/null +++ b/src/abap2xlsx/ycl_ecb.clas.testclasses.abap @@ -0,0 +1,100 @@ +CLASS zcl_tc_excel DEFINITION DEFERRED. +CLASS ycl_ecb DEFINITION LOCAL FRIENDS zcl_tc_excel. + +*----------------------------------------------------------------------* +* CLASS zcl_Tc_Excel DEFINITION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS zcl_tc_excel DEFINITION FOR TESTING + DURATION SHORT + RISK LEVEL HARMLESS +. +*? +*? +*? +*?zcl_Tc_Excel +*? +*?f_Cut +*? +*?ZCL_EXCEL +*? +*? +*?X +*? +*?X +*? +*?X +*? +*?X +*? +*? +*? +*? + PRIVATE SECTION. +* ================ + DATA: + f_cut TYPE REF TO ycl_ecb. "class under test + + CLASS-METHODS: class_setup. + CLASS-METHODS: class_teardown. + METHODS: setup. + METHODS: teardown. + METHODS: create_empty_excel FOR TESTING. + +ENDCLASS. "zcl_Tc_Excel + + +*----------------------------------------------------------------------* +* CLASS zcl_Tc_Excel IMPLEMENTATION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS zcl_tc_excel IMPLEMENTATION. +* ================================== + + METHOD class_setup. +* =================== + + + ENDMETHOD. "class_Setup + + + METHOD class_teardown. +* ====================== + + + ENDMETHOD. "class_Teardown + + + METHOD setup. +* ============= + + CREATE OBJECT f_cut. + ENDMETHOD. "setup + + + METHOD teardown. +* ================ + + + ENDMETHOD. "teardown + +*// START TEST METHODS + + METHOD create_empty_excel. +* ================================== + + DATA: lv_count TYPE i. + lv_count = f_cut->get_worksheets_size( ). + + cl_abap_unit_assert=>assert_equals( act = lv_count + exp = 1 + msg = 'Testing number of sheet' + level = if_aunit_constants=>tolerable ). + ENDMETHOD. "create_empty_excel + +*// END TEST METHODS + + +ENDCLASS. "zcl_Tc_Excel diff --git a/src/abap2xlsx/ycl_ecb.clas.xml b/src/abap2xlsx/ycl_ecb.clas.xml new file mode 100644 index 0000000..7054e31 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb.clas.xml @@ -0,0 +1,448 @@ + + + + + + YCL_ECB + E + Excel creator + 1 + X + X + X + X + + + + I + 001 + Worksheet not existing + 30 + + + I + 002 + Deleting last remaining worksheet is not allowed + 60 + + + + + ADD_NEW_AUTOFILTER + E + Create a new autofilter + + + ADD_NEW_AUTOFILTER + I + Create a new autofilter + + + ADD_NEW_DRAWING + E + Create a new drawing + + + ADD_NEW_DRAWING + I + Create a new drawing + + + ADD_NEW_RANGE + E + Create a new range + + + ADD_NEW_RANGE + I + Create a new range + + + ADD_NEW_STYLE + E + Create a new style + + + ADD_NEW_STYLE + I + Create a new style + + + ADD_NEW_WORKSHEET + E + Create a new worksheet + + + ADD_NEW_WORKSHEET + I + Create a new worksheet + + + ADD_STATIC_STYLES + E + Add static styles to styles iterator + + + ADD_STATIC_STYLES + I + Add static styles to styles iterator + + + AUTOFILTERS + E + Autofilters collection + + + AUTOFILTERS + I + Autofilters collection + + + CHARTS + E + Charts collection + + + CHARTS + I + Charts collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + DEFAULT_STYLE + E + Style identifier + + + DEFAULT_STYLE + I + Style identifier + + + DELETE_WORKSHEET + E + Delete worksheet + + + DELETE_WORKSHEET_BY_INDEX + E + Delete worksheet by index + + + DELETE_WORKSHEET_BY_NAME + E + Delete worksheet by name + + + DRAWINGS + E + Drawings collection + + + DRAWINGS + I + Worksheets collection + + + GET_ACTIVE_SHEET_INDEX + E + Get active worksheet index + + + GET_ACTIVE_SHEET_INDEX + I + Get active worksheet index + + + GET_ACTIVE_WORKSHEET + E + Get active worksheet + + + GET_ACTIVE_WORKSHEET + I + Get active worksheet + + + GET_AUTOFILTERS_REFERENCE + E + Get filter reference + + + GET_AUTOFILTERS_REFERENCE + I + Get filter reference + + + GET_DEFAULT_STYLE + E + Get default style + + + GET_DEFAULT_STYLE + I + Get default style + + + GET_DRAWINGS_ITERATOR + E + Get drawing iterator + + + GET_DRAWINGS_ITERATOR + I + Get drawing iterator + + + GET_NEXT_TABLE_ID + E + Get table ID unique across sheets + + + GET_NEXT_TABLE_ID + I + Get table ID unique across sheets + + + GET_RANGES_ITERATOR + E + Get ranges iterator + + + GET_RANGES_ITERATOR + I + Get ranges iterator + + + GET_STATIC_CELLSTYLE_GUID + E + Get GUID for static cellstyle + + + GET_STATIC_CELLSTYLE_GUID + I + Get GUID for static cellstyle + + + GET_STYLES_ITERATOR + E + Get styles iterator + + + GET_STYLES_ITERATOR + I + Get styles iterator + + + GET_STYLE_FROM_GUID + E + Return a style object from a GUID + + + GET_STYLE_INDEX_IN_STYLES + E + Get index of style in styles + + + GET_STYLE_INDEX_IN_STYLES + I + Get index of style in styles + + + GET_STYLE_TO_GUID + E + Get style(structure) for guid + + + GET_STYLE_TO_GUID + I + Get style(structure) for guid + + + GET_THEME + E + Gets theme + + + GET_WORKSHEETS_ITERATOR + E + Get worksheets iterator + + + GET_WORKSHEETS_ITERATOR + I + Get worksheets iterator + + + GET_WORKSHEETS_NAME + E + Returns the name of worksheets + + + GET_WORKSHEETS_NAME + I + Returns the name of worksheets + + + GET_WORKSHEETS_SIZE + E + Returns the number of worksheets + + + GET_WORKSHEETS_SIZE + I + Returns the number of worksheets + + + GET_WORKSHEET_BY_INDEX + E + Get worksheet by index + + + GET_WORKSHEET_BY_NAME + E + Get worksheet by name + + + GET_WORKSHEET_BY_NAME + I + Get worksheet by name + + + RANGES + E + Ranges collection + + + RANGES + I + Ranges collection + + + SECURITY + E + Security + + + SECURITY + I + Security + + + SET_ACTIVE_SHEET_INDEX + E + Set active worksheet index + + + SET_ACTIVE_SHEET_INDEX + I + Set active worksheet index + + + SET_ACTIVE_SHEET_INDEX_BY_NAME + E + Set active worksheet index by name + + + SET_ACTIVE_SHEET_INDEX_BY_NAME + I + Set active worksheet index by name + + + SET_DEFAULT_STYLE + E + Set default style + + + SET_DEFAULT_STYLE + I + Set default style + + + SET_THEME + E + Sets theme + + + STYLEMAPPING_DYNAMIC_STYLE + E + Convert dynamic style to static styleentry + + + STYLEMAPPING_DYNAMIC_STYLE + I + Convert dynamic style to static stlyeentry + + + STYLES + E + Styles collection + + + STYLES + I + Styles collection + + + THEME + E + Theme + + + T_STYLEMAPPING1 + E + Stylemapping: Values -> GUID + + + T_STYLEMAPPING1 + I + Stylemapping: Values -> GUID + + + T_STYLEMAPPING2 + E + Stylemapping: GUID -> Values + + + T_STYLEMAPPING2 + I + Stylemapping: GUID -> Values + + + USE_TEMPLATE + E + Checkbox + + + USE_TEMPLATE + I + Checkbox + + + VERSION + E + abap2xlsx version + + + WORKSHEETS + E + Worksheets collection + + + WORKSHEETS + I + Worksheets collection + + + + + diff --git a/src/abap2xlsx/ycl_ecb_autofilter.clas.abap b/src/abap2xlsx/ycl_ecb_autofilter.clas.abap new file mode 100644 index 0000000..b23837c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_autofilter.clas.abap @@ -0,0 +1,440 @@ +CLASS ycl_ecb_autofilter DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_AUTOFILTER +*"* do not include other source files here!!! + PUBLIC SECTION. + + TYPES tv_filter_rule TYPE string . + TYPES tv_logical_operator TYPE c LENGTH 3 . + TYPES: + BEGIN OF ts_filter, + column TYPE yecb_cell_column, + rule TYPE tv_filter_rule, + t_values TYPE HASHED TABLE OF yecb_cell_value WITH UNIQUE KEY table_line, + tr_textfilter1 TYPE RANGE OF string, + logical_operator TYPE tv_logical_operator, + tr_textfilter2 TYPE RANGE OF string, + END OF ts_filter . + TYPES: + tt_filters TYPE HASHED TABLE OF ts_filter WITH UNIQUE KEY column . + + DATA filter_area TYPE yecb_s_autofilter_area . + CONSTANTS mc_filter_rule_single_values TYPE tv_filter_rule VALUE 'single_values'. "#EC NOTEXT + CONSTANTS mc_filter_rule_text_pattern TYPE tv_filter_rule VALUE 'text_pattern'. "#EC NOTEXT + CONSTANTS mc_logical_operator_and TYPE tv_logical_operator VALUE 'and'. "#EC NOTEXT + CONSTANTS mc_logical_operator_none TYPE tv_logical_operator VALUE space. "#EC NOTEXT + CONSTANTS mc_logical_operator_or TYPE tv_logical_operator VALUE 'or'. "#EC NOTEXT + + METHODS constructor + IMPORTING + !io_sheet TYPE REF TO ycl_ecb_worksheet . + METHODS get_filter_area + RETURNING + VALUE(rs_area) TYPE yecb_s_autofilter_area + RAISING + ycx_ecb . + METHODS get_filter_range + RETURNING + VALUE(r_range) TYPE yecb_cell_value + RAISING + ycx_ecb. + METHODS get_filter_reference + RETURNING + VALUE(r_ref) TYPE yecb_range_value + RAISING + ycx_ecb . + METHODS get_values + RETURNING + VALUE(rt_filter) TYPE yecb_t_autofilter_values . + METHODS is_row_hidden + IMPORTING + !iv_row TYPE yecb_cell_row + RETURNING + VALUE(rv_is_hidden) TYPE abap_bool . + METHODS set_filter_area + IMPORTING + !is_area TYPE yecb_s_autofilter_area . + METHODS set_text_filter + IMPORTING + !i_column TYPE yecb_cell_column + !iv_textfilter1 TYPE clike + !iv_logical_operator TYPE tv_logical_operator DEFAULT mc_logical_operator_none + !iv_textfilter2 TYPE clike OPTIONAL . + METHODS set_value + IMPORTING + !i_column TYPE yecb_cell_column + !i_value TYPE yecb_cell_value . + METHODS set_values + IMPORTING + !it_values TYPE yecb_t_autofilter_values . +*"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! + PROTECTED SECTION. + + METHODS get_column_filter + IMPORTING + !i_column TYPE yecb_cell_column + RETURNING + VALUE(rr_filter) TYPE REF TO ts_filter . + METHODS is_row_hidden_single_values + IMPORTING + !iv_row TYPE yecb_cell_row + !iv_col TYPE yecb_cell_column + !is_filter TYPE ts_filter + RETURNING + VALUE(rv_is_hidden) TYPE abap_bool . + METHODS is_row_hidden_text_pattern + IMPORTING + !iv_row TYPE yecb_cell_row + !iv_col TYPE yecb_cell_column + !is_filter TYPE ts_filter + RETURNING + VALUE(rv_is_hidden) TYPE abap_bool . +*"* private components of class ZCL_EXCEL_AUTOFILTER +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA worksheet TYPE REF TO ycl_ecb_worksheet . + DATA mt_filters TYPE tt_filters . + + METHODS validate_area + RAISING + ycx_ecb . +ENDCLASS. + + + +CLASS ycl_ecb_autofilter IMPLEMENTATION. + + + METHOD constructor. + worksheet = io_sheet. + ENDMETHOD. + + + METHOD get_column_filter. + + DATA: ls_filter LIKE LINE OF me->mt_filters. + + READ TABLE me->mt_filters REFERENCE INTO rr_filter WITH TABLE KEY column = i_column. + IF sy-subrc <> 0. + ls_filter-column = i_column. + INSERT ls_filter INTO TABLE me->mt_filters REFERENCE INTO rr_filter. + ENDIF. + + ENDMETHOD. + + + METHOD get_filter_area. + + validate_area( ). + + rs_area = filter_area. + + ENDMETHOD. + + + METHOD get_filter_range. + DATA: l_row_start_c TYPE string, + l_row_end_c TYPE string, + l_col_start_c TYPE string, + l_col_end_c TYPE string. + + validate_area( ). + + l_row_end_c = filter_area-row_end. + CONDENSE l_row_end_c NO-GAPS. + + l_row_start_c = filter_area-row_start. + CONDENSE l_row_start_c NO-GAPS. + + l_col_start_c = ycl_ecb_common=>convert_column2alpha( ip_column = filter_area-col_start ) . + l_col_end_c = ycl_ecb_common=>convert_column2alpha( ip_column = filter_area-col_end ) . + + CONCATENATE l_col_start_c l_row_start_c ':' l_col_end_c l_row_end_c INTO r_range. + + ENDMETHOD. + + + METHOD get_filter_reference. + DATA: l_row_start_c TYPE string, + l_row_end_c TYPE string, + l_col_start_c TYPE string, + l_col_end_c TYPE string, + l_value TYPE string. + + validate_area( ). + + l_row_end_c = filter_area-row_end. + CONDENSE l_row_end_c NO-GAPS. + + l_row_start_c = filter_area-row_start. + CONDENSE l_row_start_c NO-GAPS. + + l_col_start_c = ycl_ecb_common=>convert_column2alpha( ip_column = filter_area-col_start ) . + l_col_end_c = ycl_ecb_common=>convert_column2alpha( ip_column = filter_area-col_end ) . + l_value = worksheet->get_title( ) . + + r_ref = ycl_ecb_common=>escape_string( ip_value = l_value ). + + CONCATENATE r_ref '!$' l_col_start_c '$' l_row_start_c ':$' l_col_end_c '$' l_row_end_c INTO r_ref. + + ENDMETHOD. + + + METHOD get_values. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_filters, + LIKE LINE OF -t_values. + + DATA: ls_filter LIKE LINE OF rt_filter. + + LOOP AT me->mt_filters ASSIGNING WHERE rule = mc_filter_rule_single_values. + + ls_filter-column = -column. + LOOP AT -t_values ASSIGNING . + ls_filter-value = . + APPEND ls_filter TO rt_filter. + ENDLOOP. + + ENDLOOP. + + ENDMETHOD. + + + METHOD is_row_hidden. + + + DATA: lr_filter TYPE REF TO ts_filter, + lv_col TYPE i. + + FIELD-SYMBOLS: TYPE ts_filter. + + rv_is_hidden = abap_false. + +*--------------------------------------------------------------------* +* 1st row of filter area is never hidden, because here the filter +* symbol is being shown +*--------------------------------------------------------------------* + IF iv_row = me->filter_area-row_start. + RETURN. + ENDIF. + + + lv_col = me->filter_area-col_start. + + + WHILE lv_col <= me->filter_area-col_end. + + lr_filter = me->get_column_filter( lv_col ). + ASSIGN lr_filter->* TO . + + CASE -rule. + + WHEN mc_filter_rule_single_values. + rv_is_hidden = me->is_row_hidden_single_values( iv_row = iv_row + iv_col = lv_col + is_filter = ). + + WHEN mc_filter_rule_text_pattern. + rv_is_hidden = me->is_row_hidden_text_pattern( iv_row = iv_row + iv_col = lv_col + is_filter = ). + + ENDCASE. + + IF rv_is_hidden = abap_true. + RETURN. + ENDIF. + + + ADD 1 TO lv_col. + + ENDWHILE. + + + ENDMETHOD. + + + METHOD is_row_hidden_single_values. + + + DATA: lv_value TYPE string. + + FIELD-SYMBOLS: LIKE LINE OF me->worksheet->sheet_content. + + rv_is_hidden = abap_false. " Default setting is NOT HIDDEN = is in filter range + +*--------------------------------------------------------------------* +* No filter values --> only symbol should be shown but nothing is being hidden +*--------------------------------------------------------------------* + IF is_filter-t_values IS INITIAL. + RETURN. + ENDIF. + +*--------------------------------------------------------------------* +* Get value of cell +*--------------------------------------------------------------------* + READ TABLE me->worksheet->sheet_content ASSIGNING WITH TABLE KEY cell_row = iv_row + cell_column = iv_col. + IF sy-subrc = 0. + lv_value = -cell_value. + ELSE. + CLEAR lv_value. + ENDIF. + +*--------------------------------------------------------------------* +* Check whether it is affected by filter +* this needs to be extended if we support other filtertypes +* other than single values +*--------------------------------------------------------------------* + READ TABLE is_filter-t_values TRANSPORTING NO FIELDS WITH TABLE KEY table_line = lv_value. + IF sy-subrc <> 0. + rv_is_hidden = abap_true. + ENDIF. + + ENDMETHOD. + + + METHOD is_row_hidden_text_pattern. + + + + DATA: lv_value TYPE string. + + FIELD-SYMBOLS: LIKE LINE OF me->worksheet->sheet_content. + + rv_is_hidden = abap_false. " Default setting is NOT HIDDEN = is in filter range + +*--------------------------------------------------------------------* +* Get value of cell +*--------------------------------------------------------------------* + READ TABLE me->worksheet->sheet_content ASSIGNING WITH TABLE KEY cell_row = iv_row + cell_column = iv_col. + IF sy-subrc = 0. + lv_value = -cell_value. + ELSE. + CLEAR lv_value. + ENDIF. + +*--------------------------------------------------------------------* +* Check whether it is affected by filter +* this needs to be extended if we support other filtertypes +* other than single values +*--------------------------------------------------------------------* + IF lv_value NOT IN is_filter-tr_textfilter1. + rv_is_hidden = abap_true. + ENDIF. + + ENDMETHOD. + + + METHOD set_filter_area. + + filter_area = is_area. + + ENDMETHOD. + + + METHOD set_text_filter. +* see method documentation how to use this + + DATA: lr_filter TYPE REF TO ts_filter, + ls_value1 TYPE LINE OF ts_filter-tr_textfilter1. + + FIELD-SYMBOLS: TYPE ts_filter. + + + lr_filter = me->get_column_filter( i_column ). + ASSIGN lr_filter->* TO . + + -rule = mc_filter_rule_text_pattern. + CLEAR -tr_textfilter1. + + IF iv_textfilter1 CA '*+'. " Pattern + ls_value1-sign = 'I'. + ls_value1-option = 'CP'. + ls_value1-low = iv_textfilter1. + ELSE. + ls_value1-sign = 'I'. + ls_value1-option = 'EQ'. + ls_value1-low = iv_textfilter1. + ENDIF. + APPEND ls_value1 TO -tr_textfilter1. + + ENDMETHOD. + + + METHOD set_value. + + DATA: lr_filter TYPE REF TO ts_filter. + + FIELD-SYMBOLS: TYPE ts_filter. + + + lr_filter = me->get_column_filter( i_column ). + ASSIGN lr_filter->* TO . + + -rule = mc_filter_rule_single_values. + + INSERT i_value INTO TABLE -t_values. + + ENDMETHOD. + + + METHOD set_values. + + FIELD-SYMBOLS: LIKE LINE OF it_values. + + LOOP AT it_values ASSIGNING . + + me->set_value( i_column = -column + i_value = -value ). + + ENDLOOP. + + ENDMETHOD. + + + METHOD validate_area. + DATA: l_col TYPE yecb_cell_column, + ls_original_filter_area TYPE yecb_s_autofilter_area, + l_row TYPE yecb_cell_row. + + l_row = worksheet->get_highest_row( ) . + l_col = worksheet->get_highest_column( ) . + + IF filter_area IS INITIAL. + filter_area-row_start = 1. + filter_area-col_start = 1. + filter_area-row_end = l_row . + filter_area-col_end = l_col . + ENDIF. + + IF filter_area-row_start > filter_area-row_end. + ls_original_filter_area = filter_area. + filter_area-row_start = ls_original_filter_area-row_end. + filter_area-row_end = ls_original_filter_area-row_start. + ENDIF. + IF filter_area-row_start < 1. + filter_area-row_start = 1. + ENDIF. + IF filter_area-col_start < 1. + filter_area-col_start = 1. + ENDIF. + IF filter_area-row_end > l_row OR + filter_area-row_end < 1. + filter_area-row_end = l_row. + ENDIF. + IF filter_area-col_end > l_col OR + filter_area-col_end < 1. + filter_area-col_end = l_col. + ENDIF. + IF filter_area-col_start > filter_area-col_end. + filter_area-col_start = filter_area-col_end. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_autofilter.clas.xml b/src/abap2xlsx/ycl_ecb_autofilter.clas.xml new file mode 100644 index 0000000..459ac48 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_autofilter.clas.xml @@ -0,0 +1,203 @@ + + + + + + YCL_ECB_AUTOFILTER + E + Autofilter + 1 + X + X + X + + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + FILTER_AREA + E + Autofilter area ( rows and columns ) + + + FILTER_AREA + I + Autofilter area ( rows and columns ) + + + GET_COLUMN_FILTER + E + Get filter for column + + + GET_FILTER_AREA + E + Get filter area for filter + + + GET_FILTER_AREA + I + Get filter area for filter + + + GET_FILTER_RANGE + E + Get Filter range for filter + + + GET_FILTER_RANGE + I + Get Filter range for filter + + + GET_FILTER_REFERENCE + E + Get filter reference for filter + + + GET_FILTER_REFERENCE + I + Get filter reference for filter + + + GET_VALUES + E + Get filter values table + + + GET_VALUES + I + Get filter values table + + + IS_ROW_HIDDEN + E + Is cellrow hidden by this autofilter + + + IS_ROW_HIDDEN_SINGLE_VALUES + E + Is cellrow hidden by this autofilter if rule single values + + + IS_ROW_HIDDEN_TEXT_PATTERN + E + Is cellrow hidden by this autofilter if rule text pattern + + + MC_FILTER_RULE_SINGLE_VALUES + E + Standard filter for single values + + + MC_FILTER_RULE_TEXT_PATTERN + E + Standard filter for single values + + + MC_LOGICAL_OPERATOR_AND + E + logical operator to be used in set_xxxxx_pattern + + + MC_LOGICAL_OPERATOR_NONE + E + logical operator to be used in set_xxxxx_pattern + + + MC_LOGICAL_OPERATOR_OR + E + logical operator to be used in set_xxxxx_pattern + + + MT_FILTERS + E + All textfilters + + + SET_FILTER_AREA + E + Set filter area for filter + + + SET_FILTER_AREA + I + Set filter area for filter + + + SET_TEXT_FILTER + E + Set filter by text pattern - see method documentation + + + SET_VALUE + E + Set Filter value + + + SET_VALUE + I + Set Filter value + + + SET_VALUES + E + Set Filter values with table + + + SET_VALUES + I + Set Filter values with table + + + TS_FILTER + E + Filter + + + TT_FILTERS + E + All filters + + + TV_FILTER_RULE + E + Filter rule + + + TV_LOGICAL_OPERATOR + E + logical operator to be used in set_xxxxx_pattern + + + VALIDATE_AREA + E + Validates filter area + + + VALIDATE_AREA + I + Validates filter area + + + WORKSHEET + E + Worksheet + + + WORKSHEET + I + Worksheet + + + + + diff --git a/src/abap2xlsx/ycl_ecb_autofilters.clas.abap b/src/abap2xlsx/ycl_ecb_autofilters.clas.abap new file mode 100644 index 0000000..6e1eada --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_autofilters.clas.abap @@ -0,0 +1,120 @@ +CLASS ycl_ecb_autofilters DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_AUTOFILTERS +*"* do not include other source files here!!! + + CONSTANTS c_autofilter TYPE string VALUE '_xlnm._FilterDatabase'. "#EC NOTEXT + + METHODS add + IMPORTING + !io_sheet TYPE REF TO ycl_ecb_worksheet + RETURNING + VALUE(ro_autofilter) TYPE REF TO ycl_ecb_autofilter + RAISING + ycx_ecb . + METHODS clear . + METHODS get + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RETURNING + VALUE(ro_autofilter) TYPE REF TO ycl_ecb_autofilter . + METHODS is_empty + RETURNING + VALUE(r_empty) TYPE flag . + METHODS remove + IMPORTING + !io_sheet TYPE any . + METHODS size + RETURNING + VALUE(r_size) TYPE i . +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + TYPES: + BEGIN OF ts_autofilter, + worksheet TYPE REF TO ycl_ecb_worksheet, + autofilter TYPE REF TO ycl_ecb_autofilter, + END OF ts_autofilter . + TYPES: + tt_autofilters TYPE HASHED TABLE OF ts_autofilter WITH UNIQUE KEY worksheet . + + DATA mt_autofilters TYPE tt_autofilters . +ENDCLASS. + + + +CLASS ycl_ecb_autofilters IMPLEMENTATION. + + + METHOD add. + + DATA: ls_autofilter LIKE LINE OF me->mt_autofilters. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_autofilters. + + READ TABLE me->mt_autofilters ASSIGNING WITH TABLE KEY worksheet = io_sheet. + IF sy-subrc = 0. + RAISE EXCEPTION TYPE ycx_ecb. " adding another autofilter to sheet is not allowed + ENDIF. + + CREATE OBJECT ro_autofilter + EXPORTING + io_sheet = io_sheet. + + ls_autofilter-worksheet = io_sheet. + ls_autofilter-autofilter = ro_autofilter. + INSERT ls_autofilter INTO TABLE me->mt_autofilters. + + + ENDMETHOD. + + + METHOD clear. + + CLEAR me->mt_autofilters. + + ENDMETHOD. + + + METHOD get. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_autofilters. + + READ TABLE me->mt_autofilters ASSIGNING WITH TABLE KEY worksheet = io_worksheet. + IF sy-subrc = 0. + ro_autofilter = -autofilter. + ELSE. + CLEAR ro_autofilter. + ENDIF. + + ENDMETHOD. + + + METHOD is_empty. + IF me->mt_autofilters IS INITIAL. + r_empty = abap_true. + ENDIF. + ENDMETHOD. + + + METHOD remove. + + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet. + + DELETE TABLE me->mt_autofilters WITH TABLE KEY worksheet = lo_worksheet. + + ENDMETHOD. + + + METHOD size. + DESCRIBE TABLE me->mt_autofilters LINES r_size. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_autofilters.clas.xml b/src/abap2xlsx/ycl_ecb_autofilters.clas.xml new file mode 100644 index 0000000..dedf5d9 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_autofilters.clas.xml @@ -0,0 +1,103 @@ + + + + + + YCL_ECB_AUTOFILTERS + E + Autofilters collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + ADD + I + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CLEAR + I + Initializes the Collection + + + C_AUTOFILTER + E + Excel Autofilter range name + + + C_AUTOFILTER + I + Excel Autofilter range name + + + GET + E + Gets Element + + + GET + I + Gets Element + + + IS_EMPTY + E + Checks whether elements are contained + + + IS_EMPTY + I + Checks whether elements are contained + + + MT_AUTOFILTERS + E + All autofilters + + + REMOVE + E + Deletes an Element from the Collection + + + REMOVE + I + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + SIZE + I + Specifies number of contained elements + + + TS_AUTOFILTER + E + Autofilter + + + TT_AUTOFILTERS + E + All autofilters + + + + + diff --git a/src/abap2xlsx/ycl_ecb_collection.clas.abap b/src/abap2xlsx/ycl_ecb_collection.clas.abap new file mode 100644 index 0000000..8424617 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_collection.clas.abap @@ -0,0 +1,84 @@ +CLASS ycl_ecb_collection DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: + ty_collection TYPE STANDARD TABLE OF REF TO object . + + DATA collection TYPE ty_collection READ-ONLY . + + METHODS size + RETURNING + VALUE(size) TYPE i . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE abap_bool . + METHODS get + IMPORTING + !index TYPE i + RETURNING + VALUE(object) TYPE REF TO object . + METHODS get_iterator + RETURNING + VALUE(iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS add + IMPORTING + !element TYPE REF TO object . + METHODS remove + IMPORTING + !element TYPE REF TO object . + METHODS clear . + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_collection IMPLEMENTATION. + + + METHOD add . + APPEND element TO collection. + ENDMETHOD. + + + METHOD clear . + CLEAR collection. + ENDMETHOD. + + + METHOD get . + READ TABLE collection INDEX index INTO object. + ENDMETHOD. + + + METHOD get_iterator . + CREATE OBJECT iterator + EXPORTING + collection = me. + ENDMETHOD. + + + METHOD is_empty. + is_empty = boolc( size( ) = 0 ). + ENDMETHOD. + + + METHOD remove . + DATA obj TYPE REF TO object. + LOOP AT collection INTO obj. + IF obj = element. + DELETE collection. + RETURN. + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD size. + size = lines( collection ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_collection.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_collection.clas.testclasses.abap new file mode 100644 index 0000000..90ff9b2 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_collection.clas.testclasses.abap @@ -0,0 +1,37 @@ +CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. + + PRIVATE SECTION. + METHODS test01 FOR TESTING RAISING cx_static_check. +ENDCLASS. + + +CLASS ltcl_test IMPLEMENTATION. + + METHOD test01. + + DATA lo_collection TYPE REF TO ycl_ecb_collection. + + CREATE OBJECT lo_collection. + + cl_abap_unit_assert=>assert_equals( + act = lo_collection->size( ) + exp = 0 ). + + cl_abap_unit_assert=>assert_equals( + act = lo_collection->is_empty( ) + exp = abap_true ). + +* heh, yea, add the collection to itself :) + lo_collection->add( lo_collection ). + + cl_abap_unit_assert=>assert_equals( + act = lo_collection->size( ) + exp = 1 ). + + cl_abap_unit_assert=>assert_equals( + act = lo_collection->is_empty( ) + exp = abap_false ). + + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_collection.clas.xml b/src/abap2xlsx/ycl_ecb_collection.clas.xml new file mode 100644 index 0000000..3419877 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_collection.clas.xml @@ -0,0 +1,17 @@ + + + + + + YCL_ECB_COLLECTION + E + abap2xlsx - Object Collection + 1 + X + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_collection_iterator.clas.abap b/src/abap2xlsx/ycl_ecb_collection_iterator.clas.abap new file mode 100644 index 0000000..5af3fed --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_collection_iterator.clas.abap @@ -0,0 +1,52 @@ +CLASS ycl_ecb_collection_iterator DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + METHODS get_index + RETURNING + VALUE(index) TYPE i. + METHODS has_next + RETURNING + VALUE(has_next) TYPE abap_bool. + METHODS get_next + RETURNING + VALUE(object) TYPE REF TO object. + METHODS constructor + IMPORTING + collection TYPE REF TO ycl_ecb_collection. + PROTECTED SECTION. + PRIVATE SECTION. + DATA index TYPE i VALUE 0. + DATA collection TYPE REF TO ycl_ecb_collection. +ENDCLASS. + + + +CLASS ycl_ecb_collection_iterator IMPLEMENTATION. + + + METHOD constructor . + me->collection = collection. + ENDMETHOD. + + + METHOD get_index . + index = me->index. + ENDMETHOD. + + + METHOD get_next . + DATA obj TYPE REF TO object. + index = index + 1. + object = collection->get( index ). + ENDMETHOD. + + + METHOD has_next. + DATA obj TYPE REF TO object. + obj = collection->get( index + 1 ). + has_next = boolc( obj IS NOT INITIAL ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_collection_iterator.clas.xml b/src/abap2xlsx/ycl_ecb_collection_iterator.clas.xml new file mode 100644 index 0000000..af95f44 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_collection_iterator.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_COLLECTION_ITERATOR + E + abap2xlsx - Object Iterator + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_column.clas.abap b/src/abap2xlsx/ycl_ecb_column.clas.abap new file mode 100644 index 0000000..c65f18c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_column.clas.abap @@ -0,0 +1,229 @@ +CLASS ycl_ecb_column DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_COLUMN +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS constructor + IMPORTING + !ip_index TYPE yecb_cell_column_alpha + !ip_worksheet TYPE REF TO ycl_ecb_worksheet + !ip_excel TYPE REF TO ycl_ecb + RAISING + ycx_ecb . + METHODS get_auto_size + RETURNING + VALUE(r_auto_size) TYPE abap_bool . + METHODS get_collapsed + RETURNING + VALUE(r_collapsed) TYPE abap_bool . + METHODS get_column_index + RETURNING + VALUE(r_column_index) TYPE int4 . + METHODS get_outline_level + RETURNING + VALUE(r_outline_level) TYPE int4 . + METHODS get_visible + RETURNING + VALUE(r_visible) TYPE abap_bool . + METHODS get_width + RETURNING + VALUE(r_width) TYPE f . + METHODS get_xf_index + RETURNING + VALUE(r_xf_index) TYPE int4 . + METHODS set_auto_size + IMPORTING + !ip_auto_size TYPE abap_bool + RETURNING + VALUE(io_column) TYPE REF TO ycl_ecb_column . + METHODS set_collapsed + IMPORTING + !ip_collapsed TYPE abap_bool + RETURNING + VALUE(io_column) TYPE REF TO ycl_ecb_column . + METHODS set_column_index + IMPORTING + !ip_index TYPE yecb_cell_column_alpha + RETURNING + VALUE(io_column) TYPE REF TO ycl_ecb_column + RAISING + ycx_ecb . + METHODS set_outline_level + IMPORTING + !ip_outline_level TYPE int4 . + METHODS set_visible + IMPORTING + !ip_visible TYPE abap_bool + RETURNING + VALUE(io_column) TYPE REF TO ycl_ecb_column . + METHODS set_width + IMPORTING + !ip_width TYPE simple + RETURNING + VALUE(io_column) TYPE REF TO ycl_ecb_column + RAISING + ycx_ecb . + METHODS set_xf_index + IMPORTING + !ip_xf_index TYPE int4 + RETURNING + VALUE(io_column) TYPE REF TO ycl_ecb_column . + METHODS set_column_style_by_guid + IMPORTING + !ip_style_guid TYPE yecb_cell_style + RAISING + ycx_ecb . + METHODS get_column_style_guid + RETURNING + VALUE(ep_style_guid) TYPE yecb_cell_style + RAISING + ycx_ecb . +*"* protected components of class ZCL_EXCEL_COLUMN +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_COLUMN +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA column_index TYPE int4 . + DATA width TYPE f . + DATA auto_size TYPE abap_bool . + DATA visible TYPE abap_bool . + DATA outline_level TYPE int4 . + DATA collapsed TYPE abap_bool . + DATA xf_index TYPE int4 . + DATA style_guid TYPE yecb_cell_style . + DATA excel TYPE REF TO ycl_ecb . + DATA worksheet TYPE REF TO ycl_ecb_worksheet . +ENDCLASS. + + + +CLASS ycl_ecb_column IMPLEMENTATION. + + + METHOD constructor. + me->column_index = ycl_ecb_common=>convert_column2int( ip_index ). + me->width = -1. + me->auto_size = abap_false. + me->visible = abap_true. + me->outline_level = 0. + me->collapsed = abap_false. + me->excel = ip_excel. "ins issue #157 - Allow Style for columns + me->worksheet = ip_worksheet. "ins issue #157 - Allow Style for columns + + " set default index to cellXf + 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_column_style_guid. + IF me->style_guid IS NOT INITIAL. + ep_style_guid = me->style_guid. + ELSE. + ep_style_guid = me->worksheet->yif_ecb_sheet_properties~get_style( ). + ENDIF. + 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. + io_column = me. + ENDMETHOD. + + + METHOD set_collapsed. + me->collapsed = ip_collapsed. + io_column = me. + ENDMETHOD. + + + METHOD set_column_index. + me->column_index = ycl_ecb_common=>convert_column2int( ip_index ). + io_column = me. + ENDMETHOD. + + + METHOD set_column_style_by_guid. + DATA: stylemapping TYPE yecb_s_stylemapping. + + IF me->excel IS NOT BOUND. + ycx_ecb=>raise_text( 'Internal error - reference to ZCL_EXCEL not bound' ). + ENDIF. + TRY. + stylemapping = me->excel->get_style_to_guid( ip_style_guid ). + me->style_guid = stylemapping-guid. + + CATCH ycx_ecb . + RETURN. " leave as is in case of error + ENDTRY. + + ENDMETHOD. + + + METHOD set_outline_level. + me->outline_level = ip_outline_level. + ENDMETHOD. + + + METHOD set_visible. + me->visible = ip_visible. + io_column = me. + ENDMETHOD. + + + METHOD set_width. + TRY. + me->width = ip_width. + io_column = me. + CATCH cx_sy_conversion_no_number. + ycx_ecb=>raise_text( 'Unable to interpret width as number' ). + ENDTRY. + ENDMETHOD. + + + METHOD set_xf_index. + me->xf_index = ip_xf_index. + io_column = me. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_column.clas.xml b/src/abap2xlsx/ycl_ecb_column.clas.xml new file mode 100644 index 0000000..11d1c50 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_column.clas.xml @@ -0,0 +1,78 @@ + + + + + + YCL_ECB_COLUMN + E + Worksheet Column + 1 + X + X + X + + + + AUTO_SIZE + E + Auto size? + + + COLLAPSED + E + Collapsed? + + + COLUMN_INDEX + E + Column index + + + EXCEL + E + Excel creator + + + GET_COLUMN_STYLE_GUID + E + Get guid of column style + + + OUTLINE_LEVEL + E + Outline level + + + SET_COLUMN_STYLE_BY_GUID + E + Set column style by style guid + + + STYLE_GUID + E + Style identifier + + + VISIBLE + E + Visible? + + + WIDTH + E + Column width + + + WORKSHEET + E + Worksheet + + + XF_INDEX + E + Index to cellXf + + + + + diff --git a/src/abap2xlsx/ycl_ecb_columns.clas.abap b/src/abap2xlsx/ycl_ecb_columns.clas.abap new file mode 100644 index 0000000..e50ac7b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_columns.clas.abap @@ -0,0 +1,107 @@ +CLASS ycl_ecb_columns DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_COLUMNS +*"* do not include other source files here!!! + PUBLIC SECTION. + METHODS add + IMPORTING + !io_column TYPE REF TO ycl_ecb_column . + METHODS clear . + METHODS constructor . + METHODS get + IMPORTING + !ip_index TYPE i + RETURNING + VALUE(eo_column) TYPE REF TO ycl_ecb_column . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !io_column TYPE REF TO ycl_ecb_column . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! + PRIVATE SECTION. + TYPES: + BEGIN OF mty_s_hashed_column, + column_index TYPE int4, + column TYPE REF TO ycl_ecb_column, + END OF mty_s_hashed_column , + mty_ts_hashed_column TYPE HASHED TABLE OF mty_s_hashed_column WITH UNIQUE KEY column_index. + + DATA columns TYPE REF TO ycl_ecb_collection . + DATA columns_hashed TYPE mty_ts_hashed_column . +ENDCLASS. + + + +CLASS ycl_ecb_columns IMPLEMENTATION. + + + METHOD add. + DATA: ls_hashed_column TYPE mty_s_hashed_column. + + ls_hashed_column-column_index = io_column->get_column_index( ). + ls_hashed_column-column = io_column. + + INSERT ls_hashed_column INTO TABLE columns_hashed . + + columns->add( io_column ). + ENDMETHOD. + + + METHOD clear. + CLEAR columns_hashed. + columns->clear( ). + ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT columns. + + ENDMETHOD. + + + METHOD get. + FIELD-SYMBOLS: TYPE mty_s_hashed_column. + + READ TABLE columns_hashed WITH KEY column_index = ip_index ASSIGNING . + IF sy-subrc = 0. + eo_column = -column. + ENDIF. + ENDMETHOD. + + + METHOD get_iterator. + eo_iterator ?= columns->get_iterator( ). + ENDMETHOD. + + + METHOD is_empty. + is_empty = columns->is_empty( ). + ENDMETHOD. + + + METHOD remove. + DELETE TABLE columns_hashed WITH TABLE KEY column_index = io_column->get_column_index( ) . + columns->remove( io_column ). + ENDMETHOD. + + + METHOD size. + ep_size = columns->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_columns.clas.xml b/src/abap2xlsx/ycl_ecb_columns.clas.xml new file mode 100644 index 0000000..bc6e6d3 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_columns.clas.xml @@ -0,0 +1,58 @@ + + + + + + YCL_ECB_COLUMNS + E + Ranges collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + GET + E + Gets Element + + + GET_ITERATOR + E + Returns an iterator + + + IS_EMPTY + E + Checks whether elements are contained + + + REMOVE + E + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + + + diff --git a/src/abap2xlsx/ycl_ecb_comment.clas.abap b/src/abap2xlsx/ycl_ecb_comment.clas.abap new file mode 100644 index 0000000..ef03847 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_comment.clas.abap @@ -0,0 +1,70 @@ +CLASS ycl_ecb_comment DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS constructor . + METHODS get_name + RETURNING + VALUE(r_name) TYPE string . + METHODS get_index + RETURNING + VALUE(rp_index) TYPE string . + METHODS get_ref + RETURNING + VALUE(rp_ref) TYPE string . + METHODS get_text + RETURNING + VALUE(rp_text) TYPE string . + METHODS set_text + IMPORTING + !ip_text TYPE string + !ip_ref TYPE string OPTIONAL . + PROTECTED SECTION. + PRIVATE SECTION. + + DATA index TYPE string . + DATA ref TYPE string . + DATA text TYPE string . +ENDCLASS. + + + +CLASS ycl_ecb_comment IMPLEMENTATION. + + + METHOD constructor. + + ENDMETHOD. + + + METHOD get_index. + rp_index = me->index. + ENDMETHOD. + + + METHOD get_name. + + ENDMETHOD. + + + METHOD get_ref. + rp_ref = me->ref. + ENDMETHOD. + + + METHOD get_text. + rp_text = me->text. + ENDMETHOD. + + + METHOD set_text. + me->text = ip_text. + + IF ip_ref IS SUPPLIED. + me->ref = ip_ref. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_comment.clas.xml b/src/abap2xlsx/ycl_ecb_comment.clas.xml new file mode 100644 index 0000000..0109307 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_comment.clas.xml @@ -0,0 +1,58 @@ + + + + + + YCL_ECB_COMMENT + E + Comment + 1 + X + X + X + + + + CONSTRUCTOR + E + CONSTRUCTOR + + + GET_INDEX + E + Get index + + + GET_REF + E + Get reference + + + GET_TEXT + E + Get text + + + INDEX + E + Index in collection + + + REF + E + Reference to cell (eg. 'B13') + + + SET_TEXT + E + Set text + + + TEXT + E + Comment + + + + + diff --git a/src/abap2xlsx/ycl_ecb_comments.clas.abap b/src/abap2xlsx/ycl_ecb_comments.clas.abap new file mode 100644 index 0000000..9fedc51 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_comments.clas.abap @@ -0,0 +1,100 @@ +CLASS ycl_ecb_comments DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS add + IMPORTING + !ip_comment TYPE REF TO ycl_ecb_comment . + METHODS include + IMPORTING + !ip_comment TYPE REF TO ycl_ecb_comment . + METHODS clear . + METHODS constructor . + METHODS get + IMPORTING + !ip_index TYPE yecb_active_worksheet + RETURNING + VALUE(eo_comment) TYPE REF TO ycl_ecb_comment . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !ip_comment TYPE REF TO ycl_ecb_comment . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . + PROTECTED SECTION. + PRIVATE SECTION. + + DATA comments TYPE REF TO ycl_ecb_collection . +ENDCLASS. + + + +CLASS ycl_ecb_comments IMPLEMENTATION. + + + METHOD add. + DATA: lv_index TYPE i. + + comments->add( ip_comment ). + lv_index = comments->size( ). + + ENDMETHOD. + + + METHOD clear. + comments->clear( ). + + ENDMETHOD. + + + METHOD constructor. + CREATE OBJECT comments. + + ENDMETHOD. + + + METHOD get. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_comment ?= comments->get( lv_index ). + + ENDMETHOD. + + + METHOD get_iterator. + + eo_iterator ?= comments->get_iterator( ). + ENDMETHOD. + + + METHOD include. + comments->add( ip_comment ). + ENDMETHOD. + + + METHOD is_empty. + + is_empty = comments->is_empty( ). + ENDMETHOD. + + + METHOD remove. + + comments->remove( ip_comment ). + ENDMETHOD. + + + METHOD size. + + ep_size = comments->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_comments.clas.xml b/src/abap2xlsx/ycl_ecb_comments.clas.xml new file mode 100644 index 0000000..f399c11 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_comments.clas.xml @@ -0,0 +1,63 @@ + + + + + + YCL_ECB_COMMENTS + E + Comments collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + GET + E + Gets Element + + + GET_ITERATOR + E + Returns an iterator + + + INCLUDE + E + Adds an Element to the Collection + + + IS_EMPTY + E + Checks whether elements are contained + + + REMOVE + E + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + + + diff --git a/src/abap2xlsx/ycl_ecb_common.clas.abap b/src/abap2xlsx/ycl_ecb_common.clas.abap new file mode 100644 index 0000000..c25e78f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_common.clas.abap @@ -0,0 +1,1709 @@ +CLASS ycl_ecb_common DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* 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 . . . . . . . . . . . . . . . . " . + CONSTANTS c_excel_sheet_max_col TYPE int4 VALUE 16384. "#EC NOTEXT + CONSTANTS c_excel_sheet_min_col TYPE int4 VALUE 1. "#EC NOTEXT + CONSTANTS c_excel_sheet_max_row TYPE int4 VALUE 1048576. "#EC NOTEXT + CONSTANTS c_excel_sheet_min_row TYPE int4 VALUE 1. "#EC NOTEXT + CLASS-DATA c_spras_en TYPE spras VALUE 'E'. "#EC NOTEXT . . . . . . . . . . . . . . . . " . + CLASS-DATA o_conv TYPE REF TO cl_abap_conv_out_ce . + CONSTANTS c_excel_1900_leap_year TYPE d VALUE '19000228'. "#EC NOTEXT + CLASS-DATA c_xlsx_file_filter TYPE string VALUE 'Excel Workbook (*.xlsx)|*.xlsx|'. "#EC NOTEXT . . . . . . . " . + + CLASS-METHODS class_constructor . + CLASS-METHODS describe_structure + IMPORTING + !io_struct TYPE REF TO cl_abap_structdescr + RETURNING + VALUE(rt_dfies) TYPE ddfields . + CLASS-METHODS convert_column2alpha + IMPORTING + !ip_column TYPE simple + RETURNING + VALUE(ep_column) TYPE yecb_cell_column_alpha + RAISING + ycx_ecb . + CLASS-METHODS convert_column2int + IMPORTING + !ip_column TYPE simple + RETURNING + VALUE(ep_column) TYPE yecb_cell_column + RAISING + ycx_ecb . + CLASS-METHODS convert_column_a_row2columnrow + IMPORTING + !i_column TYPE simple + !i_row TYPE yecb_cell_row + RETURNING + VALUE(e_columnrow) TYPE string + RAISING + ycx_ecb. + CLASS-METHODS convert_columnrow2column_a_row + IMPORTING + !i_columnrow TYPE clike + EXPORTING + !e_column TYPE yecb_cell_column_alpha + !e_column_int TYPE yecb_cell_column + !e_row TYPE yecb_cell_row + RAISING + ycx_ecb. + CLASS-METHODS convert_range2column_a_row + IMPORTING + !i_range TYPE clike + !i_allow_1dim_range TYPE abap_bool DEFAULT abap_false + EXPORTING + !e_column_start TYPE yecb_cell_column_alpha + !e_column_start_int TYPE yecb_cell_column + !e_column_end TYPE yecb_cell_column_alpha + !e_column_end_int TYPE yecb_cell_column + !e_row_start TYPE yecb_cell_row + !e_row_end TYPE yecb_cell_row + !e_sheet TYPE clike + RAISING + ycx_ecb . + CLASS-METHODS convert_columnrow2column_o_row + IMPORTING + !i_columnrow TYPE clike + EXPORTING + !e_column TYPE yecb_cell_column_alpha + !e_row TYPE yecb_cell_row . + CLASS-METHODS clone_ixml_with_namespaces + IMPORTING + element TYPE REF TO if_ixml_element + RETURNING + VALUE(result) TYPE REF TO if_ixml_element. + CLASS-METHODS date_to_excel_string + IMPORTING + !ip_value TYPE d + RETURNING + VALUE(ep_value) TYPE yecb_cell_value . + CLASS-METHODS encrypt_password + IMPORTING + !i_pwd TYPE yecb_aes_password + RETURNING + VALUE(r_encrypted_pwd) TYPE yecb_aes_password . + CLASS-METHODS escape_string + IMPORTING + !ip_value TYPE clike + RETURNING + VALUE(ep_escaped_value) TYPE string . + CLASS-METHODS unescape_string + IMPORTING + !iv_escaped TYPE clike + RETURNING + VALUE(ev_unescaped_string) TYPE string + RAISING + ycx_ecb . + CLASS-METHODS excel_string_to_date + IMPORTING + !ip_value TYPE yecb_cell_value + RETURNING + VALUE(ep_value) TYPE d + RAISING + ycx_ecb . + CLASS-METHODS excel_string_to_time + IMPORTING + !ip_value TYPE yecb_cell_value + RETURNING + VALUE(ep_value) TYPE t + RAISING + ycx_ecb . + CLASS-METHODS excel_string_to_number + IMPORTING + !ip_value TYPE yecb_cell_value + RETURNING + VALUE(ep_value) TYPE f + RAISING + ycx_ecb . + CLASS-METHODS get_fieldcatalog + IMPORTING + !ip_table TYPE STANDARD TABLE + !iv_hide_mandt TYPE abap_bool DEFAULT abap_true + !ip_conv_exit_length TYPE abap_bool DEFAULT abap_false + RETURNING + VALUE(ep_fieldcatalog) TYPE yecb_t_fieldcatalog . + CLASS-METHODS number_to_excel_string + IMPORTING + VALUE(ip_value) TYPE numeric + ip_currency TYPE waers_curc OPTIONAL + RETURNING + VALUE(ep_value) TYPE yecb_cell_value . + CLASS-METHODS recursive_class_to_struct + IMPORTING + !i_source TYPE any + CHANGING + !e_target TYPE data + !e_targetx TYPE data . + CLASS-METHODS recursive_struct_to_class + IMPORTING + !i_source TYPE data + !i_sourcex TYPE data + CHANGING + !e_target TYPE any . + CLASS-METHODS time_to_excel_string + IMPORTING + !ip_value TYPE t + RETURNING + VALUE(ep_value) TYPE yecb_cell_value . + TYPES: t_char10 TYPE c LENGTH 10. + TYPES: t_char255 TYPE c LENGTH 255. + CLASS-METHODS split_file + IMPORTING + !ip_file TYPE t_char255 + EXPORTING + !ep_file TYPE t_char255 + !ep_extension TYPE t_char10 + !ep_dotextension TYPE t_char10 . + CLASS-METHODS calculate_cell_distance + IMPORTING + !iv_reference_cell TYPE clike + !iv_current_cell TYPE clike + EXPORTING + !ev_row_difference TYPE i + !ev_col_difference TYPE i + RAISING + ycx_ecb . + CLASS-METHODS determine_resulting_formula + IMPORTING + !iv_reference_cell TYPE clike + !iv_reference_formula TYPE clike + !iv_current_cell TYPE clike + RETURNING + VALUE(ev_resulting_formula) TYPE string + RAISING + ycx_ecb . + CLASS-METHODS shift_formula + IMPORTING + !iv_reference_formula TYPE clike + VALUE(iv_shift_cols) TYPE i + VALUE(iv_shift_rows) TYPE i + RETURNING + VALUE(ev_resulting_formula) TYPE string + RAISING + ycx_ecb . + CLASS-METHODS is_cell_in_range + IMPORTING + !ip_column TYPE simple + !ip_row TYPE yecb_cell_row + !ip_range TYPE clike + RETURNING + VALUE(rp_in_range) TYPE abap_bool + RAISING + ycx_ecb . +*"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_COMMON +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + CLASS-DATA c_excel_col_module TYPE int2 VALUE 64. "#EC NOTEXT . . . . . . . . . . . . . . . " . + CLASS-DATA sv_prev_in1 TYPE yecb_cell_column. + CLASS-DATA sv_prev_out1 TYPE yecb_cell_column_alpha. + CLASS-DATA sv_prev_in2 TYPE c LENGTH 10. + CLASS-DATA sv_prev_out2 TYPE yecb_cell_column. + CLASS-METHODS structure_case + IMPORTING + !is_component TYPE abap_componentdescr + CHANGING + !xt_components TYPE abap_component_tab . + CLASS-METHODS structure_recursive + IMPORTING + !is_component TYPE abap_componentdescr + RETURNING + VALUE(rt_components) TYPE abap_component_tab . + TYPES ty_char1 TYPE c LENGTH 1. + CLASS-METHODS char2hex + IMPORTING + !i_char TYPE ty_char1 + RETURNING + VALUE(r_hex) TYPE yecb_pwd_hash . + CLASS-METHODS shl01 + IMPORTING + !i_pwd_hash TYPE yecb_pwd_hash + RETURNING + VALUE(r_pwd_hash) TYPE yecb_pwd_hash . + CLASS-METHODS shr14 + IMPORTING + !i_pwd_hash TYPE yecb_pwd_hash + RETURNING + VALUE(r_pwd_hash) TYPE yecb_pwd_hash . +ENDCLASS. + + + +CLASS ycl_ecb_common IMPLEMENTATION. + + + METHOD calculate_cell_distance. + + DATA: lv_reference_row TYPE i, + lv_reference_col_alpha TYPE yecb_cell_column_alpha, + lv_reference_col TYPE i, + lv_current_row TYPE i, + lv_current_col_alpha TYPE yecb_cell_column_alpha, + lv_current_col TYPE i. + +*--------------------------------------------------------------------* +* Split reference cell into numerical row/column representation +*--------------------------------------------------------------------* + convert_columnrow2column_a_row( EXPORTING + i_columnrow = iv_reference_cell + IMPORTING + e_column = lv_reference_col_alpha + e_row = lv_reference_row ). + lv_reference_col = convert_column2int( lv_reference_col_alpha ). + +*--------------------------------------------------------------------* +* Split current cell into numerical row/column representation +*--------------------------------------------------------------------* + convert_columnrow2column_a_row( EXPORTING + i_columnrow = iv_current_cell + IMPORTING + e_column = lv_current_col_alpha + e_row = lv_current_row ). + lv_current_col = convert_column2int( lv_current_col_alpha ). + +*--------------------------------------------------------------------* +* Calculate row and column difference +* Positive: Current cell below reference cell +* or Current cell right of reference cell +* Negative: Current cell above reference cell +* or Current cell left of reference cell +*--------------------------------------------------------------------* + ev_row_difference = lv_current_row - lv_reference_row. + ev_col_difference = lv_current_col - lv_reference_col. + + ENDMETHOD. + + + METHOD char2hex. + + IF o_conv IS NOT BOUND. + o_conv = cl_abap_conv_out_ce=>create( endian = 'L' + ignore_cerr = abap_true + replacement = '#' ). + ENDIF. + + CALL METHOD o_conv->reset( ). + CALL METHOD o_conv->write( data = i_char ). + r_hex+1 = o_conv->get_buffer( ). " x'65' must be x'0065' + + ENDMETHOD. + + + METHOD class_constructor. + c_xlsx_file_filter = 'Excel Workbook (*.xlsx)|*.xlsx|'(005). + ENDMETHOD. + + + METHOD convert_column2alpha. + + DATA: lv_uccpi TYPE i, + lv_text TYPE c LENGTH 2, + lv_module TYPE int4, + lv_column TYPE yecb_cell_column. + +* Propagate zcx_excel if error occurs " issue #155 - less restrictive typing for ip_column + lv_column = convert_column2int( ip_column ). " issue #155 - less restrictive typing for ip_column + +*--------------------------------------------------------------------* +* Check whether column is in allowed range for EXCEL to handle ( 1-16384 ) +*--------------------------------------------------------------------* + IF lv_column > 16384 + OR lv_column < 1. + ycx_ecb=>raise_text( 'Index out of bounds' ). + ENDIF. + +*--------------------------------------------------------------------* +* Look up for previous succesfull cached result +*--------------------------------------------------------------------* + IF lv_column = sv_prev_in1 AND sv_prev_out1 IS NOT INITIAL. + ep_column = sv_prev_out1. + RETURN. + ELSE. + CLEAR sv_prev_out1. + sv_prev_in1 = lv_column. + ENDIF. + +*--------------------------------------------------------------------* +* Build alpha representation of column +*--------------------------------------------------------------------* + WHILE lv_column GT 0. + + lv_module = ( lv_column - 1 ) MOD 26. + lv_uccpi = 65 + lv_module. + + lv_column = ( lv_column - lv_module ) / 26. + + lv_text = cl_abap_conv_in_ce=>uccpi( lv_uccpi ). + CONCATENATE lv_text ep_column INTO ep_column. + + ENDWHILE. + +*--------------------------------------------------------------------* +* Save succesfull output into cache +*--------------------------------------------------------------------* + sv_prev_out1 = ep_column. + + ENDMETHOD. + + + METHOD convert_column2int. + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-12-29 +* - ... +* changes: renaming variables to naming conventions +* removing unused variables +* removing commented out code that is inactive for more then half a year +* message made to support multilinguality +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* +* issue#246 - error converting lower case column names +* - Stefan Schmoecker, 2012-12-29 +* changes: translating the correct variable to upper dase +* adding missing exception if input is a number +* that is out of bounds +* adding missing exception if input contains +* illegal characters like german umlauts +*--------------------------------------------------------------------* + + DATA: lv_column TYPE yecb_cell_column_alpha, + lv_column_c TYPE c LENGTH 10, + lv_column_s TYPE string, + lv_errormessage TYPE string, " Can't pass '...'(abc) to exception-class + lv_modulo TYPE i. + +*--------------------------------------------------------------------* +* This module tries to identify which column a user wants to access +* Numbers as input are just passed back, anything else will be converted +* using EXCEL nomenclatura A = 1, AA = 27, ..., XFD = 16384 +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* Normalize input ( upper case , no gaps ) +*--------------------------------------------------------------------* + lv_column_c = ip_column. + TRANSLATE lv_column_c TO UPPER CASE. " Fix #246 + CONDENSE lv_column_c NO-GAPS. + IF lv_column_c EQ ''. + MESSAGE e800(yecb) INTO lv_errormessage. + ycx_ecb=>raise_symsg( ). + ENDIF. + +*--------------------------------------------------------------------* +* Look up for previous succesfull cached result +*--------------------------------------------------------------------* + IF lv_column_c = sv_prev_in2 AND sv_prev_out2 IS NOT INITIAL. + ep_column = sv_prev_out2. + RETURN. + ELSE. + CLEAR sv_prev_out2. + sv_prev_in2 = lv_column_c. + ENDIF. + +*--------------------------------------------------------------------* +* If a number gets passed, just convert it to an integer and return +* the converted value +*--------------------------------------------------------------------* + TRY. + IF lv_column_c CO '1234567890 '. " Fix #164 + ep_column = lv_column_c. " Fix #164 +*--------------------------------------------------------------------* +* Maximum column for EXCEL: XFD = 16384 " if anyone has a reference for this information - please add here instead of this comment +*--------------------------------------------------------------------* + IF ep_column > 16384 OR ep_column < 1. + lv_errormessage = 'Index out of bounds'(004). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + RETURN. + ENDIF. + CATCH cx_sy_conversion_no_number. "#EC NO_HANDLER + " Try the character-approach if approach via number has failed + ENDTRY. + +*--------------------------------------------------------------------* +* Raise error if unexpected characters turns up +*--------------------------------------------------------------------* + lv_column_s = lv_column_c. + IF lv_column_s CN sy-abcde. + MESSAGE e800(yecb) INTO lv_errormessage. + ycx_ecb=>raise_symsg( ). + ENDIF. + + DO 1 TIMES. "Because of using CHECK +*--------------------------------------------------------------------* +* Interpret input as number to base 26 with A=1, ... Z=26 +* Raise error if unexpected character turns up +*--------------------------------------------------------------------* +* 1st character +*--------------------------------------------------------------------* + lv_column = lv_column_c. + FIND lv_column+0(1) IN sy-abcde MATCH OFFSET lv_modulo. + lv_modulo = lv_modulo + 1. + IF lv_modulo < 1 OR lv_modulo > 26. + MESSAGE e800(yecb) INTO lv_errormessage. + ycx_ecb=>raise_symsg( ). + ENDIF. + ep_column = lv_modulo. " Leftmost digit + +*--------------------------------------------------------------------* +* 2nd character if present +*--------------------------------------------------------------------* + CHECK lv_column+1(1) IS NOT INITIAL. " No need to continue if string ended + FIND lv_column+1(1) IN sy-abcde MATCH OFFSET lv_modulo. + lv_modulo = lv_modulo + 1. + IF lv_modulo < 1 OR lv_modulo > 26. + MESSAGE e800(yecb) INTO lv_errormessage. + ycx_ecb=>raise_symsg( ). + ENDIF. + ep_column = 26 * ep_column + lv_modulo. " if second digit is present first digit is for 26^1 + +*--------------------------------------------------------------------* +* 3rd character if present +*--------------------------------------------------------------------* + CHECK lv_column+2(1) IS NOT INITIAL. " No need to continue if string ended + FIND lv_column+2(1) IN sy-abcde MATCH OFFSET lv_modulo. + lv_modulo = lv_modulo + 1. + IF lv_modulo < 1 OR lv_modulo > 26. + MESSAGE e800(yecb) INTO lv_errormessage. + ycx_ecb=>raise_symsg( ). + ENDIF. + ep_column = 26 * ep_column + lv_modulo. " if third digit is present first digit is for 26^2 and second digit for 26^1 + ENDDO. + +*--------------------------------------------------------------------* +* Maximum column for EXCEL: XFD = 16384 " if anyone has a reference for this information - please add here instead of this comment +*--------------------------------------------------------------------* + IF ep_column > 16384 OR ep_column < 1. + lv_errormessage = 'Index out of bounds'(004). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + +*--------------------------------------------------------------------* +* Save succesfull output into cache +*--------------------------------------------------------------------* + sv_prev_out2 = ep_column. + + ENDMETHOD. + + + METHOD convert_column_a_row2columnrow. + DATA: lv_row_alpha TYPE string, + lv_column_alpha TYPE yecb_cell_column_alpha. + + lv_row_alpha = i_row. + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( i_column ). + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_column_alpha lv_row_alpha INTO e_columnrow. + + ENDMETHOD. + + + METHOD convert_columnrow2column_a_row. +*--------------------------------------------------------------------* + "issue #256 - replacing char processing with regex +*--------------------------------------------------------------------* +* Stefan Schmoecker, 2013-08-11 +* Allow input to be CLIKE instead of STRING +*--------------------------------------------------------------------* + + DATA: pane_cell_row_a TYPE string, + lv_columnrow TYPE string. + + lv_columnrow = i_columnrow. " Get rid of trailing blanks + + FIND REGEX '^(\D+)(\d+)$' IN lv_columnrow SUBMATCHES e_column + pane_cell_row_a. + IF e_column_int IS SUPPLIED. + e_column_int = convert_column2int( ip_column = e_column ). + ENDIF. + e_row = pane_cell_row_a. + + ENDMETHOD. + + + METHOD convert_range2column_a_row. +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-12-07 +* - ... +* changes: renaming variables to naming conventions +* aligning code +* added exceptionclass +* added errorhandling for invalid range +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* +* issue#241 - error when sheetname contains "!" +* - sheetname should be returned unescaped +* - Stefan Schmoecker, 2012-12-07 +* changes: changed coding to support sheetnames with "!" +* unescaping sheetname +*--------------------------------------------------------------------* +* issue#155 - lessening restrictions of input parameters +* - Stefan Schmoecker, 2012-12-07 +* changes: i_range changed to clike +* e_sheet changed to clike +*--------------------------------------------------------------------* + + DATA: lv_sheet TYPE string, + lv_range TYPE string, + lv_columnrow_start TYPE string, + lv_columnrow_end TYPE string, + lv_position TYPE i, + lv_errormessage TYPE string. " Can't pass '...'(abc) to exception-class + + +*--------------------------------------------------------------------* +* Split input range into sheetname and Area +* 4 cases - a) input empty --> nothing to do +* - b) sheetname existing - starts with ' example 'Sheet 1'!$B$6:$D$13 +* - c) sheetname existing - does not start with ' example Sheet1!$B$6:$D$13 +* - d) no sheetname - just area example $B$6:$D$13 +*--------------------------------------------------------------------* +* Initialize output parameters + CLEAR: e_column_start, + e_column_end, + e_row_start, + e_row_end, + e_sheet. + + IF i_range IS INITIAL. " a) input empty --> nothing to do + RETURN. + + ELSEIF i_range(1) = `'`. " b) sheetname existing - starts with ' + FIND REGEX '\![^\!]*$' IN i_range MATCH OFFSET lv_position. " Find last ! + IF sy-subrc = 0. + lv_sheet = i_range(lv_position). + ADD 1 TO lv_position. + lv_range = i_range. + SHIFT lv_range LEFT BY lv_position PLACES. + ELSE. + lv_errormessage = 'Invalid range'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + + ELSEIF i_range CS '!'. " c) sheetname existing - does not start with ' + SPLIT i_range AT '!' INTO lv_sheet lv_range. + " begin Dennis Schaaf + IF lv_range CP '*#REF*'. + lv_errormessage = 'Invalid range'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + " end Dennis Schaaf + ELSE. " d) no sheetname - just area + lv_range = i_range. + ENDIF. + + REPLACE ALL OCCURRENCES OF '$' IN lv_range WITH ''. + SPLIT lv_range AT ':' INTO lv_columnrow_start lv_columnrow_end. + + IF i_allow_1dim_range = abap_true. + convert_columnrow2column_o_row( EXPORTING i_columnrow = lv_columnrow_start + IMPORTING e_column = e_column_start + e_row = e_row_start ). + convert_columnrow2column_o_row( EXPORTING i_columnrow = lv_columnrow_end + IMPORTING e_column = e_column_end + e_row = e_row_end ). + ELSE. + convert_columnrow2column_a_row( EXPORTING i_columnrow = lv_columnrow_start + IMPORTING e_column = e_column_start + e_row = e_row_start ). + convert_columnrow2column_a_row( EXPORTING i_columnrow = lv_columnrow_end + IMPORTING e_column = e_column_end + e_row = e_row_end ). + ENDIF. + + IF e_column_start_int IS SUPPLIED AND e_column_start IS NOT INITIAL. + e_column_start_int = convert_column2int( e_column_start ). + ENDIF. + IF e_column_end_int IS SUPPLIED AND e_column_end IS NOT INITIAL. + e_column_end_int = convert_column2int( e_column_end ). + ENDIF. + + e_sheet = unescape_string( lv_sheet ). " Return in unescaped form + ENDMETHOD. + + + METHOD convert_columnrow2column_o_row. + + DATA: row TYPE string. + DATA: columnrow TYPE string. + + CLEAR e_column. + + columnrow = i_columnrow. + + FIND REGEX '^(\D*)(\d*)$' IN columnrow SUBMATCHES e_column + row. + + e_row = row. + + ENDMETHOD. + + + METHOD clone_ixml_with_namespaces. + + DATA: iterator TYPE REF TO if_ixml_node_iterator, + node TYPE REF TO if_ixml_node, + xmlns TYPE ihttpnvp, + xmlns_table TYPE TABLE OF ihttpnvp. + FIELD-SYMBOLS: + TYPE ihttpnvp. + + iterator = element->create_iterator( ). + result ?= element->clone( ). + node = iterator->get_next( ). + WHILE node IS BOUND. + xmlns-name = node->get_namespace_prefix( ). + xmlns-value = node->get_namespace_uri( ). + COLLECT xmlns INTO xmlns_table. + node = iterator->get_next( ). + ENDWHILE. + + LOOP AT xmlns_table ASSIGNING . + result->set_attribute_ns( prefix = 'xmlns' name = -name value = -value ). + ENDLOOP. + + ENDMETHOD. + + + METHOD date_to_excel_string. + DATA: lv_date_diff TYPE i. + + CHECK ip_value IS NOT INITIAL + AND ip_value <> space. + " Needed hack caused by the problem that: + " Excel 2000 incorrectly assumes that the year 1900 is a leap year + " http://support.microsoft.com/kb/214326/en-us + IF ip_value > c_excel_1900_leap_year. + lv_date_diff = ip_value - c_excel_baseline_date + 2. + ELSE. + lv_date_diff = ip_value - c_excel_baseline_date + 1. + ENDIF. + ep_value = ycl_ecb_common=>number_to_excel_string( ip_value = lv_date_diff ). + ENDMETHOD. + + + METHOD describe_structure. + DATA: lt_components TYPE abap_component_tab, + lt_comps TYPE abap_component_tab, + ls_component TYPE abap_componentdescr, + lo_elemdescr TYPE REF TO cl_abap_elemdescr, + ls_dfies TYPE dfies, + l_position LIKE ls_dfies-position. + + "for DDIC structure get the info directly + IF io_struct->is_ddic_type( ) = abap_true. + rt_dfies = io_struct->get_ddic_field_list( ). + ELSE. + lt_components = io_struct->get_components( ). + + LOOP AT lt_components INTO ls_component. + structure_case( EXPORTING is_component = ls_component + CHANGING xt_components = lt_comps ) . + ENDLOOP. + LOOP AT lt_comps INTO ls_component. + CLEAR ls_dfies. + IF ls_component-type->kind = cl_abap_typedescr=>kind_elem. "E Elementary Type + ADD 1 TO l_position. + lo_elemdescr ?= ls_component-type. + IF lo_elemdescr->is_ddic_type( ) = abap_true. + ls_dfies = lo_elemdescr->get_ddic_field( ). + ls_dfies-fieldname = ls_component-name. + ls_dfies-position = l_position. + ELSE. + ls_dfies-fieldname = ls_component-name. + ls_dfies-position = l_position. + ls_dfies-inttype = lo_elemdescr->type_kind. + ls_dfies-leng = lo_elemdescr->length. + ls_dfies-outputlen = lo_elemdescr->length. + ls_dfies-decimals = lo_elemdescr->decimals. + ls_dfies-fieldtext = ls_component-name. + ls_dfies-reptext = ls_component-name. + ls_dfies-scrtext_s = ls_component-name. + ls_dfies-scrtext_m = ls_component-name. + ls_dfies-scrtext_l = ls_component-name. + ls_dfies-dynpfld = abap_true. + ENDIF. + INSERT ls_dfies INTO TABLE rt_dfies. + ENDIF. + ENDLOOP. + ENDIF. + ENDMETHOD. + + + METHOD determine_resulting_formula. + + DATA: lv_row_difference TYPE i, + lv_col_difference TYPE i. + +*--------------------------------------------------------------------* +* Calculate distance of reference and current cell +*--------------------------------------------------------------------* + calculate_cell_distance( EXPORTING + iv_reference_cell = iv_reference_cell + iv_current_cell = iv_current_cell + IMPORTING + ev_row_difference = lv_row_difference + ev_col_difference = lv_col_difference ). + +*--------------------------------------------------------------------* +* and shift formula by using the row- and columndistance +*--------------------------------------------------------------------* + ev_resulting_formula = shift_formula( iv_reference_formula = iv_reference_formula + iv_shift_rows = lv_row_difference + iv_shift_cols = lv_col_difference ). + + ENDMETHOD. "determine_resulting_formula + + + METHOD encrypt_password. + + DATA lv_curr_offset TYPE i. + DATA lv_curr_char TYPE c LENGTH 1. + DATA lv_curr_hex TYPE yecb_pwd_hash. + DATA lv_pwd_len TYPE yecb_pwd_hash. + DATA lv_pwd_hash TYPE yecb_pwd_hash. + + CONSTANTS: + lv_0x7fff TYPE yecb_pwd_hash VALUE '7FFF', + lv_0x0001 TYPE yecb_pwd_hash VALUE '0001', + lv_0xce4b TYPE yecb_pwd_hash VALUE 'CE4B'. + + DATA lv_pwd TYPE yecb_aes_password. + + lv_pwd = i_pwd. + + lv_pwd_len = strlen( lv_pwd ). + lv_curr_offset = lv_pwd_len - 1. + + WHILE lv_curr_offset GE 0. + + lv_curr_char = lv_pwd+lv_curr_offset(1). + lv_curr_hex = char2hex( lv_curr_char ). + + lv_pwd_hash = ( shr14( lv_pwd_hash ) BIT-AND lv_0x0001 ) BIT-OR ( shl01( lv_pwd_hash ) BIT-AND lv_0x7fff ). + + lv_pwd_hash = lv_pwd_hash BIT-XOR lv_curr_hex. + SUBTRACT 1 FROM lv_curr_offset. + ENDWHILE. + + lv_pwd_hash = ( shr14( lv_pwd_hash ) BIT-AND lv_0x0001 ) BIT-OR ( shl01( lv_pwd_hash ) BIT-AND lv_0x7fff ). + lv_pwd_hash = lv_pwd_hash BIT-XOR lv_0xce4b. + lv_pwd_hash = lv_pwd_hash BIT-XOR lv_pwd_len. + + WRITE lv_pwd_hash TO r_encrypted_pwd. + + ENDMETHOD. + + + METHOD escape_string. +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-12-08 +* - ... +* changes: aligning code +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* +* issue#242 - Support escaping for white-spaces +* - Escaping also necessary when ' encountered in input +* - Stefan Schmoecker, 2012-12-08 +* changes: switched check if escaping is necessary to regular expression +* and moved the "REPLACE" +*--------------------------------------------------------------------* +* issue#155 - lessening restrictions of input parameters +* - Stefan Schmoecker, 2012-12-08 +* changes: ip_value changed to clike +*--------------------------------------------------------------------* + DATA: lv_value TYPE string. + +*--------------------------------------------------------------------* +* There exist various situations when a space will be used to separate +* different parts of a string. When we have a string consisting spaces +* that will cause errors unless we "escape" the string by putting ' at +* the beginning and at the end of the string. +*--------------------------------------------------------------------* + + +*--------------------------------------------------------------------* +* When allowing clike-input parameters we might encounter trailing +* "real" blanks . These are automatically eliminated when moving +* the input parameter to a string. +* Now any remaining spaces ( white-spaces or normal spaces ) should +* trigger the escaping as well as any ' +*--------------------------------------------------------------------* + lv_value = ip_value. + + + FIND REGEX `\s|'|-` IN lv_value. " \s finds regular and white spaces + IF sy-subrc = 0. + REPLACE ALL OCCURRENCES OF `'` IN lv_value WITH `''`. + CONCATENATE `'` lv_value `'` INTO lv_value . + ENDIF. + + ep_escaped_value = lv_value. + + ENDMETHOD. + + + METHOD excel_string_to_date. + DATA: lv_date_int TYPE i. + + CHECK ip_value IS NOT INITIAL AND ip_value CN ' 0'. + + TRY. + lv_date_int = ip_value. + IF lv_date_int NOT BETWEEN 1 AND 2958465. + ycx_ecb=>raise_text( 'Unable to interpret date' ). + ENDIF. + ep_value = lv_date_int + c_excel_baseline_date - 2. + " Needed hack caused by the problem that: + " Excel 2000 incorrectly assumes that the year 1900 is a leap year + " http://support.microsoft.com/kb/214326/en-us + IF ep_value < c_excel_1900_leap_year. + ep_value = ep_value + 1. + ENDIF. + CATCH cx_sy_conversion_error. + ycx_ecb=>raise_text( 'Index out of bounds' ). + ENDTRY. + ENDMETHOD. + + + METHOD excel_string_to_number. + +* If we encounter anything more complicated in EXCEL we might have to extend this +* But currently this works fine - even for numbers in scientific notation + + ep_value = ip_value. + + ENDMETHOD. + + + METHOD excel_string_to_time. + DATA: lv_seconds_in_day TYPE i, + lv_day_fraction TYPE f, + lc_seconds_in_day TYPE i VALUE 86400. + + TRY. + + lv_day_fraction = ip_value. + lv_seconds_in_day = lv_day_fraction * lc_seconds_in_day. + + ep_value = lv_seconds_in_day. + + CATCH cx_sy_conversion_error. + ycx_ecb=>raise_text( 'Unable to interpret time' ). + ENDTRY. + ENDMETHOD. + + + METHOD get_fieldcatalog. + DATA: lr_dref_tab TYPE REF TO data, + lo_salv_table TYPE REF TO cl_salv_table, + lo_salv_columns_table TYPE REF TO cl_salv_columns_table, + lt_salv_t_column_ref TYPE salv_t_column_ref, + ls_salv_t_column_ref LIKE LINE OF lt_salv_t_column_ref, + lo_salv_column_table TYPE REF TO cl_salv_column_table. + + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: LIKE LINE OF ep_fieldcatalog. + +* Get copy of IP_TABLE-structure <-- must be changeable to create salv + CREATE DATA lr_dref_tab LIKE ip_table. + ASSIGN lr_dref_tab->* TO . +* Create salv --> implicitly create fieldcat + TRY. + cl_salv_table=>factory( IMPORTING + r_salv_table = lo_salv_table + CHANGING + t_table = ). + lo_salv_columns_table = lo_salv_table->get_columns( ). + lt_salv_t_column_ref = lo_salv_columns_table->get( ). + CATCH cx_root. +* maybe some errorhandling here - just haven't made up my mind yet + ENDTRY. + +* Loop through columns and set relevant fields ( fieldname, texts ) + LOOP AT lt_salv_t_column_ref INTO ls_salv_t_column_ref. + + lo_salv_column_table ?= ls_salv_t_column_ref-r_column. + APPEND INITIAL LINE TO ep_fieldcatalog ASSIGNING . + -position = sy-tabix. + -fieldname = ls_salv_t_column_ref-columnname. + -scrtext_s = ls_salv_t_column_ref-r_column->get_short_text( ). + -scrtext_m = ls_salv_t_column_ref-r_column->get_medium_text( ). + -scrtext_l = ls_salv_t_column_ref-r_column->get_long_text( ). + -currency_column = ls_salv_t_column_ref-r_column->get_currency_column( ). + " If currency column not in structure then clear the field again + IF -currency_column IS NOT INITIAL. + READ TABLE lt_salv_t_column_ref WITH KEY columnname = -currency_column TRANSPORTING NO FIELDS. + IF sy-subrc <> 0. + CLEAR -currency_column. + ENDIF. + ENDIF. + + IF ip_conv_exit_length = abap_false. + -abap_type = lo_salv_column_table->get_ddic_inttype( ). + ENDIF. + + -dynpfld = 'X'. " What in the world would we exclude here? + " except for the MANDT-field of most tables ( 1st column that is ) + IF -position = 1 AND lo_salv_column_table->get_ddic_datatype( ) = 'CLNT' AND iv_hide_mandt = abap_true. + CLEAR -dynpfld. + ENDIF. + +* For fields that don't a description ( i.e. defined by "field type i," ) +* just use the fieldname as description - that is better than nothing + IF -scrtext_s IS INITIAL + AND -scrtext_m IS INITIAL + AND -scrtext_l IS INITIAL. + CONCATENATE 'Col:' -fieldname INTO -scrtext_l SEPARATED BY space. + -scrtext_m = -scrtext_l. + -scrtext_s = -scrtext_l. + ENDIF. + + ENDLOOP. + + ENDMETHOD. + + + METHOD is_cell_in_range. + DATA lv_column_start TYPE yecb_cell_column_alpha. + DATA lv_column_end TYPE yecb_cell_column_alpha. + DATA lv_row_start TYPE yecb_cell_row. + DATA lv_row_end TYPE yecb_cell_row. + DATA lv_column_start_i TYPE yecb_cell_column. + DATA lv_column_end_i TYPE yecb_cell_column. + DATA lv_column_i TYPE yecb_cell_column. + + +* Split range and convert columns + convert_range2column_a_row( + EXPORTING + i_range = ip_range + IMPORTING + e_column_start = lv_column_start + e_column_end = lv_column_end + e_row_start = lv_row_start + e_row_end = lv_row_end ). + + lv_column_start_i = convert_column2int( ip_column = lv_column_start ). + lv_column_end_i = convert_column2int( ip_column = lv_column_end ). + + lv_column_i = convert_column2int( ip_column = ip_column ). + +* Check if cell is in range + IF lv_column_i >= lv_column_start_i AND + lv_column_i <= lv_column_end_i AND + ip_row >= lv_row_start AND + ip_row <= lv_row_end. + rp_in_range = abap_true. + ENDIF. + ENDMETHOD. + + + METHOD number_to_excel_string. + DATA: lv_value_c TYPE c LENGTH 100. + + IF ip_currency IS INITIAL. + WRITE ip_value TO lv_value_c EXPONENT 0 NO-GROUPING NO-SIGN. + ELSE. + WRITE ip_value TO lv_value_c EXPONENT 0 NO-GROUPING NO-SIGN CURRENCY ip_currency. + ENDIF. + REPLACE ALL OCCURRENCES OF ',' IN lv_value_c WITH '.'. + + ep_value = lv_value_c. + CONDENSE ep_value. + + IF ip_value < 0. + CONCATENATE '-' ep_value INTO ep_value. + ELSEIF ip_value EQ 0. + ep_value = '0'. + ENDIF. + ENDMETHOD. + + + 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 +* This is private an no one using it so far except me, so no need to hurry + DATA: descr TYPE REF TO cl_abap_structdescr, + wa_component LIKE LINE OF descr->components, + attribute_name LIKE wa_component-name, + flag_class TYPE abap_bool. + + FIELD-SYMBOLS: TYPE any, + TYPE any, + TYPE any. + + + descr ?= cl_abap_structdescr=>describe_by_data( e_target ). + + LOOP AT descr->components INTO wa_component. + +* Assign structure and X-structure + ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO . + ASSIGN COMPONENT wa_component-name OF STRUCTURE e_targetx TO . +* At least one field in the structure should be marked - otherwise continue with next field + CLEAR flag_class. +* maybe source is just a structure - try assign component... + ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO . + IF sy-subrc <> 0. +* not - then it is an attribute of the class - use different assign then + CONCATENATE 'i_source->' wa_component-name INTO attribute_name. + ASSIGN (attribute_name) TO . + IF sy-subrc <> 0. + EXIT. + ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps + flag_class = abap_true. + ENDIF. + + CASE wa_component-type_kind. + WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. " Structure --> use recursio + ycl_ecb_common=>recursive_class_to_struct( EXPORTING i_source = + CHANGING e_target = + e_targetx = ). + WHEN OTHERS. + = . + = abap_true. + + ENDCASE. + ENDLOOP. + + ENDMETHOD. + + + 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 +* This is private an no one using it so far except me, so no need to hurry + DATA: descr TYPE REF TO cl_abap_structdescr, + wa_component LIKE LINE OF descr->components, + attribute_name LIKE wa_component-name, + flag_class TYPE abap_bool, + o_border TYPE REF TO ycl_ecb_style_border. + + FIELD-SYMBOLS: TYPE any, + TYPE any, + TYPE any. + + + descr ?= cl_abap_structdescr=>describe_by_data( i_source ). + + LOOP AT descr->components INTO wa_component. + +* Assign structure and X-structure + ASSIGN COMPONENT wa_component-name OF STRUCTURE i_source TO . + ASSIGN COMPONENT wa_component-name OF STRUCTURE i_sourcex TO . +* At least one field in the structure should be marked - otherwise continue with next field + CHECK CA abap_true. + CLEAR flag_class. +* maybe target is just a structure - try assign component... + ASSIGN COMPONENT wa_component-name OF STRUCTURE e_target TO . + IF sy-subrc <> 0. +* not - then it is an attribute of the class - use different assign then + CONCATENATE 'E_TARGET->' wa_component-name INTO attribute_name. + ASSIGN (attribute_name) TO . + IF sy-subrc <> 0.EXIT.ENDIF. " Should not happen if structure is built properly - otherwise just exit to create no dumps + flag_class = abap_true. + ENDIF. + + CASE wa_component-type_kind. + WHEN cl_abap_structdescr=>typekind_struct1 OR cl_abap_structdescr=>typekind_struct2. " Structure --> use recursion + " To avoid dump with attribute GRADTYPE of class ZCL_EXCEL_STYLE_FILL + " quick and really dirty fix -> check the attribute name + " Border has to be initialized somewhere else + IF wa_component-name EQ 'GRADTYPE'. + flag_class = abap_false. + ENDIF. + + IF flag_class = abap_true AND IS INITIAL. +* Only borders will be passed as unbound references. But since we want to set a value we have to create an instance + CREATE OBJECT o_border. + = o_border. + ENDIF. + ycl_ecb_common=>recursive_struct_to_class( EXPORTING i_source = + i_sourcex = + CHANGING e_target = ). + WHEN OTHERS. + CHECK = abap_true. " Marked for change + = . + + ENDCASE. + ENDLOOP. + + ENDMETHOD. + + + METHOD shift_formula. + + CONSTANTS: lcv_operators TYPE string VALUE '+-/*^%=<>&, !', + lcv_letters TYPE string VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$', + lcv_digits TYPE string VALUE '0123456789', + lcv_cell_reference_error TYPE string VALUE '#REF!'. + + DATA: lv_tcnt TYPE i, " Counter variable + lv_tlen TYPE i, " Temp variable length + lv_cnt TYPE i, " Counter variable + lv_cnt2 TYPE i, " Counter variable + lv_offset1 TYPE i, " Character offset + lv_numchars TYPE i, " Number of characters counter + lv_tchar(1) TYPE c, " Temp character + lv_tchar2(1) TYPE c, " Temp character + lv_cur_form TYPE string, " Formula for current cell + lv_ref_cell_addr TYPE string, " Reference cell address + lv_tcol1 TYPE string, " Temp column letter + lv_tcol2 TYPE string, " Temp column letter + lv_tcoln TYPE i, " Temp column number + lv_trow1 TYPE string, " Temp row number + lv_trow2 TYPE string, " Temp row number + lv_flen TYPE i, " Length of reference formula + lv_tlen2 TYPE i, " Temp variable length + lv_substr1 TYPE string, " Substring variable + lv_abscol TYPE string, " Absolute column symbol + lv_absrow TYPE string, " Absolute row symbol + lv_ref_formula TYPE string, + lv_compare_1 TYPE string, + lv_compare_2 TYPE string, + lv_level TYPE i, " Level of groups [..[..]..] or {..} + + lv_errormessage TYPE string. + +*--------------------------------------------------------------------* +* When copying a cell in EXCEL to another cell any inherent formulas +* are copied as well. Cell-references in the formula are being adjusted +* by the distance of the new cell to the original one +*--------------------------------------------------------------------* +* §1 Parse reference formula character by character +* §2 Identify Cell-references +* §3 Shift cell-reference +* §4 Build resulting formula +*--------------------------------------------------------------------* + + lv_ref_formula = iv_reference_formula. +*--------------------------------------------------------------------* +* No distance --> Reference = resulting cell/formula +*--------------------------------------------------------------------* + IF iv_shift_cols = 0 + AND iv_shift_rows = 0. + ev_resulting_formula = lv_ref_formula. + RETURN. " done + ENDIF. + + + lv_flen = strlen( lv_ref_formula ). + lv_numchars = 1. + +*--------------------------------------------------------------------* +* §1 Parse reference formula character by character +*--------------------------------------------------------------------* + DO lv_flen TIMES. + + CLEAR: lv_tchar, + lv_substr1, + lv_ref_cell_addr. + lv_cnt2 = lv_cnt + 1. + IF lv_cnt2 > lv_flen. + EXIT. " Done + ENDIF. + +*--------------------------------------------------------------------* +* Here we have the current character in the formula +*--------------------------------------------------------------------* + lv_tchar = lv_ref_formula+lv_cnt(1). + +*--------------------------------------------------------------------* +* Operators or opening parenthesis will separate possible cellreferences +*--------------------------------------------------------------------* + IF ( lv_tchar CA lcv_operators + OR lv_tchar CA '(' ) + AND lv_cnt2 = 1. + lv_substr1 = lv_ref_formula+lv_offset1(1). + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_numchars = 1. + CONTINUE. " --> next character in formula can be analyzed + ENDIF. + +*--------------------------------------------------------------------* +* Quoted literal text holds no cell reference --> advance to end of text +*--------------------------------------------------------------------* + IF lv_tchar EQ '"'. + lv_cnt = lv_cnt + 1. + lv_numchars = lv_numchars + 1. + lv_tchar = lv_ref_formula+lv_cnt(1). + WHILE lv_tchar NE '"'. + + lv_cnt = lv_cnt + 1. + lv_numchars = lv_numchars + 1. + lv_tchar = lv_ref_formula+lv_cnt(1). + + ENDWHILE. + lv_cnt2 = lv_cnt + 1. + lv_substr1 = lv_ref_formula+lv_offset1(lv_numchars). + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + IF lv_cnt = lv_flen. + EXIT. + ENDIF. + lv_offset1 = lv_cnt. + lv_numchars = 1. + lv_tchar = lv_ref_formula+lv_cnt(1). + lv_cnt2 = lv_cnt + 1. + CONTINUE. " --> next character in formula can be analyzed + ENDIF. + + +*--------------------------------------------------------------------* +* Groups - Ignore values inside blocks [..[..]..] and {..} +* R1C1-Style Cell Reference: R[1]C[1] +* Cell References: 'C:\[Source.xlsx]Sheet1'!$A$1 +* Array constants: {1,3.5,TRUE,"Hello"} +* "Intra table reference": Flights[[#This Row],[Air fare]] +*--------------------------------------------------------------------* + IF lv_tchar CA '[]{}' OR lv_level > 0. + IF lv_tchar CA '[{'. + lv_level = lv_level + 1. + ELSEIF lv_tchar CA ']}'. + lv_level = lv_level - 1. + ENDIF. + IF lv_cnt2 = lv_flen. + lv_substr1 = iv_reference_formula+lv_offset1(lv_numchars). + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + EXIT. + ENDIF. + lv_numchars = lv_numchars + 1. + lv_cnt = lv_cnt + 1. + lv_cnt2 = lv_cnt + 1. + CONTINUE. + ENDIF. + +*--------------------------------------------------------------------* +* Operators or parenthesis or last character in formula will separate possible cellreferences +*--------------------------------------------------------------------* + IF lv_tchar CA lcv_operators + OR lv_tchar CA '():' + OR lv_cnt2 = lv_flen. + IF lv_cnt > 0. + lv_substr1 = lv_ref_formula+lv_offset1(lv_numchars). +*--------------------------------------------------------------------* +* Check for text concatenation and functions +*--------------------------------------------------------------------* + IF ( lv_tchar CA lcv_operators AND lv_tchar EQ lv_substr1 ) OR lv_tchar EQ '('. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. " --> next character in formula can be analyzed + ENDIF. + + lv_tlen = lv_cnt2 - lv_offset1. +*--------------------------------------------------------------------* +* Exclude mathematical operators and closing parentheses +*--------------------------------------------------------------------* + IF lv_tchar CA lcv_operators + OR lv_tchar CA ':)'. + IF lv_cnt2 = lv_flen + AND lv_numchars = 1. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. " --> next character in formula can be analyzed + ELSE. + lv_tlen = lv_tlen - 1. + ENDIF. + ENDIF. +*--------------------------------------------------------------------* +* Capture reference cell address +*--------------------------------------------------------------------* + TRY. + lv_ref_cell_addr = lv_ref_formula+lv_offset1(lv_tlen). "Ref cell address + CATCH cx_root. + lv_errormessage = 'Internal error in Class ZCL_EXCEL_COMMON Method SHIFT_FORMULA Spot 1 '. " Change to messageclass if possible + ycx_ecb=>raise_text( lv_errormessage ). + ENDTRY. + +*--------------------------------------------------------------------* +* Split cell address into characters and numbers +*--------------------------------------------------------------------* + CLEAR: lv_tlen, + lv_tcnt, + lv_tcol1, + lv_trow1. + lv_tlen = strlen( lv_ref_cell_addr ). + IF lv_tlen <> 0. + CLEAR: lv_tcnt. + DO lv_tlen TIMES. + CLEAR: lv_tchar2. + lv_tchar2 = lv_ref_cell_addr+lv_tcnt(1). + IF lv_tchar2 CA lcv_letters. + CONCATENATE lv_tcol1 lv_tchar2 INTO lv_tcol1. + ELSEIF lv_tchar2 CA lcv_digits. + CONCATENATE lv_trow1 lv_tchar2 INTO lv_trow1. + ENDIF. + lv_tcnt = lv_tcnt + 1. + ENDDO. + ENDIF. + + " Is valid column & row ? + IF lv_tcol1 IS NOT INITIAL AND lv_trow1 IS NOT INITIAL. + " COLUMN + ROW + CONCATENATE lv_tcol1 lv_trow1 INTO lv_compare_1. + " Original condensed string + lv_compare_2 = lv_ref_cell_addr. + CONDENSE lv_compare_2. + IF lv_compare_1 <> lv_compare_2. + CLEAR: lv_trow1, lv_tchar2. + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* Check for invalid cell address +*--------------------------------------------------------------------* + IF lv_tcol1 IS INITIAL OR lv_trow1 IS INITIAL. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. + ENDIF. +*--------------------------------------------------------------------* +* Check for range names +*--------------------------------------------------------------------* + CLEAR: lv_tlen. + lv_tlen = strlen( lv_tcol1 ). + IF lv_tlen GT 3. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. + ENDIF. +*--------------------------------------------------------------------* +* Check for valid row +*--------------------------------------------------------------------* + IF lv_trow1 GT 1048576. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. + ENDIF. +*--------------------------------------------------------------------* +* Check for absolute column or row reference +*--------------------------------------------------------------------* + CLEAR: lv_tcol2, + lv_trow2, + lv_abscol, + lv_absrow. + lv_tlen2 = strlen( lv_tcol1 ) - 1. + IF lv_tcol1 IS NOT INITIAL. + lv_abscol = lv_tcol1(1). + ENDIF. + IF lv_tlen2 GE 0. + lv_absrow = lv_tcol1+lv_tlen2(1). + ENDIF. + IF lv_abscol EQ '$' AND lv_absrow EQ '$'. + lv_tlen2 = lv_tlen2 - 1. + IF lv_tlen2 > 0. + lv_tcol1 = lv_tcol1+1(lv_tlen2). + ENDIF. + lv_tlen2 = lv_tlen2 + 1. + ELSEIF lv_abscol EQ '$'. + lv_tcol1 = lv_tcol1+1(lv_tlen2). + ELSEIF lv_absrow EQ '$'. + lv_tcol1 = lv_tcol1(lv_tlen2). + ENDIF. +*--------------------------------------------------------------------* +* Check for valid column +*--------------------------------------------------------------------* + TRY. + lv_tcoln = ycl_ecb_common=>convert_column2int( lv_tcol1 ) + iv_shift_cols. + CATCH ycx_ecb. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. + ENDTRY. +*--------------------------------------------------------------------* +* Check whether there is a referencing problem +*--------------------------------------------------------------------* + lv_trow2 = lv_trow1 + iv_shift_rows. + " Remove the space used for the sign + CONDENSE lv_trow2. + IF ( lv_tcoln < 1 AND lv_abscol <> '$' ) " Maybe we should add here max-column and max row-tests as well. + OR ( lv_trow2 < 1 AND lv_absrow <> '$' ). " Check how EXCEL behaves in this case +*--------------------------------------------------------------------* +* Referencing problem encountered --> set error +*--------------------------------------------------------------------* + CONCATENATE lv_cur_form lcv_cell_reference_error INTO lv_cur_form. + ELSE. +*--------------------------------------------------------------------* +* No referencing problems --> adjust row and column +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* Adjust column +*--------------------------------------------------------------------* + IF lv_abscol EQ '$'. + CONCATENATE lv_cur_form lv_abscol lv_tcol1 INTO lv_cur_form. + ELSEIF iv_shift_cols EQ 0. + CONCATENATE lv_cur_form lv_tcol1 INTO lv_cur_form. + ELSE. + TRY. + lv_tcol2 = ycl_ecb_common=>convert_column2alpha( lv_tcoln ). + CONCATENATE lv_cur_form lv_tcol2 INTO lv_cur_form. + CATCH ycx_ecb. + CONCATENATE lv_cur_form lv_substr1 INTO lv_cur_form. + lv_cnt = lv_cnt + 1. + lv_offset1 = lv_cnt. + lv_cnt2 = lv_cnt + 1. + lv_numchars = 1. + CONTINUE. + ENDTRY. + ENDIF. +*--------------------------------------------------------------------* +* Adjust row +*--------------------------------------------------------------------* + IF lv_absrow EQ '$'. + CONCATENATE lv_cur_form lv_absrow lv_trow1 INTO lv_cur_form. + ELSEIF iv_shift_rows = 0. + CONCATENATE lv_cur_form lv_trow1 INTO lv_cur_form. + ELSE. + CONCATENATE lv_cur_form lv_trow2 INTO lv_cur_form. + ENDIF. + ENDIF. + + lv_numchars = 0. + IF lv_tchar CA lcv_operators + OR lv_tchar CA ':)'. + CONCATENATE lv_cur_form lv_tchar INTO lv_cur_form RESPECTING BLANKS. + ENDIF. + lv_offset1 = lv_cnt2. + ENDIF. + ENDIF. + lv_numchars = lv_numchars + 1. + lv_cnt = lv_cnt + 1. + lv_cnt2 = lv_cnt + 1. + + ENDDO. + + + +*--------------------------------------------------------------------* +* Return resulting formula +*--------------------------------------------------------------------* + IF lv_cur_form IS NOT INITIAL. + ev_resulting_formula = lv_cur_form. + ENDIF. + + ENDMETHOD. + + + METHOD shl01. + + DATA: + lv_bit TYPE i, + lv_curr_pos TYPE i VALUE 2, + lv_prev_pos TYPE i VALUE 1. + + DO 15 TIMES. + GET BIT lv_curr_pos OF i_pwd_hash INTO lv_bit. + SET BIT lv_prev_pos OF r_pwd_hash TO lv_bit. + ADD 1 TO lv_curr_pos. + ADD 1 TO lv_prev_pos. + ENDDO. + SET BIT 16 OF r_pwd_hash TO 0. + + ENDMETHOD. + + + METHOD shr14. + + DATA: + lv_bit TYPE i, + lv_curr_pos TYPE i, + lv_next_pos TYPE i. + + r_pwd_hash = i_pwd_hash. + + DO 14 TIMES. + lv_curr_pos = 15. + lv_next_pos = 16. + + DO 15 TIMES. + GET BIT lv_curr_pos OF r_pwd_hash INTO lv_bit. + SET BIT lv_next_pos OF r_pwd_hash TO lv_bit. + SUBTRACT 1 FROM lv_curr_pos. + SUBTRACT 1 FROM lv_next_pos. + ENDDO. + SET BIT 1 OF r_pwd_hash TO 0. + ENDDO. + + ENDMETHOD. + + + METHOD split_file. + + DATA: lt_hlp TYPE TABLE OF text255, + ls_hlp TYPE text255. + + DATA: lf_ext(10) TYPE c, + lf_dot_ext(10) TYPE c. + DATA: lf_anz TYPE i, + lf_len TYPE i. +** --------------------------------------------------------------------- + + CLEAR: lt_hlp, + ep_file, + ep_extension, + ep_dotextension. + +** Split the whole file at '.' + SPLIT ip_file AT '.' INTO TABLE lt_hlp. + +** get the extenstion from the last line of table + DESCRIBE TABLE lt_hlp LINES lf_anz. + IF lf_anz <= 1. + ep_file = ip_file. + RETURN. + ENDIF. + + READ TABLE lt_hlp INTO ls_hlp INDEX lf_anz. + ep_extension = ls_hlp. + lf_ext = ls_hlp. + IF NOT lf_ext IS INITIAL. + CONCATENATE '.' lf_ext INTO lf_dot_ext. + ENDIF. + ep_dotextension = lf_dot_ext. + +** get only the filename + lf_len = strlen( ip_file ) - strlen( lf_dot_ext ). + IF lf_len > 0. + ep_file = ip_file(lf_len). + ENDIF. + + ENDMETHOD. + + + METHOD structure_case. + DATA: lt_comp_str TYPE abap_component_tab. + + CASE is_component-type->kind. + WHEN cl_abap_typedescr=>kind_elem. "E Elementary Type + INSERT is_component INTO TABLE xt_components. + WHEN cl_abap_typedescr=>kind_table. "T Table + INSERT is_component INTO TABLE xt_components. + WHEN cl_abap_typedescr=>kind_struct. "S Structure + lt_comp_str = structure_recursive( is_component = is_component ). + INSERT LINES OF lt_comp_str INTO TABLE xt_components. + WHEN OTHERS. "cl_abap_typedescr=>kind_ref or cl_abap_typedescr=>kind_class or cl_abap_typedescr=>kind_intf. +* We skip it. for now. + ENDCASE. + ENDMETHOD. + + + METHOD structure_recursive. + DATA: lo_struct TYPE REF TO cl_abap_structdescr, + lt_components TYPE abap_component_tab, + ls_components TYPE abap_componentdescr. + + lo_struct ?= is_component-type. + lt_components = lo_struct->get_components( ). + + LOOP AT lt_components INTO ls_components. + structure_case( EXPORTING is_component = ls_components + CHANGING xt_components = rt_components ) . + ENDLOOP. + + ENDMETHOD. + + + METHOD time_to_excel_string. + DATA: lv_seconds_in_day TYPE i, + lv_day_fraction TYPE f, + lc_time_baseline TYPE t VALUE '000000', + lc_seconds_in_day TYPE i VALUE 86400. + + lv_seconds_in_day = ip_value - lc_time_baseline. + lv_day_fraction = lv_seconds_in_day / lc_seconds_in_day. + ep_value = ycl_ecb_common=>number_to_excel_string( ip_value = lv_day_fraction ). + ENDMETHOD. + + + METHOD unescape_string. + + CONSTANTS lcv_regex TYPE string VALUE `^'[^']` & `|` & " Beginning single ' OR + `[^']'$` & `|` & " Trailing single ' OR + `[^']'[^']`. " Single ' somewhere in between + + + DATA: lv_errormessage TYPE string. " Can't pass '...'(abc) to exception-class + +*--------------------------------------------------------------------* +* This method is used to extract the "real" string from an escaped string. +* An escaped string can be identified by a beginning ' which must be +* accompanied by a trailing ' +* All '' in between beginning and trailing ' are treated as single ' +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* When allowing clike-input parameters we might encounter trailing +* "real" blanks . These are automatically eliminated when moving +* the input parameter to a string. +*--------------------------------------------------------------------* + ev_unescaped_string = iv_escaped. " Pass through if not escaped + + CHECK ev_unescaped_string IS NOT INITIAL. " Nothing to do if empty + CHECK ev_unescaped_string(1) = `'`. " Nothing to do if not escaped + +*--------------------------------------------------------------------* +* Remove leading and trailing ' +*--------------------------------------------------------------------* + REPLACE REGEX `^'(.*)'$` IN ev_unescaped_string WITH '$1'. + IF sy-subrc <> 0. + lv_errormessage = 'Input not properly escaped - &'(002). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + +*--------------------------------------------------------------------* +* Any remaining single ' should not be here +*--------------------------------------------------------------------* + FIND REGEX lcv_regex IN ev_unescaped_string. + IF sy-subrc = 0. + lv_errormessage = 'Input not properly escaped - &'(002). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + +*--------------------------------------------------------------------* +* Replace '' with ' +*--------------------------------------------------------------------* + REPLACE ALL OCCURRENCES OF `''` IN ev_unescaped_string WITH `'`. + + + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_common.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_common.clas.testclasses.abap new file mode 100644 index 0000000..93d8f21 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_common.clas.testclasses.abap @@ -0,0 +1,1734 @@ +CLASS lcl_excel_common_test DEFINITION DEFERRED. +CLASS ycl_ecb_common DEFINITION LOCAL FRIENDS lcl_excel_common_test. + +*----------------------------------------------------------------------* +* CLASS lcl_Excel_Common_Test DEFINITION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_excel_common_test DEFINITION FOR TESTING + RISK LEVEL HARMLESS + DURATION SHORT. + + PRIVATE SECTION. +* ================ + TYPES: BEGIN OF ty_convert_range2column_a_row, + column_start TYPE yecb_cell_column_alpha, + column_start_int TYPE yecb_cell_column, + column_end TYPE yecb_cell_column_alpha, + column_end_int TYPE yecb_cell_column, + row_start TYPE yecb_cell_row, + row_end TYPE yecb_cell_row, + sheet TYPE string, + END OF ty_convert_range2column_a_row. + DATA: + lx_excel TYPE REF TO ycx_ecb, + ls_symsg_act LIKE sy, " actual messageinformation of exception + ls_symsg_exp LIKE sy, " expected messageinformation of exception + f_cut TYPE REF TO ycl_ecb_common. "class under test + + METHODS: setup. + METHODS: convert_column2alpha_simple FOR TESTING. + METHODS: convert_column2alpha_maxcol FOR TESTING. + METHODS: convert_column2alpha_last FOR TESTING. + METHODS: convert_column2alpha_oob FOR TESTING. + METHODS convert_column2int_basic FOR TESTING. + METHODS convert_column2int_from_int FOR TESTING RAISING cx_static_check. + METHODS convert_column2int_maxcol FOR TESTING. + METHODS convert_column2int_oob_empty FOR TESTING. + METHODS convert_column2int_oob_invalid FOR TESTING. + METHODS convert_column_a_row2columnrow FOR TESTING RAISING cx_static_check. + METHODS convert_columnrow2column_a_row FOR TESTING RAISING cx_static_check. + METHODS date_to_excel_string1 FOR TESTING RAISING cx_static_check. + METHODS date_to_excel_string2 FOR TESTING RAISING cx_static_check. + METHODS date_to_excel_string3 FOR TESTING RAISING cx_static_check. + METHODS date_to_excel_string4 FOR TESTING RAISING cx_static_check. + METHODS date_to_excel_string5 FOR TESTING RAISING cx_static_check. + METHODS date_to_excel_string6 FOR TESTING RAISING cx_static_check. + METHODS amount_to_excel_string1 FOR TESTING RAISING cx_static_check. + METHODS amount_to_excel_string2 FOR TESTING RAISING cx_static_check. + METHODS amount_to_excel_string3 FOR TESTING RAISING cx_static_check. + METHODS: encrypt_password FOR TESTING. + METHODS: excel_string_to_date FOR TESTING. + METHODS excel_string_to_time1 FOR TESTING RAISING cx_static_check. + METHODS excel_string_to_time2 FOR TESTING RAISING cx_static_check. + METHODS excel_string_to_time3 FOR TESTING RAISING cx_static_check. + METHODS excel_string_to_time4 FOR TESTING RAISING cx_static_check. + METHODS excel_string_to_time5 FOR TESTING RAISING cx_static_check. + METHODS time_to_excel_string1 FOR TESTING RAISING cx_static_check. + METHODS time_to_excel_string2 FOR TESTING RAISING cx_static_check. + METHODS time_to_excel_string3 FOR TESTING RAISING cx_static_check. + METHODS time_to_excel_string4 FOR TESTING RAISING cx_static_check. + METHODS: split_file FOR TESTING. + METHODS: convert_range2column_a_row FOR TESTING RAISING cx_static_check. + METHODS: assert_convert_range2column_a_ + IMPORTING + i_range TYPE clike + i_allow_1dim_range TYPE abap_bool DEFAULT abap_false + is_exp TYPE ty_convert_range2column_a_row + RAISING + cx_static_check. + METHODS: describe_structure FOR TESTING. + METHODS macro_calculate_cell_distance + IMPORTING + iv_reference_cell TYPE clike + iv_current_cell TYPE clike + iv_expected_column TYPE i + iv_expected_row TYPE i + RAISING + cx_static_check. + METHODS: calc_cell_dist_samecell FOR TESTING RAISING cx_static_check, + calc_cell_dist_down1pl FOR TESTING RAISING cx_static_check, + calc_cell_dist_downsome FOR TESTING RAISING cx_static_check, + calc_cell_dist_up1pl FOR TESTING RAISING cx_static_check, + calc_cell_dist_upsome FOR TESTING RAISING cx_static_check, + calc_cell_dist_right1pl FOR TESTING RAISING cx_static_check, + calc_cell_dist_rightsome FOR TESTING RAISING cx_static_check, + calc_cell_dist_left1pl FOR TESTING RAISING cx_static_check, + calc_cell_dist_leftsome FOR TESTING RAISING cx_static_check, + calc_cell_dist_fullpack FOR TESTING RAISING cx_static_check. + METHODS macro_shift_formula + IMPORTING + iv_reference_formula TYPE clike + iv_shift_cols TYPE i + iv_shift_rows TYPE i + iv_expected TYPE string. + METHODS: shift_formula_basic FOR TESTING, + shift_formula_rightdown FOR TESTING, + shift_formula_leftup FOR TESTING, + shift_formula_fixedcolrows FOR TESTING, + shift_formula_mixedfixedrows FOR TESTING, + shift_formula_rangename FOR TESTING, + shift_formula_stringlitconc FOR TESTING, + shift_formula_extref FOR TESTING, + shift_formula_charblanks FOR TESTING, + shift_formula_stringblanks FOR TESTING, + shift_formula_funcnoargs FOR TESTING, + shift_formula_nocellref FOR TESTING, + shift_formula_empty FOR TESTING, + shift_formula_referr_colunder FOR TESTING, + shift_formula_referr_rowunder FOR TESTING, + shift_formula_referr_rowcolund FOR TESTING, + shift_formula_sheet_nodigit FOR TESTING, + shift_formula_sheet_nodig FOR TESTING, + shift_formula_sheet_special FOR TESTING, + shift_formula_resp_blanks_1 FOR TESTING, + shift_formula_resp_blanks_2 FOR TESTING, + shift_formula_range FOR TESTING, + shift_formula_notcols FOR TESTING, + shift_formula_name FOR TESTING, + shift_formula_refcolumn1 FOR TESTING, + shift_formula_refcolumn2 FOR TESTING. + METHODS is_cell_in_range_ulc_in FOR TESTING. + METHODS is_cell_in_range_lrc_in FOR TESTING. + METHODS is_cell_in_range_leftside_out FOR TESTING. + METHODS is_cell_in_range_upperside_out FOR TESTING. + METHODS is_cell_in_range_rightside_out FOR TESTING. + METHODS is_cell_in_range_lowerside_out FOR TESTING. + METHODS escape_string_whitespace1 FOR TESTING. + METHODS escape_string_whitespace2 FOR TESTING. + METHODS escape_string_whitespace3 FOR TESTING. + METHODS escape_string_quote FOR TESTING. + METHODS escape_string_hyphen FOR TESTING. + METHODS escape_string_regular FOR TESTING. +ENDCLASS. + + +*----------------------------------------------------------------------* +* CLASS lcl_Excel_Common_Test IMPLEMENTATION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_excel_common_test IMPLEMENTATION. +* =========================================== + + METHOD setup. +* ============= + + CREATE OBJECT f_cut. + ENDMETHOD. "setup + + + METHOD convert_column2alpha_simple. +* ============================ + DATA ep_column TYPE yecb_cell_column_alpha. + +* Test 1. Simple test + TRY. + ep_column = ycl_ecb_common=>convert_column2alpha( 1 ). + + cl_abap_unit_assert=>assert_equals( + act = ep_column + exp = 'A' + msg = 'Wrong column conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + ENDMETHOD. "convert_column2alpha_simple + + + METHOD convert_column2alpha_maxcol. +* ============================ + DATA ep_column TYPE yecb_cell_column_alpha. + +* Test 2. Max column for OXML #16,384 = XFD + TRY. + ep_column = ycl_ecb_common=>convert_column2alpha( 16384 ). + + cl_abap_unit_assert=>assert_equals( + act = ep_column + exp = 'XFD' + msg = 'Wrong column conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + ENDMETHOD. "convert_column2alpha_maxcol + + + METHOD convert_column2alpha_last. +* ============================ + DATA ep_column TYPE yecb_cell_column_alpha. + +* Test 3. Index 0 is out of bounds + TRY. + ep_column = ycl_ecb_common=>convert_column2alpha( 0 ). + + cl_abap_unit_assert=>assert_equals( + act = ep_column + exp = 'A' + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>assert_equals( + act = lx_excel->error + exp = 'Index out of bounds' + msg = 'Colum index 0 is out of bounds, min column index is 1' + level = if_aunit_constants=>fatal + ). + ENDTRY. + ENDMETHOD. "convert_column2alpha_last + + + METHOD convert_column2alpha_oob. +* ============================ + DATA ep_column TYPE yecb_cell_column_alpha. + +* Test 4. Exception should be thrown index out of bounds + TRY. + ep_column = ycl_ecb_common=>convert_column2alpha( 16385 ). + + cl_abap_unit_assert=>assert_differs( + act = ep_column + exp = 'XFE' + msg = 'Colum index 16385 is out of bounds, max column index is 16384' + level = if_aunit_constants=>fatal + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>assert_equals( + act = lx_excel->error + exp = 'Index out of bounds' + msg = 'Wrong exception is thrown' + level = if_aunit_constants=>tolerable + ). + ENDTRY. + ENDMETHOD. "convert_Column2alpha_oob + + + METHOD convert_column2int_basic. +* ========================== +* Test 1. Basic test + DATA ep_column TYPE yecb_cell_column. + + TRY. + ep_column = ycl_ecb_common=>convert_column2int( 'A' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_column + exp = 1 + msg = 'Wrong column conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + ENDMETHOD. "convert_column2int_basic. + + + METHOD convert_column2int_from_int. + + DATA ep_column TYPE yecb_cell_column. + + ep_column = ycl_ecb_common=>convert_column2int( 5 ). + + cl_abap_unit_assert=>assert_equals( act = ep_column exp = 5 ). + + ENDMETHOD. + + + METHOD convert_column2int_maxcol. +* ========================== +* Test 2. Max column + DATA ep_column TYPE yecb_cell_column. + + TRY. + ep_column = ycl_ecb_common=>convert_column2int( 'XFD' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_column + exp = 16384 + msg = 'Wrong column conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + ENDMETHOD. "convert_column2int_maxcol + + + METHOD convert_column2int_oob_empty. +* ========================== +* Test 3. Out of bounds + DATA ep_column TYPE yecb_cell_column. + + TRY. + ep_column = ycl_ecb_common=>convert_column2int( '' ). + + cl_abap_unit_assert=>assert_differs( act = ep_column + exp = '0' + msg = 'Wrong column conversion' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb INTO lx_excel. + CLEAR: ls_symsg_act, + ls_symsg_exp. + ls_symsg_exp-msgid = 'ZABAP2XLSX'. + ls_symsg_exp-msgno = '800'. + ls_symsg_act-msgid = lx_excel->syst_at_raise-msgid. + ls_symsg_act-msgno = lx_excel->syst_at_raise-msgno. + cl_abap_unit_assert=>assert_equals( act = ls_symsg_act + exp = ls_symsg_exp + msg = 'Colum name should be a valid string' + level = if_aunit_constants=>fatal ). + ENDTRY. + ENDMETHOD. "convert_column2int_oob_empty. + + + METHOD convert_column2int_oob_invalid. +* ========================== +* Test 4. Out of bounds + DATA ep_column TYPE yecb_cell_column. + + TRY. + ep_column = ycl_ecb_common=>convert_column2int( 'XFE' ). + + cl_abap_unit_assert=>assert_differs( act = ep_column + exp = 16385 + msg = 'Wrong column conversion' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>assert_equals( act = lx_excel->error + exp = 'Index out of bounds' + msg = 'Colum XFE is out of range' + level = if_aunit_constants=>fatal ). + ENDTRY. + ENDMETHOD. "convert_column2int_oob_invalid. + + + METHOD convert_column_a_row2columnrow. + + DATA: cell_coords TYPE string. + + cell_coords = ycl_ecb_common=>convert_column_a_row2columnrow( i_column = 'B' i_row = 6 ). + + cl_abap_unit_assert=>assert_equals( act = cell_coords exp = 'B6' ). + + + cell_coords = ycl_ecb_common=>convert_column_a_row2columnrow( i_column = 2 i_row = 6 ). + + cl_abap_unit_assert=>assert_equals( act = cell_coords exp = 'B6' ). + + ENDMETHOD. + + + METHOD convert_columnrow2column_a_row. + + DATA: column TYPE yecb_cell_column_alpha, + column_int TYPE yecb_cell_column, + row TYPE yecb_cell_row. + + ycl_ecb_common=>convert_columnrow2column_a_row( + EXPORTING + i_columnrow = 'B6' + IMPORTING + e_column = column + e_column_int = column_int + e_row = row ). + + cl_abap_unit_assert=>assert_equals( act = column exp = 'B' msg = 'Invalid column (alpha)' ). + cl_abap_unit_assert=>assert_equals( act = column_int exp = 2 msg = 'Invalid column (numeric)' ). + cl_abap_unit_assert=>assert_equals( act = row exp = 6 msg = 'Invalid row' ). + + ENDMETHOD. + + + METHOD date_to_excel_string1. + DATA ep_value TYPE yecb_cell_value. + +* Test 1. Basic conversion + ep_value = ycl_ecb_common=>date_to_excel_string( '19000101' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = 1 + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD date_to_excel_string2. + DATA ep_value TYPE yecb_cell_value. + +* Check around the "Excel Leap Year" 1900 + ep_value = ycl_ecb_common=>date_to_excel_string( '19000228' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = 59 + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD date_to_excel_string3. + DATA ep_value TYPE yecb_cell_value. + + ep_value = ycl_ecb_common=>date_to_excel_string( '19000301' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = 61 + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD date_to_excel_string4. + DATA ep_value TYPE yecb_cell_value. + +* Test 2. Basic conversion + ep_value = ycl_ecb_common=>date_to_excel_string( '99991212' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = 2958446 + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD date_to_excel_string5. + DATA ep_value TYPE yecb_cell_value. + +* Test 3. Initial date + DATA: lv_date TYPE d. + ep_value = ycl_ecb_common=>date_to_excel_string( lv_date ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD date_to_excel_string6. + DATA ep_value TYPE yecb_cell_value. + +* Test 2. Basic conversion + DATA exp_value TYPE yecb_cell_value VALUE 0. + ep_value = ycl_ecb_common=>date_to_excel_string( '18991231' ). + + cl_abap_unit_assert=>assert_differs( + act = ep_value + exp = exp_value + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD amount_to_excel_string1. + DATA ep_value TYPE yecb_cell_value. + + ep_value = ycl_ecb_common=>number_to_excel_string( ip_value = '1003.99' + ip_currency = 'EUR' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '1003.99' + msg = 'Wrong currency amount conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD amount_to_excel_string2. + DATA ep_value TYPE yecb_cell_value. + + ep_value = ycl_ecb_common=>number_to_excel_string( ip_value = '-1003.99' + ip_currency = 'HUF' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '-100399' + msg = 'Wrong currency amount conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD amount_to_excel_string3. + DATA ep_value TYPE yecb_cell_value. + + ep_value = ycl_ecb_common=>number_to_excel_string( ip_value = '0' + ip_currency = 'HUF' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '0' + msg = 'Wrong currency amount conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD encrypt_password. +* ======================== + DATA lv_encrypted_pwd TYPE yecb_aes_password. + + TRY. + lv_encrypted_pwd = ycl_ecb_common=>encrypt_password( 'test' ). + + cl_abap_unit_assert=>assert_equals( + act = lv_encrypted_pwd + exp = 'CBEB' + msg = 'Wrong password encryption' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + ENDMETHOD. "encrypt_Password + + + METHOD excel_string_to_date. +* ============================ + DATA ep_value TYPE d. + + +* Test 1. Simple test -> ABAP Manage also date prior of 1900 + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '0' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '00000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. +* Check empty content + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '00000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. +* Check space character + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( ` ` ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '00000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. +* Check first Excel date 1/1/1900 + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '1' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '19000101' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. +* Check around the "Excel Leap Year" 1900 + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '59' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '19000228' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '61' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '19000301' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + +* Test 2. Simple test + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '1' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '19000101' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + +* Test 3. Last possible date + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '2958465' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '99991231' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical + ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>fail( + msg = 'unexpected exception' + level = if_aunit_constants=>critical " Error Severity + ). + ENDTRY. + +* Test 4. Exception should be thrown index out of bounds + TRY. + ep_value = ycl_ecb_common=>excel_string_to_date( '2958466' ). + + cl_abap_unit_assert=>fail( + msg = |Unexpected result '{ ep_value }'| + level = if_aunit_constants=>critical + ). + + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>assert_equals( + act = lx_excel->error + exp = 'Unable to interpret date' + msg = 'Time should be a valid date' + level = if_aunit_constants=>fatal + ). + ENDTRY. + ENDMETHOD. "excel_String_To_Date + + + METHOD excel_string_to_time1. + DATA ep_value TYPE t. + +* Test 1. Simple test + ep_value = ycl_ecb_common=>excel_string_to_time( '0' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>tolerable ). + + ENDMETHOD. + + METHOD excel_string_to_time2. + DATA ep_value TYPE t. +* Test 2. Simple test + + ep_value = ycl_ecb_common=>excel_string_to_time( '1' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD excel_string_to_time3. + DATA ep_value TYPE t. +* Test 3. Simple test + + ep_value = ycl_ecb_common=>excel_string_to_time( '0.99999' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '235959' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD excel_string_to_time4. + DATA ep_value TYPE t. +* Test 4. Also string greater than 1 should be managed + + ep_value = ycl_ecb_common=>excel_string_to_time( '4.1' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '022400' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD excel_string_to_time5. + DATA ep_value TYPE t. +* Test 4. string is not a number + TRY. + ep_value = ycl_ecb_common=>excel_string_to_time( 'NaN' ). + + cl_abap_unit_assert=>assert_differs( + act = ep_value + exp = '000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb INTO lx_excel. + cl_abap_unit_assert=>assert_equals( + act = lx_excel->error + exp = 'Unable to interpret time' + msg = 'Time should be a valid string' + level = if_aunit_constants=>fatal ). + ENDTRY. + ENDMETHOD. + + METHOD time_to_excel_string1. + DATA ep_value TYPE yecb_cell_value. + +* Test 1. Basic conversion + ep_value = ycl_ecb_common=>time_to_excel_string( '000001' ). + " A test directly in Excel returns the value 0.0000115740740740741000 + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '0.0000115740740741' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD time_to_excel_string2. + DATA ep_value TYPE yecb_cell_value. + +* Test 2. Basic conversion + ep_value = ycl_ecb_common=>time_to_excel_string( '235959' ). + " A test directly in Excel returns the value 0.9999884259259260000000 + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '0.9999884259259260' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD time_to_excel_string3. + DATA ep_value TYPE yecb_cell_value. + +* Test 3. Initial date + ep_value = ycl_ecb_common=>time_to_excel_string( '000000' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '0' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD time_to_excel_string4. + + DATA ep_value TYPE yecb_cell_value. + +* Test 2. Basic conversion + ep_value = ycl_ecb_common=>time_to_excel_string( '022400' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_value + exp = '0.1000000000000000' + msg = 'Wrong date conversion' + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD split_file. +* ============================ + + DATA: ep_file TYPE text255, + ep_extension TYPE char10, + ep_dotextension TYPE char10. + + +* Test 1. Basic conversion + ycl_ecb_common=>split_file( EXPORTING ip_file = 'filename.xml' + IMPORTING ep_file = ep_file + ep_extension = ep_extension + ep_dotextension = ep_dotextension ). + + cl_abap_unit_assert=>assert_equals( + act = ep_file + exp = 'filename' + msg = 'Split filename failed' + level = if_aunit_constants=>critical ). + + cl_abap_unit_assert=>assert_equals( + act = ep_extension + exp = 'xml' + msg = 'Split extension failed' + level = if_aunit_constants=>critical ). + + cl_abap_unit_assert=>assert_equals( + act = ep_dotextension + exp = '.xml' + msg = 'Split extension failed' + level = if_aunit_constants=>critical ). + +* Test 2. no extension + ycl_ecb_common=>split_file( EXPORTING ip_file = 'filename' + IMPORTING ep_file = ep_file + ep_extension = ep_extension + ep_dotextension = ep_dotextension ). + + cl_abap_unit_assert=>assert_equals( + act = ep_file + exp = 'filename' + msg = 'Split filename failed' + level = if_aunit_constants=>critical ). + + cl_abap_unit_assert=>assert_equals( + act = ep_extension + exp = '' + msg = 'Split extension failed' + level = if_aunit_constants=>critical ). + + cl_abap_unit_assert=>assert_equals( + act = ep_dotextension + exp = '' + msg = 'Split extension failed' + level = if_aunit_constants=>critical ). + + ENDMETHOD. "split_file + + METHOD convert_range2column_a_row. + DATA: lv_range TYPE string, + ls_exp TYPE ty_convert_range2column_a_row. + +* a) input empty --> nothing to do + lv_range = ''. + + CLEAR ls_exp. + + assert_convert_range2column_a_( i_range = lv_range is_exp = ls_exp ). + +* b) sheetname existing - starts with ' example 'Sheet 1'!$B$6:$D$13 + lv_range = `'Sheet 1'!$B$6:$D$13`. + + CLEAR ls_exp. + ls_exp-column_start = 'B'. + ls_exp-column_start_int = 2. + ls_exp-column_end = 'D'. + ls_exp-column_end_int = 4. + ls_exp-row_start = 6. + ls_exp-row_end = 13. + ls_exp-sheet = 'Sheet 1'. + + assert_convert_range2column_a_( i_range = lv_range is_exp = ls_exp ). + +* c) sheetname existing - does not start with ' example Sheet1!$B$6:$D$13 + lv_range = `Sheet1!B6:$D$13`. + + CLEAR ls_exp. + ls_exp-column_start = 'B'. + ls_exp-column_start_int = 2. + ls_exp-column_end = 'D'. + ls_exp-column_end_int = 4. + ls_exp-row_start = 6. + ls_exp-row_end = 13. + ls_exp-sheet = 'Sheet1'. + + assert_convert_range2column_a_( i_range = lv_range is_exp = ls_exp ). + +* d) no sheetname - just area example $B$6:$D$13 + lv_range = `$B$6:D13`. + + CLEAR ls_exp. + ls_exp-column_start = 'B'. + ls_exp-column_start_int = 2. + ls_exp-column_end = 'D'. + ls_exp-column_end_int = 4. + ls_exp-row_start = 6. + ls_exp-row_end = 13. + + assert_convert_range2column_a_( i_range = lv_range is_exp = ls_exp ). + +********************************************************************** +* 1 Dimensional Ranges - Ros or Cols Only (eg Print Tiles) +* + lv_range = `$2:$7`. + + CLEAR ls_exp. + + assert_convert_range2column_a_( i_range = lv_range i_allow_1dim_range = abap_false is_exp = ls_exp ). + +*** + lv_range = `$2:$7`. + + CLEAR ls_exp. + ls_exp-row_start = 2. + ls_exp-row_end = 7. + + assert_convert_range2column_a_( i_range = lv_range i_allow_1dim_range = abap_true is_exp = ls_exp ). + +*** + lv_range = `Sheet3!$D:$I`. + + CLEAR ls_exp. + ls_exp-column_start = 'D'. + ls_exp-column_start_int = 4. + ls_exp-column_end = 'I'. + ls_exp-column_end_int = 9. + ls_exp-sheet = 'Sheet3'. + + assert_convert_range2column_a_( i_range = lv_range i_allow_1dim_range = abap_true is_exp = ls_exp ). + + ENDMETHOD. "convert_range2column_a_row + + + METHOD assert_convert_range2column_a_. + + DATA: ls_act TYPE ty_convert_range2column_a_row, + lv_message TYPE string. + + ycl_ecb_common=>convert_range2column_a_row( + EXPORTING + i_range = i_range + i_allow_1dim_range = i_allow_1dim_range + IMPORTING + e_column_start = ls_act-column_start + e_column_start_int = ls_act-column_start_int + e_column_end = ls_act-column_end + e_column_end_int = ls_act-column_end_int + e_row_start = ls_act-row_start + e_row_end = ls_act-row_end + e_sheet = ls_act-sheet ). + + lv_message = `Invalid column start (alpha) for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-column_start + exp = is_exp-column_start + msg = lv_message ). + lv_message = `Invalid column start (numeric) for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-column_start_int + exp = is_exp-column_start_int + msg = lv_message ). + lv_message = `Invalid column end (alpha) for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-column_end + exp = is_exp-column_end + msg = lv_message ). + lv_message = `Invalid column end (numeric) for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-column_end_int + exp = is_exp-column_end_int + msg = lv_message ). + lv_message = `Invalid row start for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-row_start + exp = is_exp-row_start + msg = lv_message ). + lv_message = `Invalid row end for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-row_end + exp = is_exp-row_end + msg = lv_message ). + lv_message = `Invalid sheet for ` && i_range. + cl_abap_unit_assert=>assert_equals( + act = ls_act-sheet + exp = is_exp-sheet + msg = lv_message ). + + ENDMETHOD. + + + METHOD describe_structure. + DATA: ls_test TYPE yecb_pane. + DATA: lo_structdescr TYPE REF TO cl_abap_structdescr. + DATA: lt_structure TYPE ddfields. + FIELD-SYMBOLS: LIKE LINE OF lt_structure. + + " Test with DDIC Type + lo_structdescr ?= cl_abap_structdescr=>describe_by_data( p_data = ls_test ). + lt_structure = ycl_ecb_common=>describe_structure( io_struct = lo_structdescr ). + READ TABLE lt_structure ASSIGNING INDEX 1. + cl_abap_unit_assert=>assert_equals( + act = -fieldname + exp = 'YSPLIT' + msg = 'Describe structure failed' + level = if_aunit_constants=>critical ). + + " Test with local defined structure having DDIC and non DDIC elements + TYPES: + BEGIN OF t_test, + carrid TYPE string, + carrname TYPE string, + carrdesc TYPE string, + END OF t_test. + DATA: ls_ttest TYPE t_test. + + lo_structdescr ?= cl_abap_structdescr=>describe_by_data( p_data = ls_ttest ). + lt_structure = ycl_ecb_common=>describe_structure( io_struct = lo_structdescr ). + READ TABLE lt_structure ASSIGNING INDEX 1. + cl_abap_unit_assert=>assert_equals( + act = -fieldname + exp = 'CARRID' + msg = 'Describe structure failed' + level = if_aunit_constants=>critical ). + + ENDMETHOD. "describe_structure + + METHOD macro_calculate_cell_distance. + + DATA: lv_offset_rows TYPE i, + lv_offset_cols TYPE i, + lv_message TYPE string. + + ycl_ecb_common=>calculate_cell_distance( EXPORTING iv_reference_cell = iv_reference_cell + iv_current_cell = iv_current_cell + IMPORTING ev_row_difference = lv_offset_rows + ev_col_difference = lv_offset_cols ). +* Check delta columns + CONCATENATE 'Error calculating column difference in test:' + iv_reference_cell + '->' + iv_current_cell + INTO lv_message SEPARATED BY space. + cl_abap_unit_assert=>assert_equals( act = lv_offset_cols + exp = iv_expected_column + msg = lv_message + quit = 0 " continue tests + level = if_aunit_constants=>critical ). +* Check delta rows + CONCATENATE 'Error calculating row difference in test:' + iv_reference_cell + '->' + iv_current_cell + INTO lv_message SEPARATED BY space. + cl_abap_unit_assert=>assert_equals( act = lv_offset_rows + exp = iv_expected_row + msg = lv_message + quit = 0 " continue tests + level = if_aunit_constants=>critical ). + + ENDMETHOD. + + METHOD calc_cell_dist_samecell. + + " Same cell + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'C12' + iv_expected_column = 0 + iv_expected_row = 0 ). + ENDMETHOD. + + METHOD calc_cell_dist_down1pl. + + " Shift down 1 place + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'C13' + iv_expected_column = 0 + iv_expected_row = 1 ). + ENDMETHOD. + + METHOD calc_cell_dist_downsome. + + " Shift down some places + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'C25' + iv_expected_column = 0 + iv_expected_row = 13 ). + ENDMETHOD. + + METHOD calc_cell_dist_up1pl. + + " Shift up 1 place + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'C11' + iv_expected_column = 0 + iv_expected_row = -1 ). + ENDMETHOD. + + METHOD calc_cell_dist_upsome. + + " Shift up some place + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'C1' + iv_expected_column = 0 + iv_expected_row = -11 ). + ENDMETHOD. + + METHOD calc_cell_dist_right1pl. + + " Shift right 1 place + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'D12' + iv_expected_column = 1 + iv_expected_row = 0 ). + ENDMETHOD. + + METHOD calc_cell_dist_rightsome. + + " Shift right some places + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'AA12' + iv_expected_column = 24 + iv_expected_row = 0 ). + ENDMETHOD. + + METHOD calc_cell_dist_left1pl. + + " Shift left 1 place + macro_calculate_cell_distance( + iv_reference_cell = 'C12' + iv_current_cell = 'B12' + iv_expected_column = -1 + iv_expected_row = 0 ). + ENDMETHOD. + + METHOD calc_cell_dist_leftsome. + + " Shift left some place + macro_calculate_cell_distance( + iv_reference_cell = 'AA12' + iv_current_cell = 'C12' + iv_expected_column = -24 + iv_expected_row = 0 ). + ENDMETHOD. + + METHOD calc_cell_dist_fullpack. + + " The full package. + macro_calculate_cell_distance( + iv_reference_cell = 'AA121' + iv_current_cell = 'C12' + iv_expected_column = -24 + iv_expected_row = -109 ). + ENDMETHOD. + + METHOD macro_shift_formula. + + DATA: lv_resulting_formula TYPE string, + lv_message TYPE string, + lv_counter TYPE n LENGTH 8. + + ADD 1 TO lv_counter. + CLEAR lv_resulting_formula. + TRY. + lv_resulting_formula = ycl_ecb_common=>shift_formula( iv_reference_formula = iv_reference_formula + iv_shift_cols = iv_shift_cols + iv_shift_rows = iv_shift_rows ). + CONCATENATE 'Wrong result in test' + lv_counter + 'shifting formula ' + iv_reference_formula + INTO lv_message SEPARATED BY space. + cl_abap_unit_assert=>assert_equals( act = lv_resulting_formula + exp = iv_expected + msg = lv_message + quit = 0 " continue tests + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + CONCATENATE 'Unexpected exception occurred in test' + lv_counter + 'shifting formula ' + iv_reference_formula + INTO lv_message SEPARATED BY space. + cl_abap_unit_assert=>assert_equals( act = lv_resulting_formula + exp = iv_expected + msg = lv_message + quit = 0 " continue tests + level = if_aunit_constants=>critical ). + ENDTRY. + + ENDMETHOD. + + METHOD shift_formula_basic. + + " Very basic check + macro_shift_formula( + iv_reference_formula = 'C17' + iv_shift_cols = 0 + iv_shift_rows = 0 + iv_expected = 'C17' ). + + ENDMETHOD. + + METHOD shift_formula_rightdown. + + " Check shift right and down + macro_shift_formula( + iv_reference_formula = 'C17' + iv_shift_cols = 2 + iv_shift_rows = 3 + iv_expected = 'E20' ). + + ENDMETHOD. + + METHOD shift_formula_leftup. + + " Check shift left and up + macro_shift_formula( + iv_reference_formula = 'C17' + iv_shift_cols = -2 + iv_shift_rows = -3 + iv_expected = 'A14' ). + + ENDMETHOD. + + METHOD shift_formula_fixedcolrows. + + " Fixed columns/rows + macro_shift_formula( + iv_reference_formula = '$C$17' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = '$C$17' ). + + ENDMETHOD. + + METHOD shift_formula_mixedfixedrows. + + " Operators and Ranges, mixed fixed rows or columns + macro_shift_formula( + iv_reference_formula = 'SUM($C17:C$23)+C30' + iv_shift_cols = 1 + iv_shift_rows = 11 + iv_expected = 'SUM($C28:D$23)+D41' ). + + ENDMETHOD. + + METHOD shift_formula_rangename. + + " Operators and Rangename + macro_shift_formula( + iv_reference_formula = 'RNGNAME1+C7' + iv_shift_cols = -1 + iv_shift_rows = -4 + iv_expected = 'RNGNAME1+B3' ). + + ENDMETHOD. + + METHOD shift_formula_stringlitconc. + + " String literals and string concatenation + macro_shift_formula( + iv_reference_formula = '"Date:"&TEXT(B2)' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = '"Date:"&TEXT(C3)' ). + + ENDMETHOD. + + METHOD shift_formula_extref. + + " External sheet reference + macro_shift_formula( + iv_reference_formula = '[TEST6.XLSX]SHEET1!A1' + iv_shift_cols = 1 + iv_shift_rows = 11 + iv_expected = '[TEST6.XLSX]SHEET1!B12' ). + + ENDMETHOD. + + METHOD shift_formula_charblanks. + + " superflous blanks, multi-argument functions, literals in function, unknown functions + macro_shift_formula( + iv_reference_formula = `X(B13, "KK" ) ` + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = `X(C14, "KK" ) ` ). + + ENDMETHOD. + + METHOD shift_formula_stringblanks. + + " same as above - but with string input instead of Char-input + macro_shift_formula( + iv_reference_formula = `SIN(SIN(SIN(SIN(E22))))` + iv_shift_cols = 0 + iv_shift_rows = 1 + iv_expected = 'SIN(SIN(SIN(SIN(E23))))' ). + + ENDMETHOD. + + METHOD shift_formula_funcnoargs. + + " Functions w/o arguments, No cellreferences + macro_shift_formula( + iv_reference_formula = 'HEUTE()' + iv_shift_cols = 2 + iv_shift_rows = 5 + iv_expected = 'HEUTE()' ). + + ENDMETHOD. + + METHOD shift_formula_nocellref. + + " No cellreferences + macro_shift_formula( + iv_reference_formula = '"B2"' + iv_shift_cols = 2 + iv_shift_rows = 5 + iv_expected = '"B2"' ). + + ENDMETHOD. + + METHOD shift_formula_empty. + + " Empty + macro_shift_formula( + iv_reference_formula = '' + iv_shift_cols = 2 + iv_shift_rows = 5 + iv_expected = '' ). + + ENDMETHOD. + + METHOD shift_formula_referr_colunder. + + " Referencing error , column only , underflow + macro_shift_formula( + iv_reference_formula = 'A1+$A1+A$1+$A$1+B2' + iv_shift_cols = -1 + iv_shift_rows = 0 + iv_expected = '#REF!+$A1+#REF!+$A$1+A2' ). + + ENDMETHOD. + + METHOD shift_formula_referr_rowunder. + + " Referencing error , row only , underflow + macro_shift_formula( + iv_reference_formula = 'A1+$A1+A$1+$A$1+B2' + iv_shift_cols = 0 + iv_shift_rows = -1 + iv_expected = '#REF!+#REF!+A$1+$A$1+B1' ). + + ENDMETHOD. + + METHOD shift_formula_referr_rowcolund. + + " Referencing error , row and column , underflow + macro_shift_formula( + iv_reference_formula = 'A1+$A1+A$1+$A$1+B2' + iv_shift_cols = -1 + iv_shift_rows = -1 + iv_expected = '#REF!+#REF!+#REF!+$A$1+A1' ). + + ENDMETHOD. + + METHOD shift_formula_sheet_nodigit. + + " Sheet name not ending with digit + macro_shift_formula( + iv_reference_formula = 'Sheet!A1' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'Sheet!B2' ). + + ENDMETHOD. + + METHOD shift_formula_sheet_nodig. + + " Sheet name ending with digit + macro_shift_formula( + iv_reference_formula = 'Sheet2!A1' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'Sheet2!B2' ). + + ENDMETHOD. + + METHOD shift_formula_sheet_special. + + " Sheet name with special characters + macro_shift_formula( + iv_reference_formula = |'Sheet name'!A1| + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = |'Sheet name'!B2| ). + + ENDMETHOD. + + METHOD shift_formula_resp_blanks_1. + + " Respecting blanks + macro_shift_formula( + iv_reference_formula = 'SUBTOTAL(109,Table1[SUM 1])' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'SUBTOTAL(109,Table1[SUM 1])' ). + + ENDMETHOD. + + METHOD shift_formula_resp_blanks_2. + + " Respecting blanks + macro_shift_formula( + iv_reference_formula = 'B4 & C4' + iv_shift_cols = 0 + iv_shift_rows = 1 + iv_expected = 'B5 & C5' ). + + ENDMETHOD. + + METHOD shift_formula_range. + + " F_1 is a range name, not a cell address + macro_shift_formula( + iv_reference_formula = 'SUM(F_1,F_2)' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'SUM(F_1,F_2)' ). + + ENDMETHOD. + + METHOD shift_formula_notcols. + " RC are not columns + macro_shift_formula( + iv_reference_formula = 'INDIRECT("RC[4]",FALSE)' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'INDIRECT("RC[4]",FALSE)' ). + + ENDMETHOD. + + METHOD shift_formula_name. + + " A1 is a sheet name + macro_shift_formula( + iv_reference_formula = |'A1'!$A$1| + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = |'A1'!$A$1| ). + + ENDMETHOD. + + METHOD shift_formula_refcolumn1. + + " Reference to another column in the same row of a Table, with a space in the column name + macro_shift_formula( + iv_reference_formula = 'Tbl[[#This Row],[Air fare]]' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'Tbl[[#This Row],[Air fare]]' ). + + ENDMETHOD. + + METHOD shift_formula_refcolumn2. + + " Reference to another column in the same row of a Table, inside more complex expression + macro_shift_formula( + iv_reference_formula = 'Tbl[[#This Row],[Air]]+A1' + iv_shift_cols = 1 + iv_shift_rows = 1 + iv_expected = 'Tbl[[#This Row],[Air]]+B2' ). + + ENDMETHOD. + + METHOD is_cell_in_range_ulc_in. +* Test 1: upper left corner (in range) + DATA ep_cell_in_range TYPE abap_bool. + + TRY. + ep_cell_in_range = ycl_ecb_common=>is_cell_in_range( + ip_column = 'B' + ip_row = 2 + ip_range = 'B2:D4' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_cell_in_range + exp = abap_true + msg = 'Check cell in range failed' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + cl_abap_unit_assert=>fail( + msg = 'Unexpected exception' + level = if_aunit_constants=>critical ). + ENDTRY. + ENDMETHOD. "is_cell_in_range_ulc_in + + METHOD is_cell_in_range_lrc_in. +* Test 2: lower right corner (in range) + DATA ep_cell_in_range TYPE abap_bool. + + TRY. + ep_cell_in_range = ycl_ecb_common=>is_cell_in_range( + ip_column = 'D' + ip_row = 4 + ip_range = 'B2:D4' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_cell_in_range + exp = abap_true + msg = 'Check cell in range failed' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + cl_abap_unit_assert=>fail( + msg = 'Unexpected exception' + level = if_aunit_constants=>critical ). + ENDTRY. + ENDMETHOD. "is_cell_in_range_lrc_in + + METHOD is_cell_in_range_leftside_out. +* Test 3: left side (out of range) + DATA ep_cell_in_range TYPE abap_bool. + + TRY. + ep_cell_in_range = ycl_ecb_common=>is_cell_in_range( + ip_column = 'A' + ip_row = 3 + ip_range = 'B2:D4' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_cell_in_range + exp = abap_false + msg = 'Check cell in range failed' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + cl_abap_unit_assert=>fail( + msg = 'Unexpected exception' + level = if_aunit_constants=>critical ). + ENDTRY. + ENDMETHOD. "is_cell_in_range_leftside_out + + METHOD is_cell_in_range_upperside_out. +* Test 4: upper side (out of range) + DATA ep_cell_in_range TYPE abap_bool. + + TRY. + ep_cell_in_range = ycl_ecb_common=>is_cell_in_range( + ip_column = 'C' + ip_row = 1 + ip_range = 'B2:D4' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_cell_in_range + exp = abap_false + msg = 'Check cell in range failed' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + cl_abap_unit_assert=>fail( + msg = 'Unexpected exception' + level = if_aunit_constants=>critical ). + ENDTRY. + ENDMETHOD. "is_cell_in_range_upperside_out + + METHOD is_cell_in_range_rightside_out. +* Test 5: right side (out of range) + DATA ep_cell_in_range TYPE abap_bool. + + TRY. + ep_cell_in_range = ycl_ecb_common=>is_cell_in_range( + ip_column = 'E' + ip_row = 3 + ip_range = 'B2:D4' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_cell_in_range + exp = abap_false + msg = 'Check cell in range failed' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + cl_abap_unit_assert=>fail( + msg = 'Unexpected exception' + level = if_aunit_constants=>critical ). + ENDTRY. + ENDMETHOD. "is_cell_in_range_rightside_out + + METHOD is_cell_in_range_lowerside_out. +* Test 6: lower side (out of range) + DATA ep_cell_in_range TYPE abap_bool. + + TRY. + ep_cell_in_range = ycl_ecb_common=>is_cell_in_range( + ip_column = 'C' + ip_row = 5 + ip_range = 'B2:D4' ). + + cl_abap_unit_assert=>assert_equals( + act = ep_cell_in_range + exp = abap_false + msg = 'Check cell in range failed' + level = if_aunit_constants=>critical ). + CATCH ycx_ecb. + cl_abap_unit_assert=>fail( + msg = 'Unexpected exception' + level = if_aunit_constants=>critical ). + ENDTRY. + ENDMETHOD. "is_cell_in_range_lowerside_out. + + METHOD escape_string_hyphen. + DATA: name TYPE string, + escaped_name TYPE string. + + name = `A-B`. + + escaped_name = ycl_ecb_common=>escape_string( name ). + + cl_abap_unit_assert=>assert_equals( act = escaped_name + exp = `'A-B'` + msg = 'Escaping - failed' ). + + ENDMETHOD. + + METHOD escape_string_quote. + DATA: name TYPE string, + escaped_name TYPE string. + + name = `A'B`. + + escaped_name = ycl_ecb_common=>escape_string( name ). + + cl_abap_unit_assert=>assert_equals( act = escaped_name + exp = `'A''B'` + msg = `Escaping ' failed` ). + + ENDMETHOD. + + METHOD escape_string_regular. + DATA: name TYPE string, + escaped_name TYPE string. + + name = `Ab1`. + + escaped_name = ycl_ecb_common=>escape_string( name ). + + cl_abap_unit_assert=>assert_equals( act = escaped_name + exp = `Ab1` + msg = 'Escaped for no reason' ). + + ENDMETHOD. + + METHOD escape_string_whitespace1. + DATA: name TYPE string, + escaped_name TYPE string. + + name = `A B`. + + escaped_name = ycl_ecb_common=>escape_string( name ). + + cl_abap_unit_assert=>assert_equals( act = escaped_name + exp = `'A B'` + msg = `Escaping ' ' (space) failed` ). + + ENDMETHOD. + + METHOD escape_string_whitespace2. + DATA: name TYPE string, + escaped_name TYPE string. + + name = `A` && cl_abap_char_utilities=>horizontal_tab && `B`. + + escaped_name = ycl_ecb_common=>escape_string( name ). + + cl_abap_unit_assert=>assert_equals( act = escaped_name + exp = `'A` && cl_abap_char_utilities=>horizontal_tab && `B'` + msg = `Escaping TAB failed` ). + + ENDMETHOD. + + METHOD escape_string_whitespace3. + DATA: name TYPE string, + escaped_name TYPE string. + + name = `A` && cl_abap_char_utilities=>newline && `B`. + + escaped_name = ycl_ecb_common=>escape_string( name ). + + cl_abap_unit_assert=>assert_equals( act = escaped_name + exp = `'A` && cl_abap_char_utilities=>newline && `B'` + msg = `Escaping LF failed` ). + + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_common.clas.xml b/src/abap2xlsx/ycl_ecb_common.clas.xml new file mode 100644 index 0000000..bf58be6 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_common.clas.xml @@ -0,0 +1,406 @@ + + + + + + YCL_ECB_COMMON + E + Static common methods + 1 + X + X + X + X + + + + I + 001 + Invalid range + 60 + + + I + 002 + Input not properly escaped - & + 60 + + + I + 003 + Unable to interpret input as column + 60 + + + I + 004 + Index out of bounds + 60 + + + I + 005 + Excel Workbook (*.xlsx)|*.xlsx| + 80 + + + + + CALCULATE_CELL_DISTANCE + E + Give distance between two cells + + + CALCULATE_CELL_DISTANCE + I + Give distance between two cells + + + CHAR2HEX + E + Character to Hexadecimal + + + CHAR2HEX + I + Character to Hexadecimal + + + CLASS_CONSTRUCTOR + E + CLASS_CONSTRUCTOR + + + CONVERT_COLUMN2ALPHA + E + Convert column indicator to Alpha + + + CONVERT_COLUMN2ALPHA + I + Convert column indicator to Alpha + + + CONVERT_COLUMN2INT + E + Convert column indicator to Integer + + + CONVERT_COLUMN2INT + I + Convert column indicator to Integer + + + CONVERT_COLUMNROW2COLUMN_A_ROW + E + Convert ColumnRow i.e. AB34 to AB and 34 + + + CONVERT_COLUMNROW2COLUMN_A_ROW + I + Convert ColumnRow i.e. AB34 to AB and 34 + + + CONVERT_RANGE2COLUMN_A_ROW + E + Converts Sheet1!AB34:CD56 to Sheet1, AB, 34, CD, 56 + + + CONVERT_RANGE2COLUMN_A_ROW + I + Converts Sheet1!AB34:CD56 to Sheet1, AB, 34, CD, 56 + + + C_EXCEL_1900_LEAP_YEAR + E + Excel baseline date + + + C_EXCEL_1900_LEAP_YEAR + I + Excel baseline date + + + C_EXCEL_BASELINE_DATE + E + Excel baseline date + + + C_EXCEL_BASELINE_DATE + I + Excel baseline date + + + C_EXCEL_COL_MODULE + E + 2 byte integer (signed) + + + C_EXCEL_COL_MODULE + I + 2 byte integer (signed) + + + C_EXCEL_NUMFMT_OFFSET + E + 2 byte integer (signed) + + + C_EXCEL_NUMFMT_OFFSET + I + 2 byte integer (signed) + + + C_EXCEL_SHEET_MAX_COL + E + 2 byte integer (signed) + + + C_EXCEL_SHEET_MAX_COL + I + 2 byte integer (signed) + + + C_EXCEL_SHEET_MAX_ROW + E + 2 byte integer (signed) + + + C_EXCEL_SHEET_MIN_COL + E + 2 byte integer (signed) + + + C_EXCEL_SHEET_MIN_COL + I + 2 byte integer (signed) + + + C_EXCEL_SHEET_MIN_ROW + E + 2 byte integer (signed) + + + C_SPRAS_EN + E + Language Key + + + C_SPRAS_EN + I + Language Key + + + C_XLSX_FILE_FILTER + E + File filter + + + C_XLSX_FILE_FILTER + I + File filter + + + DATE_TO_EXCEL_STRING + E + Convert date from SAP format to Excel + + + DATE_TO_EXCEL_STRING + I + Convert date from SAP format to Excel + + + DESCRIBE_STRUCTURE + E + Describe database info of structure + + + DESCRIBE_STRUCTURE + I + Describe database info of structure + + + DETERMINE_RESULTING_FORMULA + E + Determine formula if copied to another cell + + + DETERMINE_RESULTING_FORMULA + I + Determine formula if copied to another cell + + + ENCRYPT_PASSWORD + E + Encrypt password + + + ENCRYPT_PASSWORD + I + Encrypt password + + + ESCAPE_STRING + E + Escape a string + + + ESCAPE_STRING + I + Escape a string + + + EXCEL_STRING_TO_DATE + E + Convert date from Excel format to SAP + + + EXCEL_STRING_TO_DATE + I + Convert date from Excel format to SAP + + + EXCEL_STRING_TO_NUMBER + E + Convert number from Excel format to SAP + + + EXCEL_STRING_TO_TIME + E + Convert time from Excel format to SAP + + + EXCEL_STRING_TO_TIME + I + Convert time from Excel format to SAP + + + GET_FIELDCATALOG + E + Creates field catalog for BIND_TABLE based on internal table + + + GET_FIELDCATALOG + I + Creates field catalog for BIND_TABLE based on internal table + + + IS_CELL_IN_RANGE + E + Check if cell is part of a range + + + NUMBER_TO_EXCEL_STRING + E + Converts number to string representation in Excel format + + + NUMBER_TO_EXCEL_STRING + I + Converts number to string representation in Excel format + + + O_CONV + E + Code Page and Endian Conversion (System Format -> External) + + + O_CONV + I + Code Page and Endian Conversion (System Format -> External) + + + RECURSIVE_CLASS_TO_STRUCT + E + Move class to structure + + + RECURSIVE_CLASS_TO_STRUCT + I + Move class to structure + + + RECURSIVE_STRUCT_TO_CLASS + E + Move structure to class + + + RECURSIVE_STRUCT_TO_CLASS + I + Move structure to class + + + SHIFT_FORMULA + E + Shift formula from one cell to another + + + SHIFT_FORMULA + I + Shift formula from one cell to another + + + SHL01 + E + Secret function + + + SHR14 + E + Secret function + + + SPLIT_FILE + E + File & Extension disconnect (clone of FM CV120_SPLIT_FILE) + + + SPLIT_FILE + I + File & Extension disconnect (clone of FM CV120_SPLIT_FILE) + + + STRUCTURE_CASE + E + Case stement for recursive + + + STRUCTURE_CASE + I + Case stement for recursive + + + STRUCTURE_RECURSIVE + E + Get structure details + + + STRUCTURE_RECURSIVE + I + Get structure details + + + TIME_TO_EXCEL_STRING + E + Convert time from SAP format to Excel + + + TIME_TO_EXCEL_STRING + I + Convert time from SAP format to Excel + + + UNESCAPE_STRING + E + Unescape + + + UNESCAPE_STRING + I + Unescape + + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter.clas.abap b/src/abap2xlsx/ycl_ecb_converter.clas.abap new file mode 100644 index 0000000..807ced5 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter.clas.abap @@ -0,0 +1,1817 @@ +CLASS ycl_ecb_converter DEFINITION + PUBLIC + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_CONVERTER +*"* do not include other source files here!!! + PUBLIC SECTION. + + CLASS-METHODS class_constructor . + METHODS ask_option + RETURNING + VALUE(rs_option) TYPE yecb_s_converter_option + RAISING + ycx_ecb . + METHODS convert + IMPORTING + !is_option TYPE yecb_s_converter_option OPTIONAL + !io_alv TYPE REF TO object OPTIONAL + !it_table TYPE STANDARD TABLE OPTIONAL + !i_row_int TYPE i DEFAULT 1 + !i_column_int TYPE i DEFAULT 1 + !i_table TYPE flag OPTIONAL + !i_style_table TYPE yecb_table_style OPTIONAL + !io_worksheet TYPE REF TO ycl_ecb_worksheet OPTIONAL + CHANGING + !co_excel TYPE REF TO ycl_ecb OPTIONAL + RAISING + ycx_ecb . + METHODS create_path + RETURNING + VALUE(r_path) TYPE string . + METHODS get_file + EXPORTING + !e_bytecount TYPE i + !et_file TYPE solix_tab + !e_file TYPE xstring + RAISING + ycx_ecb . + METHODS get_option + RETURNING + VALUE(rs_option) TYPE yecb_s_converter_option . + METHODS open_file + RAISING + ycx_ecb . + METHODS set_option + IMPORTING + !is_option TYPE yecb_s_converter_option . + METHODS write_file + IMPORTING + !i_path TYPE string OPTIONAL + RAISING + ycx_ecb . +*"* protected components of class ZCL_EXCEL_CONVERTER +*"* do not include other source files here!!! + PROTECTED SECTION. + + TYPES: + BEGIN OF t_relationship, + id TYPE string, + type TYPE string, + target TYPE string, + END OF t_relationship . + TYPES: + BEGIN OF t_fileversion, + appname TYPE string, + lastedited TYPE string, + lowestedited TYPE string, + rupbuild TYPE string, + codename TYPE string, + END OF t_fileversion . + TYPES: + BEGIN OF t_sheet, + name TYPE string, + sheetid TYPE string, + id TYPE string, + END OF t_sheet . + TYPES: + BEGIN OF t_workbookpr, + codename TYPE string, + defaultthemeversion TYPE string, + END OF t_workbookpr . + TYPES: + BEGIN OF t_sheetpr, + codename TYPE string, + END OF t_sheetpr . + + DATA w_row_int TYPE yecb_cell_row VALUE 1. "#EC NOTEXT . . . . . . . . . . " . + DATA w_col_int TYPE yecb_cell_column VALUE 1. "#EC NOTEXT . . . . . . . . . . " . +*"* private components of class ZCL_EXCEL_CONVERTER +*"* do not include other source files here!!! + PRIVATE SECTION. + CLASS-METHODS get_subclasses + IMPORTING + is_clskey TYPE seoclskey + CHANGING + ct_classes TYPE seor_implementing_keys. + + DATA wo_excel TYPE REF TO ycl_ecb . + DATA wo_worksheet TYPE REF TO ycl_ecb_worksheet . + DATA wo_autofilter TYPE REF TO ycl_ecb_autofilter . + DATA wo_table TYPE REF TO data . + DATA wo_data TYPE REF TO data . + DATA wt_fieldcatalog TYPE yecb_t_converter_fcat . + DATA ws_layout TYPE yecb_s_converter_layo . + DATA wt_colors TYPE yecb_t_converter_col . + DATA wt_filter TYPE yecb_t_converter_fil . + CLASS-DATA wt_objects TYPE tt_alv_types . + CLASS-DATA w_fcount TYPE n LENGTH 3 . + DATA wt_sort_values TYPE tt_sort_values . + DATA wt_subtotal_rows TYPE tt_subtotal_rows . + DATA wt_styles TYPE tt_styles . + CONSTANTS c_type_hdr TYPE c VALUE 'H'. "#EC NOTEXT + CONSTANTS c_type_str TYPE c VALUE 'P'. "#EC NOTEXT + CONSTANTS c_type_nor TYPE c VALUE 'N'. "#EC NOTEXT + CONSTANTS c_type_sub TYPE c VALUE 'S'. "#EC NOTEXT + CONSTANTS c_type_tot TYPE c VALUE 'T'. "#EC NOTEXT + DATA wt_color_styles TYPE tt_color_styles . + CLASS-DATA ws_option TYPE yecb_s_converter_option . + CLASS-DATA ws_indx TYPE indx . + + CLASS-METHODS init_option . + CLASS-METHODS get_alv_converters. + METHODS bind_table + IMPORTING + !i_style_table TYPE yecb_table_style + RETURNING + VALUE(r_freeze_col) TYPE int1 + RAISING + ycx_ecb . + METHODS bind_cells + RETURNING + VALUE(r_freeze_col) TYPE int1 + RAISING + ycx_ecb . + METHODS clean_fieldcatalog . + METHODS create_color_style + IMPORTING + !i_style TYPE yecb_cell_style + !is_colors TYPE yecb_s_converter_col + RETURNING + VALUE(ro_style) TYPE REF TO ycl_ecb_style . + METHODS create_formular_subtotal + IMPORTING + !i_row_int_start TYPE yecb_cell_row + !i_row_int_end TYPE yecb_cell_row + !i_column TYPE yecb_cell_column_alpha + !i_totals_function TYPE yecb_table_totals_function + RETURNING + VALUE(r_formula) TYPE string . + METHODS create_formular_total + IMPORTING + !i_row_int TYPE yecb_cell_row + !i_column TYPE yecb_cell_column_alpha + !i_totals_function TYPE yecb_table_totals_function + RETURNING + VALUE(r_formula) TYPE string . + METHODS create_style_hdr + IMPORTING + !i_alignment TYPE yecb_alignment OPTIONAL + RETURNING + VALUE(ro_style) TYPE REF TO ycl_ecb_style . + METHODS create_style_normal + IMPORTING + !i_alignment TYPE yecb_alignment OPTIONAL + !i_inttype TYPE abap_typekind OPTIONAL + !i_decimals TYPE int1 OPTIONAL + RETURNING + VALUE(ro_style) TYPE REF TO ycl_ecb_style . + METHODS create_style_stripped + IMPORTING + !i_alignment TYPE yecb_alignment OPTIONAL + !i_inttype TYPE abap_typekind OPTIONAL + !i_decimals TYPE int1 OPTIONAL + RETURNING + VALUE(ro_style) TYPE REF TO ycl_ecb_style . + METHODS create_style_subtotal + IMPORTING + !i_alignment TYPE yecb_alignment OPTIONAL + !i_inttype TYPE abap_typekind OPTIONAL + !i_decimals TYPE int1 OPTIONAL + RETURNING + VALUE(ro_style) TYPE REF TO ycl_ecb_style . + METHODS create_style_total + IMPORTING + !i_alignment TYPE yecb_alignment OPTIONAL + !i_inttype TYPE abap_typekind OPTIONAL + !i_decimals TYPE int1 OPTIONAL + RETURNING + VALUE(ro_style) TYPE REF TO ycl_ecb_style . + METHODS create_table . + METHODS create_text_subtotal + IMPORTING + !i_value TYPE any + !i_totals_function TYPE yecb_table_totals_function + RETURNING + VALUE(r_text) TYPE string . + METHODS create_worksheet + IMPORTING + !i_table TYPE flag DEFAULT 'X' + !i_style_table TYPE yecb_table_style + RAISING + ycx_ecb . + METHODS execute_converter + IMPORTING + !io_object TYPE REF TO object + !it_table TYPE STANDARD TABLE + RAISING + ycx_ecb . + METHODS get_color_style + IMPORTING + !i_row TYPE yecb_cell_row + !i_fieldname TYPE fieldname + !i_style TYPE yecb_cell_style + RETURNING + VALUE(r_style) TYPE yecb_cell_style . + METHODS get_function_number + IMPORTING + !i_totals_function TYPE yecb_table_totals_function + RETURNING + VALUE(r_function_number) TYPE int1 . + METHODS get_style + IMPORTING + !i_type TYPE ty_style_type + !i_alignment TYPE yecb_alignment DEFAULT space + !i_inttype TYPE abap_typekind DEFAULT space + !i_decimals TYPE int1 DEFAULT 0 + RETURNING + VALUE(r_style) TYPE yecb_cell_style . + METHODS loop_normal + IMPORTING + !i_row_int TYPE yecb_cell_row + !i_col_int TYPE yecb_cell_column + RETURNING + VALUE(r_freeze_col) TYPE int1 + RAISING + ycx_ecb . + METHODS loop_subtotal + IMPORTING + !i_row_int TYPE yecb_cell_row + !i_col_int TYPE yecb_cell_column + RETURNING + VALUE(r_freeze_col) TYPE int1 + RAISING + ycx_ecb . + METHODS set_autofilter_area . + METHODS set_cell_format + IMPORTING + !i_inttype TYPE abap_typekind + !i_decimals TYPE int1 + RETURNING + VALUE(r_format) TYPE yecb_number_format . + METHODS set_fieldcatalog . +ENDCLASS. + + + +CLASS ycl_ecb_converter IMPLEMENTATION. + + + METHOD ask_option. + DATA: ls_sval TYPE sval, + lt_sval TYPE STANDARD TABLE OF sval, + l_returncode TYPE string, + lt_fields TYPE ddfields, + ls_fields TYPE dfies. + + FIELD-SYMBOLS: TYPE any. + + rs_option = ws_option. + + CALL FUNCTION 'DDIF_FIELDINFO_GET' + EXPORTING + tabname = 'ZEXCEL_S_CONVERTER_OPTION' + TABLES + dfies_tab = lt_fields + EXCEPTIONS + not_found = 1 + internal_error = 2 + OTHERS = 3. + IF sy-subrc <> 0. + MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno + WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. + ENDIF. + + LOOP AT lt_fields INTO ls_fields. + ASSIGN COMPONENT ls_fields-fieldname OF STRUCTURE ws_option TO . + IF sy-subrc = 0. + CLEAR ls_sval. + ls_sval-tabname = ls_fields-tabname. + ls_sval-fieldname = ls_fields-fieldname. + ls_sval-value = . + ls_sval-field_attr = space. + ls_sval-field_obl = space. + ls_sval-comp_code = space. + ls_sval-fieldtext = ls_fields-scrtext_m. + ls_sval-comp_tab = space. + ls_sval-comp_field = space. + ls_sval-novaluehlp = space. + INSERT ls_sval INTO TABLE lt_sval. + ENDIF. + ENDLOOP. + + CALL FUNCTION 'POPUP_GET_VALUES' + EXPORTING + popup_title = 'Excel creation options'(008) + IMPORTING + returncode = l_returncode + TABLES + fields = lt_sval + EXCEPTIONS + error_in_fields = 1 + OTHERS = 2. + IF sy-subrc <> 0. + MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno + WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. + ELSEIF l_returncode = 'A'. + RAISE EXCEPTION TYPE ycx_ecb. + ELSE. + LOOP AT lt_sval INTO ls_sval. + ASSIGN COMPONENT ls_sval-fieldname OF STRUCTURE ws_option TO . + IF sy-subrc = 0. + = ls_sval-value. + ENDIF. + ENDLOOP. + set_option( is_option = ws_option ) . + rs_option = ws_option. + ENDIF. + ENDMETHOD. + + + METHOD bind_cells. + +* Do we need subtotals with grouping + READ TABLE wt_fieldcatalog TRANSPORTING NO FIELDS WITH KEY is_subtotalled = abap_true. + IF sy-subrc = 0 . + r_freeze_col = loop_subtotal( i_row_int = w_row_int + i_col_int = w_col_int ) . + ELSE. + r_freeze_col = loop_normal( i_row_int = w_row_int + i_col_int = w_col_int ) . + ENDIF. + + ENDMETHOD. + + + METHOD bind_table. + DATA: lt_field_catalog TYPE yecb_t_fieldcatalog, + ls_field_catalog TYPE yecb_s_fieldcatalog, + ls_fcat TYPE yecb_s_converter_fcat, + lo_column TYPE REF TO ycl_ecb_column, + lv_col_int TYPE yecb_cell_column, + lv_col_alpha TYPE yecb_cell_column_alpha, + ls_settings TYPE yecb_s_table_settings, + lv_line TYPE i. + + FIELD-SYMBOLS: TYPE ANY TABLE. + + ASSIGN wo_data->* TO . + + ls_settings-table_style = i_style_table. + ls_settings-top_left_column = ycl_ecb_common=>convert_column2alpha( ip_column = w_col_int ). + ls_settings-top_left_row = w_row_int. + ls_settings-show_row_stripes = ws_layout-is_stripped. + + DESCRIBE TABLE wt_fieldcatalog LINES lv_line. + lv_line = lv_line + 1 + w_col_int. + ls_settings-bottom_right_column = ycl_ecb_common=>convert_column2alpha( ip_column = lv_line ). + + DESCRIBE TABLE LINES lv_line. + ls_settings-bottom_right_row = lv_line + 1 + w_row_int. + SORT wt_fieldcatalog BY position. + LOOP AT wt_fieldcatalog INTO ls_fcat. + MOVE-CORRESPONDING ls_fcat TO ls_field_catalog. + ls_field_catalog-dynpfld = abap_true. + INSERT ls_field_catalog INTO TABLE lt_field_catalog. + ENDLOOP. + + wo_worksheet->bind_table( + EXPORTING + ip_table = + it_field_catalog = lt_field_catalog + is_table_settings = ls_settings + IMPORTING + es_table_settings = ls_settings + ). + LOOP AT wt_fieldcatalog INTO ls_fcat. + lv_col_int = w_col_int + ls_fcat-position - 1. + lv_col_alpha = ycl_ecb_common=>convert_column2alpha( lv_col_int ). +* Freeze panes + IF ls_fcat-fix_column = abap_true. + ADD 1 TO r_freeze_col. + ENDIF. +* Now let's check for optimized + IF ls_fcat-is_optimized = abap_true. + lo_column = wo_worksheet->get_column( ip_column = lv_col_alpha ). + lo_column->set_auto_size( ip_auto_size = abap_true ) . + ENDIF. +* Now let's check for visible + IF ls_fcat-is_hidden = abap_true. + lo_column = wo_worksheet->get_column( ip_column = lv_col_alpha ). + lo_column->set_visible( ip_visible = abap_false ) . + ENDIF. + ENDLOOP. + + ENDMETHOD. + + + METHOD class_constructor. + DATA: ls_objects TYPE ts_alv_types. + DATA: ls_option TYPE yecb_s_converter_option, + l_uname TYPE sy-uname. + + GET PARAMETER ID 'ZUS' FIELD l_uname. + IF l_uname IS INITIAL OR l_uname = space. + l_uname = sy-uname. + ENDIF. + + get_alv_converters( ). + + CONCATENATE 'EXCEL_' sy-uname INTO ws_indx-srtfd. + + IMPORT p1 = ls_option FROM DATABASE indx(xl) TO ws_indx ID ws_indx-srtfd. + + IF sy-subrc = 0. + ws_option = ls_option. + ELSE. + init_option( ) . + ENDIF. + + ENDMETHOD. + + + METHOD clean_fieldcatalog. + DATA: l_position TYPE tabfdpos. + + FIELD-SYMBOLS: TYPE yecb_s_converter_fcat. + + SORT wt_fieldcatalog BY position col_id. + + CLEAR l_position. + LOOP AT wt_fieldcatalog ASSIGNING . + ADD 1 TO l_position. + -position = l_position. +* Default stype with alignment and format + -style_hdr = get_style( i_type = c_type_hdr + i_alignment = -alignment ). + IF ws_layout-is_stripped = abap_true. + -style_stripped = get_style( i_type = c_type_str + i_alignment = -alignment + i_inttype = -inttype + i_decimals = -decimals ). + ENDIF. + -style_normal = get_style( i_type = c_type_nor + i_alignment = -alignment + i_inttype = -inttype + i_decimals = -decimals ). + -style_subtotal = get_style( i_type = c_type_sub + i_alignment = -alignment + i_inttype = -inttype + i_decimals = -decimals ). + -style_total = get_style( i_type = c_type_tot + i_alignment = -alignment + i_inttype = -inttype + i_decimals = -decimals ). + ENDLOOP. + + ENDMETHOD. + + + METHOD convert. + + IF is_option IS SUPPLIED. + ws_option = is_option. + ENDIF. + + execute_converter( EXPORTING io_object = io_alv + it_table = it_table ) . + + IF io_worksheet IS SUPPLIED AND io_worksheet IS BOUND. + wo_worksheet = io_worksheet. + ENDIF. + IF co_excel IS SUPPLIED. + IF co_excel IS NOT BOUND. + CREATE OBJECT co_excel. + co_excel->yif_ecb_book_properties~creator = sy-uname. + ENDIF. + wo_excel = co_excel. + ENDIF. + +* Move table to data object and clean it up + IF wt_fieldcatalog IS NOT INITIAL. + create_table( ). + ELSE. + wo_data = wo_table . + ENDIF. + + IF wo_excel IS NOT BOUND. + CREATE OBJECT wo_excel. + wo_excel->yif_ecb_book_properties~creator = sy-uname. + ENDIF. + IF wo_worksheet IS NOT BOUND. + " Get active sheet + wo_worksheet = wo_excel->get_active_worksheet( ). + wo_worksheet->set_title( ip_title = 'Sheet1'(001) ). + ENDIF. + + IF i_row_int <= 0. + w_row_int = 1. + ELSE. + w_row_int = i_row_int. + ENDIF. + IF i_column_int <= 0. + w_col_int = 1. + ELSE. + w_col_int = i_column_int. + ENDIF. + + create_worksheet( i_table = i_table + i_style_table = i_style_table ) . + + ENDMETHOD. + + + METHOD create_color_style. + DATA: ls_styles TYPE ts_styles. + DATA: lo_style TYPE REF TO ycl_ecb_style. + + READ TABLE wt_styles INTO ls_styles WITH KEY guid = i_style. + IF sy-subrc = 0. + lo_style = wo_excel->add_new_style( ). + lo_style->font->bold = ls_styles-style->font->bold. + lo_style->alignment->horizontal = ls_styles-style->alignment->horizontal. + lo_style->number_format->format_code = ls_styles-style->number_format->format_code. + + lo_style->font->color-rgb = is_colors-fontcolor. + lo_style->fill->filltype = ycl_ecb_style_fill=>c_fill_solid. + lo_style->fill->fgcolor-rgb = is_colors-fillcolor. + + ro_style = lo_style. + ENDIF. + ENDMETHOD. + + + METHOD create_formular_subtotal. + DATA: l_row_alpha_start TYPE string, + l_row_alpha_end TYPE string, + l_func_num TYPE string. + + l_row_alpha_start = i_row_int_start. + l_row_alpha_end = i_row_int_end. + + l_func_num = get_function_number( i_totals_function = i_totals_function ). + CONCATENATE 'SUBTOTAL(' l_func_num ',' i_column l_row_alpha_start ':' i_column l_row_alpha_end ')' INTO r_formula. + ENDMETHOD. + + + METHOD create_formular_total. + DATA: l_row_alpha TYPE string, + l_row_e_alpha TYPE string. + + l_row_alpha = w_row_int + 1. + l_row_e_alpha = i_row_int. + + CONCATENATE i_totals_function '(' i_column l_row_alpha ':' i_column l_row_e_alpha ')' INTO r_formula. + ENDMETHOD. + + + METHOD create_path. + DATA: l_sep TYPE c, + l_path TYPE string, + l_return TYPE i. + + CLEAR r_path. + + " Save the file + cl_gui_frontend_services=>get_sapgui_workdir( + CHANGING + sapworkdir = l_path + EXCEPTIONS + get_sapworkdir_failed = 1 + cntl_error = 2 + error_no_gui = 3 + not_supported_by_gui = 4 + ). + IF sy-subrc <> 0. + CONCATENATE 'Excel_' w_fcount '.xlsx' INTO r_path. + ELSE. + DO. + ADD 1 TO w_fcount. +*-obtain file separator character--------------------------------------- + CALL METHOD cl_gui_frontend_services=>get_file_separator + CHANGING + file_separator = l_sep + EXCEPTIONS + cntl_error = 1 + error_no_gui = 2 + not_supported_by_gui = 3 + OTHERS = 4. + + IF sy-subrc <> 0. + l_sep = ''. + ENDIF. + + CONCATENATE l_path l_sep 'Excel_' w_fcount '.xlsx' INTO r_path. + + IF cl_gui_frontend_services=>file_exist( file = r_path ) = abap_true. + cl_gui_frontend_services=>file_delete( EXPORTING filename = r_path + CHANGING rc = l_return + EXCEPTIONS OTHERS = 1 ). + IF sy-subrc = 0 . + RETURN. + ENDIF. + ELSE. + RETURN. + ENDIF. + ENDDO. + ENDIF. + + ENDMETHOD. + + + METHOD create_style_hdr. + DATA: lo_style TYPE REF TO ycl_ecb_style. + + lo_style = wo_excel->add_new_style( ). + lo_style->font->bold = abap_true. + lo_style->font->color-rgb = ycl_ecb_style_color=>c_white. + lo_style->fill->filltype = ycl_ecb_style_fill=>c_fill_solid. + lo_style->fill->fgcolor-rgb = 'FF4F81BD'. + IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL. + lo_style->alignment->horizontal = i_alignment. + ENDIF. + ro_style = lo_style . + ENDMETHOD. + + + METHOD create_style_normal. + DATA: lo_style TYPE REF TO ycl_ecb_style, + l_format TYPE yecb_number_format. + + IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL. + l_format = set_cell_format( i_inttype = i_inttype + i_decimals = i_decimals ) . + ENDIF. + IF l_format IS NOT INITIAL OR + ( i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL ) . + + lo_style = wo_excel->add_new_style( ). + + IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL. + lo_style->alignment->horizontal = i_alignment. + ENDIF. + + IF l_format IS NOT INITIAL. + lo_style->number_format->format_code = l_format. + ENDIF. + + ro_style = lo_style . + + ENDIF. + ENDMETHOD. + + + METHOD create_style_stripped. + DATA: lo_style TYPE REF TO ycl_ecb_style. + DATA: l_format TYPE yecb_number_format. + + lo_style = wo_excel->add_new_style( ). + lo_style->fill->filltype = ycl_ecb_style_fill=>c_fill_solid. + lo_style->fill->fgcolor-rgb = 'FFDBE5F1'. + IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL. + lo_style->alignment->horizontal = i_alignment. + ENDIF. + IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL. + l_format = set_cell_format( i_inttype = i_inttype + i_decimals = i_decimals ) . + IF l_format IS NOT INITIAL. + lo_style->number_format->format_code = l_format. + ENDIF. + ENDIF. + ro_style = lo_style. + + ENDMETHOD. + + + METHOD create_style_subtotal. + DATA: lo_style TYPE REF TO ycl_ecb_style. + DATA: l_format TYPE yecb_number_format. + + lo_style = wo_excel->add_new_style( ). + lo_style->font->bold = abap_true. + + IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL. + lo_style->alignment->horizontal = i_alignment. + ENDIF. + IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL. + l_format = set_cell_format( i_inttype = i_inttype + i_decimals = i_decimals ) . + IF l_format IS NOT INITIAL. + lo_style->number_format->format_code = l_format. + ENDIF. + ENDIF. + + ro_style = lo_style . + + ENDMETHOD. + + + METHOD create_style_total. + DATA: lo_style TYPE REF TO ycl_ecb_style. + DATA: l_format TYPE yecb_number_format. + + lo_style = wo_excel->add_new_style( ). + lo_style->font->bold = abap_true. + + CREATE OBJECT lo_style->borders->top. + lo_style->borders->top->border_style = ycl_ecb_style_border=>c_border_thin. + lo_style->borders->top->border_color-rgb = ycl_ecb_style_color=>c_black. + + CREATE OBJECT lo_style->borders->right. + lo_style->borders->right->border_style = ycl_ecb_style_border=>c_border_none. + lo_style->borders->right->border_color-rgb = ycl_ecb_style_color=>c_black. + + CREATE OBJECT lo_style->borders->down. + lo_style->borders->down->border_style = ycl_ecb_style_border=>c_border_double. + lo_style->borders->down->border_color-rgb = ycl_ecb_style_color=>c_black. + + CREATE OBJECT lo_style->borders->left. + lo_style->borders->left->border_style = ycl_ecb_style_border=>c_border_none. + lo_style->borders->left->border_color-rgb = ycl_ecb_style_color=>c_black. + + IF i_alignment IS SUPPLIED AND i_alignment IS NOT INITIAL. + lo_style->alignment->horizontal = i_alignment. + ENDIF. + IF i_inttype IS SUPPLIED AND i_inttype IS NOT INITIAL. + l_format = set_cell_format( i_inttype = i_inttype + i_decimals = i_decimals ) . + IF l_format IS NOT INITIAL. + lo_style->number_format->format_code = l_format. + ENDIF. + ENDIF. + + ro_style = lo_style . + + ENDMETHOD. + + + METHOD create_table. + TYPES: BEGIN OF ts_output, + fieldname TYPE fieldname, + function TYPE funcname, + END OF ts_output. + + DATA: lo_data TYPE REF TO data. + DATA: lo_addit TYPE REF TO cl_abap_elemdescr, + lt_components_tab TYPE cl_abap_structdescr=>component_table, + ls_components TYPE abap_componentdescr, + lo_table TYPE REF TO cl_abap_tabledescr, + lo_struc TYPE REF TO cl_abap_structdescr. + + FIELD-SYMBOLS: TYPE yecb_s_converter_fcat, + TYPE any, + TYPE STANDARD TABLE, + TYPE any, + TYPE STANDARD TABLE. + + SORT wt_fieldcatalog BY position. + ASSIGN wo_table->* TO . + + READ TABLE ASSIGNING INDEX 1. + IF sy-subrc EQ 0 . + LOOP AT wt_fieldcatalog ASSIGNING . + ASSIGN COMPONENT -columnname OF STRUCTURE TO . + IF sy-subrc = 0. + ls_components-name = -columnname. + TRY. + lo_addit ?= cl_abap_typedescr=>describe_by_data( ). + CATCH cx_sy_move_cast_error. + CLEAR lo_addit. + DELETE TABLE wt_fieldcatalog FROM . + ENDTRY. + IF lo_addit IS BOUND. + ls_components-type = lo_addit . + INSERT ls_components INTO TABLE lt_components_tab. + ENDIF. + ENDIF. + ENDLOOP. + IF lt_components_tab IS NOT INITIAL. + "create new line type + TRY. + lo_struc = cl_abap_structdescr=>create( p_components = lt_components_tab + p_strict = abap_false ). + CATCH cx_sy_struct_creation. + RETURN. " We can not do anything in this case. + ENDTRY. + + lo_table = cl_abap_tabledescr=>create( lo_struc ). + + CREATE DATA wo_data TYPE HANDLE lo_table. + CREATE DATA lo_data TYPE HANDLE lo_struc. + + ASSIGN wo_data->* TO . + ASSIGN lo_data->* TO . + LOOP AT ASSIGNING . + CLEAR . + MOVE-CORRESPONDING TO . + APPEND TO . + ENDLOOP. + ENDIF. + ENDIF. + + ENDMETHOD. + + + METHOD create_text_subtotal. + DATA: l_string(256) TYPE c, + l_func TYPE string. + + CASE i_totals_function. + WHEN ycl_ecb_table=>totals_function_sum. " Total + l_func = 'Total'(003). + WHEN ycl_ecb_table=>totals_function_min. " Minimum + l_func = 'Minimum'(004). + WHEN ycl_ecb_table=>totals_function_max. " Maximum + l_func = 'Maximum'(005). + WHEN ycl_ecb_table=>totals_function_average. " Mean Value + l_func = 'Average'(006). + WHEN ycl_ecb_table=>totals_function_count. " Count + l_func = 'Count'(007). + WHEN OTHERS. + CLEAR l_func. + ENDCASE. + + l_string = i_value. + + CONCATENATE l_string l_func INTO r_text SEPARATED BY space. + + ENDMETHOD. + + + METHOD create_worksheet. + DATA: l_freeze_col TYPE i. + + IF wo_data IS BOUND AND wo_worksheet IS BOUND. + + wo_worksheet->yif_ecb_sheet_properties~summarybelow = yif_ecb_sheet_properties=>c_below_on. " By default is on + + IF wt_fieldcatalog IS INITIAL. + set_fieldcatalog( ) . + ELSE. + clean_fieldcatalog( ) . + ENDIF. + + IF i_table = abap_true. + l_freeze_col = bind_table( i_style_table = i_style_table ) . + ELSEIF wt_filter IS NOT INITIAL. +* Let's check for filter. + wo_autofilter = wo_excel->add_new_autofilter( io_sheet = wo_worksheet ). + l_freeze_col = bind_cells( ) . + set_autofilter_area( ) . + ELSE. + l_freeze_col = bind_cells( ) . + ENDIF. + +* Check for freeze panes + IF ws_layout-is_fixed = abap_true. + IF l_freeze_col = 0. + l_freeze_col = w_col_int. + ENDIF. + wo_worksheet->freeze_panes( EXPORTING ip_num_columns = l_freeze_col + ip_num_rows = w_row_int ) . + ENDIF. + ENDIF. + + ENDMETHOD. + + + METHOD execute_converter. + DATA: lo_if TYPE REF TO yif_ecb_converter, + ls_types TYPE ts_alv_types, + lo_addit TYPE REF TO cl_abap_classdescr, + lo_addit_superclass TYPE REF TO cl_abap_classdescr. + + IF io_object IS BOUND. + TRY. + lo_addit ?= cl_abap_typedescr=>describe_by_object_ref( io_object ). + CATCH cx_sy_move_cast_error. + RAISE EXCEPTION TYPE ycx_ecb. + ENDTRY. + ls_types-seoclass = lo_addit->get_relative_name( ). + READ TABLE wt_objects INTO ls_types WITH TABLE KEY seoclass = ls_types-seoclass. + IF sy-subrc NE 0. + DO. + FREE lo_addit_superclass. + lo_addit_superclass = lo_addit->get_super_class_type( ). + IF lo_addit_superclass IS INITIAL. + CLEAR ls_types-clsname. + EXIT. + ENDIF. + lo_addit = lo_addit_superclass. + ls_types-seoclass = lo_addit->get_relative_name( ). + READ TABLE wt_objects INTO ls_types WITH TABLE KEY seoclass = ls_types-seoclass. + IF sy-subrc EQ 0. + EXIT. + ENDIF. + ENDDO. + ENDIF. + IF ls_types-clsname IS NOT INITIAL. + CREATE OBJECT lo_if TYPE (ls_types-clsname). + lo_if->create_fieldcatalog( + EXPORTING + is_option = ws_option + io_object = io_object + it_table = it_table + IMPORTING + es_layout = ws_layout + et_fieldcatalog = wt_fieldcatalog + eo_table = wo_table + et_colors = wt_colors + et_filter = wt_filter + ). +* data lines of highest level. + IF ws_layout-max_subtotal_level > 0. ADD 1 TO ws_layout-max_subtotal_level. ENDIF. + ELSE. + RAISE EXCEPTION TYPE ycx_ecb. + ENDIF. + ELSE. + CLEAR wt_fieldcatalog. + GET REFERENCE OF it_table INTO wo_table. + ENDIF. + ENDMETHOD. + + + METHOD get_alv_converters. + DATA: + lt_direct_implementations TYPE seor_implementing_keys, + lt_all_implementations TYPE seor_implementing_keys, + ls_impkey TYPE seor_implementing_key, + ls_classkey TYPE seoclskey, + lr_implementation TYPE REF TO yif_ecb_converter, + ls_object TYPE ts_alv_types, + lr_classdescr TYPE REF TO cl_abap_classdescr. + + ls_classkey-clsname = 'ZIF_EXCEL_CONVERTER'. + + CALL FUNCTION 'SEO_INTERFACE_IMPLEM_GET_ALL' + EXPORTING + intkey = ls_classkey + IMPORTING + impkeys = lt_direct_implementations + EXCEPTIONS + OTHERS = 2. + + CHECK sy-subrc = 0. + + LOOP AT lt_direct_implementations INTO ls_impkey. + lr_classdescr ?= cl_abap_classdescr=>describe_by_name( ls_impkey-clsname ). + IF lr_classdescr->is_instantiatable( ) = abap_true. + APPEND ls_impkey TO lt_all_implementations. + ENDIF. + + ls_classkey-clsname = ls_impkey-clsname. + get_subclasses( EXPORTING is_clskey = ls_classkey CHANGING ct_classes = lt_all_implementations ). + ENDLOOP. + + SORT lt_all_implementations BY clsname. + DELETE ADJACENT DUPLICATES FROM lt_all_implementations COMPARING clsname. + + LOOP AT lt_all_implementations INTO ls_impkey. + CLEAR ls_object. + CREATE OBJECT lr_implementation TYPE (ls_impkey-clsname). + ls_object-seoclass = lr_implementation->get_supported_class( ). + + IF ls_object-seoclass IS NOT INITIAL. + ls_object-clsname = ls_impkey-clsname. + INSERT ls_object INTO TABLE wt_objects. + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD get_color_style. + DATA: ls_colors TYPE yecb_s_converter_col, + ls_color_styles TYPE ts_color_styles, + lo_style TYPE REF TO ycl_ecb_style. + + r_style = i_style. " Default we change nothing + + IF wt_colors IS NOT INITIAL. +* Full line has color + READ TABLE wt_colors INTO ls_colors WITH KEY rownumber = i_row + columnname = space. + IF sy-subrc = 0. + READ TABLE wt_color_styles INTO ls_color_styles WITH KEY guid_old = i_style + fontcolor = ls_colors-fontcolor + fillcolor = ls_colors-fillcolor. + IF sy-subrc = 0. + r_style = ls_color_styles-style_new->get_guid( ). + ELSE. + lo_style = create_color_style( i_style = i_style + is_colors = ls_colors ) . + r_style = lo_style->get_guid( ) . + ls_color_styles-guid_old = i_style. + ls_color_styles-fontcolor = ls_colors-fontcolor. + ls_color_styles-fillcolor = ls_colors-fillcolor. + ls_color_styles-style_new = lo_style. + INSERT ls_color_styles INTO TABLE wt_color_styles. + ENDIF. + ELSE. +* Only field has color + READ TABLE wt_colors INTO ls_colors WITH KEY rownumber = i_row + columnname = i_fieldname. + IF sy-subrc = 0. + READ TABLE wt_color_styles INTO ls_color_styles WITH KEY guid_old = i_style + fontcolor = ls_colors-fontcolor + fillcolor = ls_colors-fillcolor. + IF sy-subrc = 0. + r_style = ls_color_styles-style_new->get_guid( ). + ELSE. + lo_style = create_color_style( i_style = i_style + is_colors = ls_colors ) . + ls_color_styles-guid_old = i_style. + ls_color_styles-fontcolor = ls_colors-fontcolor. + ls_color_styles-fillcolor = ls_colors-fillcolor. + ls_color_styles-style_new = lo_style. + INSERT ls_color_styles INTO TABLE wt_color_styles. + r_style = ls_color_styles-style_new->get_guid( ). + ENDIF. + ELSE. + r_style = i_style. + ENDIF. + ENDIF. + ELSE. + r_style = i_style. + ENDIF. + + ENDMETHOD. + + + METHOD get_file. + DATA: lo_excel_writer TYPE REF TO yif_ecb_writer. + + DATA: ls_seoclass TYPE seoclass. + + + IF wo_excel IS BOUND. + CREATE OBJECT lo_excel_writer TYPE ycl_ecb_writer_2007. + e_file = lo_excel_writer->write_file( wo_excel ). + + SELECT SINGLE * INTO ls_seoclass + FROM seoclass + WHERE clsname = 'CL_BCS_CONVERT'. + + IF sy-subrc = 0. + CALL METHOD (ls_seoclass-clsname)=>xstring_to_solix + EXPORTING + iv_xstring = e_file + RECEIVING + et_solix = et_file. + e_bytecount = xstrlen( e_file ). + ELSE. + " Convert to binary + CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' + EXPORTING + buffer = e_file + IMPORTING + output_length = e_bytecount + TABLES + binary_tab = et_file. + ENDIF. + ENDIF. + + ENDMETHOD. + + + METHOD get_function_number. +*Number Function +*1 AVERAGE +*2 COUNT +*3 COUNTA +*4 MAX +*5 MIN +*6 PRODUCT +*7 STDEV +*8 STDEVP +*9 SUM +*10 VAR +*11 VARP + + CASE i_totals_function. + WHEN ycl_ecb_table=>totals_function_sum. " Total + r_function_number = 9. + WHEN ycl_ecb_table=>totals_function_min. " Minimum + r_function_number = 5. + WHEN ycl_ecb_table=>totals_function_max. " Maximum + r_function_number = 4. + WHEN ycl_ecb_table=>totals_function_average. " Mean Value + r_function_number = 1. + WHEN ycl_ecb_table=>totals_function_count. " Count + r_function_number = 2. + WHEN OTHERS. + CLEAR r_function_number. + ENDCASE. + ENDMETHOD. + + + METHOD get_option. + + rs_option = ws_option. + + ENDMETHOD. + + + METHOD get_style. + DATA: ls_styles TYPE ts_styles, + lo_style TYPE REF TO ycl_ecb_style. + + CLEAR r_style. + + READ TABLE wt_styles INTO ls_styles WITH TABLE KEY type = i_type + alignment = i_alignment + inttype = i_inttype + decimals = i_decimals. + IF sy-subrc = 0. + r_style = ls_styles-guid. + ELSE. + CASE i_type. + WHEN c_type_hdr. " Header + lo_style = create_style_hdr( i_alignment = i_alignment ). + WHEN c_type_str. "Stripped + lo_style = create_style_stripped( i_alignment = i_alignment + i_inttype = i_inttype + i_decimals = i_decimals ). + WHEN c_type_nor. "Normal + lo_style = create_style_normal( i_alignment = i_alignment + i_inttype = i_inttype + i_decimals = i_decimals ). + WHEN c_type_sub. "Subtotals + lo_style = create_style_subtotal( i_alignment = i_alignment + i_inttype = i_inttype + i_decimals = i_decimals ). + WHEN c_type_tot. "Totals + lo_style = create_style_total( i_alignment = i_alignment + i_inttype = i_inttype + i_decimals = i_decimals ). + ENDCASE. + IF lo_style IS NOT INITIAL. + r_style = lo_style->get_guid( ). + ls_styles-type = i_type. + ls_styles-alignment = i_alignment. + ls_styles-inttype = i_inttype. + ls_styles-decimals = i_decimals. + ls_styles-guid = r_style. + ls_styles-style = lo_style. + INSERT ls_styles INTO TABLE wt_styles. + ENDIF. + ENDIF. + ENDMETHOD. + + + METHOD get_subclasses. + DATA: + lt_subclasses TYPE seor_inheritance_keys, + ls_subclass TYPE seor_inheritance_key, + lr_classdescr TYPE REF TO cl_abap_classdescr. + + CALL FUNCTION 'SEO_CLASS_GET_ALL_SUBS' + EXPORTING + clskey = is_clskey + IMPORTING + inhkeys = lt_subclasses + EXCEPTIONS + class_not_existing = 1 + OTHERS = 2. + + CHECK sy-subrc = 0. + + LOOP AT lt_subclasses INTO ls_subclass. + lr_classdescr ?= cl_abap_classdescr=>describe_by_name( ls_subclass-clsname ). + IF lr_classdescr->is_instantiatable( ) = abap_true. + APPEND ls_subclass TO ct_classes. + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD init_option. + + ws_option-filter = abap_true. + ws_option-hidenc = abap_true. + ws_option-subtot = abap_true. + + ENDMETHOD. + + + METHOD loop_normal. + DATA: l_row_int_end TYPE yecb_cell_row, + l_row_int TYPE yecb_cell_row, + l_col_int TYPE yecb_cell_column, + l_col_alpha TYPE yecb_cell_column_alpha, + l_cell_value TYPE yecb_cell_value, + l_s_color TYPE abap_bool, + lo_column TYPE REF TO ycl_ecb_column, + l_formula TYPE yecb_cell_formula, + l_style TYPE yecb_cell_style, + l_cells TYPE i, + l_count TYPE i, + l_table_row TYPE i. + + FIELD-SYMBOLS: TYPE any, + TYPE STANDARD TABLE, + TYPE yecb_s_converter_fcat, + TYPE any. + + ASSIGN wo_data->* TO . + + DESCRIBE TABLE wt_fieldcatalog LINES l_cells. + DESCRIBE TABLE LINES l_count. + l_cells = l_cells * l_count. + +* It is better to loop column by column + LOOP AT wt_fieldcatalog ASSIGNING . + l_row_int = i_row_int. + l_col_int = i_col_int + -position - 1. + +* Freeze panes + IF -fix_column = abap_true. + ADD 1 TO r_freeze_col. + ENDIF. + l_s_color = abap_true. + + l_col_alpha = ycl_ecb_common=>convert_column2alpha( l_col_int ). + +* Only if the Header is required create it. + IF ws_option-hidehd IS INITIAL. + " First of all write column header + l_cell_value = -scrtext_m. + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = l_cell_value + ip_style = -style_hdr ). + ADD 1 TO l_row_int. + ENDIF. + LOOP AT ASSIGNING . + l_table_row = sy-tabix. +* Now the cell values + ASSIGN COMPONENT -columnname OF STRUCTURE TO . +* Now let's write the cell values + IF ws_layout-is_stripped = abap_true AND l_s_color = abap_true. + l_style = get_color_style( i_row = l_table_row + i_fieldname = -columnname + i_style = -style_stripped ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = + ip_style = l_style + ip_conv_exit_length = ws_option-conv_exit_length ). + CLEAR l_s_color. + ELSE. + l_style = get_color_style( i_row = l_table_row + i_fieldname = -columnname + i_style = -style_normal ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = + ip_style = l_style + ip_conv_exit_length = ws_option-conv_exit_length ). + l_s_color = abap_true. + ENDIF. + READ TABLE wt_filter TRANSPORTING NO FIELDS WITH TABLE KEY rownumber = l_table_row + columnname = -columnname. + IF sy-subrc = 0. + wo_worksheet->get_cell( EXPORTING + ip_column = l_col_alpha + ip_row = l_row_int + IMPORTING + ep_value = l_cell_value ). + wo_autofilter->set_value( i_column = l_col_int + i_value = l_cell_value ). + ENDIF. + ADD 1 TO l_row_int. + ENDLOOP. +* Now let's check for optimized + IF -is_optimized = abap_true . + lo_column = wo_worksheet->get_column( ip_column = l_col_alpha ). + lo_column->set_auto_size( ip_auto_size = abap_true ) . + ENDIF. +* Now let's check for visible + IF -is_hidden = abap_true. + lo_column = wo_worksheet->get_column( ip_column = l_col_alpha ). + lo_column->set_visible( ip_visible = abap_false ) . + ENDIF. +* Now let's check for total versus subtotal. + IF -totals_function IS NOT INITIAL. + l_row_int_end = l_row_int - 1. + + l_formula = create_formular_total( i_row_int = l_row_int_end + i_column = l_col_alpha + i_totals_function = -totals_function ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_formula = l_formula + ip_style = -style_total ). + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD loop_subtotal. + + DATA: l_row_int_start TYPE yecb_cell_row, + l_row_int_end TYPE yecb_cell_row, + l_row_int TYPE yecb_cell_row, + l_col_int TYPE yecb_cell_column, + l_col_alpha TYPE yecb_cell_column_alpha, + l_col_alpha_start TYPE yecb_cell_column_alpha, + l_cell_value TYPE yecb_cell_value, + l_s_color TYPE abap_bool, + lo_column TYPE REF TO ycl_ecb_column, + lo_row TYPE REF TO ycl_ecb_row, + l_formula TYPE yecb_cell_formula, + l_style TYPE yecb_cell_style, + l_text TYPE string, + ls_sort_values TYPE ts_sort_values, + ls_subtotal_rows TYPE ts_subtotal_rows, + l_sort_level TYPE int4, + l_hidden TYPE int4, + l_line TYPE i, + l_cells TYPE i, + l_count TYPE i, + l_table_row TYPE i, + lt_fcat TYPE yecb_t_converter_fcat. + + FIELD-SYMBOLS: TYPE any, + TYPE STANDARD TABLE, + TYPE yecb_s_converter_fcat, + TYPE any, + TYPE any, + TYPE ts_sort_values. + + ASSIGN wo_data->* TO . + + CLEAR: wt_sort_values, + wt_subtotal_rows. + + DESCRIBE TABLE wt_fieldcatalog LINES l_cells. + DESCRIBE TABLE LINES l_count. + l_cells = l_cells * l_count. + + READ TABLE ASSIGNING INDEX 1. + IF sy-subrc = 0. + l_row_int = i_row_int + 1. + lt_fcat = wt_fieldcatalog. + SORT lt_fcat BY sort_level DESCENDING. + LOOP AT lt_fcat ASSIGNING WHERE is_subtotalled = abap_true. + ASSIGN COMPONENT -columnname OF STRUCTURE TO . + ls_sort_values-fieldname = -columnname. + ls_sort_values-row_int = l_row_int. + ls_sort_values-sort_level = -sort_level. + ls_sort_values-is_collapsed = -is_collapsed. + CREATE DATA ls_sort_values-value LIKE . + ASSIGN ls_sort_values-value->* TO . + = . + INSERT ls_sort_values INTO TABLE wt_sort_values. + ENDLOOP. + ENDIF. + l_row_int = i_row_int. +* Let's check if we need to hide a sort level. + DESCRIBE TABLE wt_sort_values LINES l_line. + IF l_line <= 1. + CLEAR l_hidden. + ELSE. + LOOP AT wt_sort_values INTO ls_sort_values WHERE is_collapsed = abap_false. + IF l_hidden < ls_sort_values-sort_level. + l_hidden = ls_sort_values-sort_level. + ENDIF. + ENDLOOP. + ENDIF. + ADD 1 TO l_hidden. " As this is the first level we show. +* First loop without formular only addtional rows with subtotal text. + LOOP AT ASSIGNING . + ADD 1 TO l_row_int. " 1 is for header row. + l_row_int_start = l_row_int. + SORT lt_fcat BY sort_level DESCENDING. + LOOP AT lt_fcat ASSIGNING WHERE is_subtotalled = abap_true. + l_col_int = i_col_int + -position - 1. + l_col_alpha = ycl_ecb_common=>convert_column2alpha( l_col_int ). +* Now the cell values + ASSIGN COMPONENT -columnname OF STRUCTURE TO . + IF sy-subrc = 0. + READ TABLE wt_sort_values ASSIGNING WITH TABLE KEY fieldname = -columnname. + IF sy-subrc = 0. + ASSIGN -value->* TO . + IF <> OR -new = abap_true. +* First let's remmember the subtotal values as it has to appear later. + ls_subtotal_rows-row_int = l_row_int. + ls_subtotal_rows-row_int_start = -row_int. + ls_subtotal_rows-columnname = -columnname. + INSERT ls_subtotal_rows INTO TABLE wt_subtotal_rows. +* Now let's write the subtotal line + l_cell_value = create_text_subtotal( i_value = + i_totals_function = -totals_function ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = l_cell_value + ip_abap_type = cl_abap_typedescr=>typekind_string + ip_style = -style_subtotal ). + lo_row = wo_worksheet->get_row( ip_row = l_row_int ). + lo_row->set_outline_level( ip_outline_level = -sort_level ) . + IF -is_collapsed = abap_true. + IF -sort_level > l_hidden. + lo_row->set_visible( ip_visible = abap_false ) . + ENDIF. + lo_row->set_collapsed( ip_collapsed = -is_collapsed ) . + ENDIF. +* Now let's change the key + ADD 1 TO l_row_int. + = . + -new = abap_false. + l_line = -sort_level. + LOOP AT wt_sort_values ASSIGNING WHERE sort_level >= l_line. + -row_int = l_row_int. + ENDLOOP. + ENDIF. + ENDIF. + ENDIF. + ENDLOOP. + ENDLOOP. + ADD 1 TO l_row_int. + l_row_int_start = l_row_int. + SORT lt_fcat BY sort_level DESCENDING. + LOOP AT lt_fcat ASSIGNING WHERE is_subtotalled = abap_true. + l_col_int = i_col_int + -position - 1. + l_col_alpha = ycl_ecb_common=>convert_column2alpha( l_col_int ). + READ TABLE wt_sort_values ASSIGNING WITH TABLE KEY fieldname = -columnname. + IF sy-subrc = 0. + ASSIGN -value->* TO . + ls_subtotal_rows-row_int = l_row_int. + ls_subtotal_rows-row_int_start = -row_int. + ls_subtotal_rows-columnname = -columnname. + INSERT ls_subtotal_rows INTO TABLE wt_subtotal_rows. +* First let's write the value as it has to appear. + l_cell_value = create_text_subtotal( i_value = + i_totals_function = -totals_function ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = l_cell_value + ip_abap_type = cl_abap_typedescr=>typekind_string + ip_style = -style_subtotal ). + + l_sort_level = -sort_level. + lo_row = wo_worksheet->get_row( ip_row = l_row_int ). + lo_row->set_outline_level( ip_outline_level = l_sort_level ) . + IF -is_collapsed = abap_true. + IF -sort_level > l_hidden. + lo_row->set_visible( ip_visible = abap_false ) . + ENDIF. + lo_row->set_collapsed( ip_collapsed = -is_collapsed ) . + ENDIF. + ADD 1 TO l_row_int. + ENDIF. + ENDLOOP. +* Let's write the Grand total + l_sort_level = 0. + lo_row = wo_worksheet->get_row( ip_row = l_row_int ). + lo_row->set_outline_level( ip_outline_level = l_sort_level ) . +* lo_row_dim->set_collapsed( ip_collapsed = -is_collapsed ) . Not on grand total + + l_text = create_text_subtotal( i_value = 'Grand'(002) + i_totals_function = -totals_function ). + + l_col_alpha_start = ycl_ecb_common=>convert_column2alpha( i_col_int ). + wo_worksheet->set_cell( ip_column = l_col_alpha_start + ip_row = l_row_int + ip_value = l_text + ip_abap_type = cl_abap_typedescr=>typekind_string + ip_style = -style_subtotal ). + +* It is better to loop column by column second time around +* Second loop with formular and data. + LOOP AT wt_fieldcatalog ASSIGNING . + l_row_int = i_row_int. + l_col_int = i_col_int + -position - 1. +* Freeze panes + IF -fix_column = abap_true. + ADD 1 TO r_freeze_col. + ENDIF. + l_s_color = abap_true. + l_col_alpha = ycl_ecb_common=>convert_column2alpha( l_col_int ). + " First of all write column header + l_cell_value = -scrtext_m. + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = l_cell_value + ip_abap_type = cl_abap_typedescr=>typekind_string + ip_style = -style_hdr ). + ADD 1 TO l_row_int. + LOOP AT ASSIGNING . + l_table_row = sy-tabix. +* Now the cell values + ASSIGN COMPONENT -columnname OF STRUCTURE TO . +* Let's check for subtotal lines + DO. + READ TABLE wt_subtotal_rows TRANSPORTING NO FIELDS WITH TABLE KEY row_int = l_row_int. + IF sy-subrc = 0. + IF -is_subtotalled = abap_false AND + -totals_function IS NOT INITIAL. + DO. + READ TABLE wt_subtotal_rows INTO ls_subtotal_rows WITH TABLE KEY row_int = l_row_int. + IF sy-subrc = 0. + l_row_int_start = ls_subtotal_rows-row_int_start. + l_row_int_end = l_row_int - 1. + + l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start + i_row_int_end = l_row_int_end + i_column = l_col_alpha + i_totals_function = -totals_function ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_formula = l_formula + ip_style = -style_subtotal ). + IF -is_collapsed = abap_true. + lo_row = wo_worksheet->get_row( ip_row = l_row_int ). + lo_row->set_collapsed( ip_collapsed = -is_collapsed ). + IF -sort_level > l_hidden. + lo_row->set_visible( ip_visible = abap_false ) . + ENDIF. + ENDIF. + ADD 1 TO l_row_int. + ELSE. + EXIT. + ENDIF. + ENDDO. + ELSE. + ADD 1 TO l_row_int. + ENDIF. + ELSE. + EXIT. + ENDIF. + ENDDO. +* Let's set the row dimension values + lo_row = wo_worksheet->get_row( ip_row = l_row_int ). + lo_row->set_outline_level( ip_outline_level = ws_layout-max_subtotal_level ) . + IF -is_collapsed = abap_true. + lo_row->set_visible( ip_visible = abap_false ) . + lo_row->set_collapsed( ip_collapsed = -is_collapsed ) . + ENDIF. +* Now let's write the cell values + IF ws_layout-is_stripped = abap_true AND l_s_color = abap_true. + l_style = get_color_style( i_row = l_table_row + i_fieldname = -columnname + i_style = -style_stripped ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = + ip_style = l_style + ip_conv_exit_length = ws_option-conv_exit_length ). + CLEAR l_s_color. + ELSE. + l_style = get_color_style( i_row = l_table_row + i_fieldname = -columnname + i_style = -style_normal ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_value = + ip_style = l_style + ip_conv_exit_length = ws_option-conv_exit_length ). + l_s_color = abap_true. + ENDIF. + READ TABLE wt_filter TRANSPORTING NO FIELDS WITH TABLE KEY rownumber = l_table_row + columnname = -columnname. + IF sy-subrc = 0. + wo_worksheet->get_cell( EXPORTING + ip_column = l_col_alpha + ip_row = l_row_int + IMPORTING + ep_value = l_cell_value ). + wo_autofilter->set_value( i_column = l_col_int + i_value = l_cell_value ). + ENDIF. + ADD 1 TO l_row_int. + ENDLOOP. +* Let's check for subtotal lines + DO. + READ TABLE wt_subtotal_rows TRANSPORTING NO FIELDS WITH TABLE KEY row_int = l_row_int. + IF sy-subrc = 0. + IF -is_subtotalled = abap_false AND + -totals_function IS NOT INITIAL. + DO. + READ TABLE wt_subtotal_rows INTO ls_subtotal_rows WITH TABLE KEY row_int = l_row_int. + IF sy-subrc = 0. + l_row_int_start = ls_subtotal_rows-row_int_start. + l_row_int_end = l_row_int - 1. + + l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start + i_row_int_end = l_row_int_end + i_column = l_col_alpha + i_totals_function = -totals_function ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_formula = l_formula + ip_style = -style_subtotal ). + IF -is_collapsed = abap_true. + lo_row = wo_worksheet->get_row( ip_row = l_row_int ). + lo_row->set_collapsed( ip_collapsed = -is_collapsed ). + ENDIF. + ADD 1 TO l_row_int. + ELSE. + EXIT. + ENDIF. + ENDDO. + ELSE. + ADD 1 TO l_row_int. + ENDIF. + ELSE. + EXIT. + ENDIF. + ENDDO. +* Now let's check for Grand total + IF -is_subtotalled = abap_false AND + -totals_function IS NOT INITIAL. + l_row_int_start = i_row_int + 1. + l_row_int_end = l_row_int - 1. + + l_formula = create_formular_subtotal( i_row_int_start = l_row_int_start + i_row_int_end = l_row_int_end + i_column = l_col_alpha + i_totals_function = -totals_function ). + wo_worksheet->set_cell( ip_column = l_col_alpha + ip_row = l_row_int + ip_formula = l_formula + ip_style = -style_subtotal ). + ENDIF. +* Now let's check for optimized + IF -is_optimized = abap_true. + lo_column = wo_worksheet->get_column( ip_column = l_col_alpha ). + lo_column->set_auto_size( ip_auto_size = abap_true ) . + ENDIF. +* Now let's check for visible + IF -is_hidden = abap_true. + lo_column = wo_worksheet->get_column( ip_column = l_col_alpha ). + lo_column->set_visible( ip_visible = abap_false ) . + ENDIF. + ENDLOOP. + + ENDMETHOD. + + + METHOD open_file. + DATA: l_bytecount TYPE i, + lt_file TYPE solix_tab, + l_dir TYPE string. + + FIELD-SYMBOLS: TYPE ANY TABLE. + + ASSIGN wo_data->* TO . + + IF wo_excel IS BOUND. + get_file( IMPORTING e_bytecount = l_bytecount + et_file = lt_file ) . + + l_dir = create_path( ) . + + cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount + filename = l_dir + filetype = 'BIN' + CHANGING data_tab = lt_file ). + cl_gui_frontend_services=>execute( + EXPORTING + document = l_dir + EXCEPTIONS + cntl_error = 1 + error_no_gui = 2 + bad_parameter = 3 + file_not_found = 4 + path_not_found = 5 + file_extension_unknown = 6 + error_execute_failed = 7 + synchronous_failed = 8 + not_supported_by_gui = 9 + ). + IF sy-subrc <> 0. + MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno + WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. + ENDIF. + + ENDIF. + + + ENDMETHOD. + + + METHOD set_autofilter_area. + DATA: ls_area TYPE yecb_s_autofilter_area, + l_lines TYPE i, + lt_values TYPE yecb_t_autofilter_values, + ls_values TYPE yecb_s_autofilter_values. + +* Let's check for filter. + IF wo_autofilter IS BOUND. + ls_area-row_start = 1. + lt_values = wo_autofilter->get_values( ) . + SORT lt_values BY column ASCENDING. + DESCRIBE TABLE lt_values LINES l_lines. + READ TABLE lt_values INTO ls_values INDEX 1. + IF sy-subrc = 0. + ls_area-col_start = ls_values-column. + ENDIF. + READ TABLE lt_values INTO ls_values INDEX l_lines. + IF sy-subrc = 0. + ls_area-col_end = ls_values-column. + ENDIF. + wo_autofilter->set_filter_area( is_area = ls_area ) . + ENDIF. + + ENDMETHOD. + + + METHOD set_cell_format. + DATA: l_format TYPE yecb_number_format. + + CLEAR r_format. + CASE i_inttype. + WHEN cl_abap_typedescr=>typekind_date. + r_format = wo_worksheet->get_default_excel_date_format( ). + WHEN cl_abap_typedescr=>typekind_time. + r_format = wo_worksheet->get_default_excel_time_format( ). + WHEN cl_abap_typedescr=>typekind_float OR cl_abap_typedescr=>typekind_packed OR + cl_abap_typedescr=>typekind_decfloat OR + cl_abap_typedescr=>typekind_decfloat16 OR + cl_abap_typedescr=>typekind_decfloat34. + IF i_decimals > 0 . + l_format = '#,##0.'. + DO i_decimals TIMES. + CONCATENATE l_format '0' INTO l_format. + ENDDO. + r_format = l_format. + ENDIF. + WHEN cl_abap_typedescr=>typekind_int OR cl_abap_typedescr=>typekind_int1 OR cl_abap_typedescr=>typekind_int2. + r_format = '#,##0'. + ENDCASE. + + ENDMETHOD. + + + METHOD set_fieldcatalog. + + DATA: lr_data TYPE REF TO data, + lo_structdescr TYPE REF TO cl_abap_structdescr, + lt_dfies TYPE ddfields, + ls_dfies TYPE dfies. + DATA: ls_fcat TYPE yecb_s_converter_fcat. + + FIELD-SYMBOLS: TYPE ANY TABLE. + + ASSIGN wo_data->* TO . + + CREATE DATA lr_data LIKE LINE OF . + + lo_structdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + lt_dfies = ycl_ecb_common=>describe_structure( io_struct = lo_structdescr ). + + LOOP AT lt_dfies INTO ls_dfies. + MOVE-CORRESPONDING ls_dfies TO ls_fcat. + ls_fcat-columnname = ls_dfies-fieldname. + INSERT ls_fcat INTO TABLE wt_fieldcatalog. + ENDLOOP. + + clean_fieldcatalog( ). + + ENDMETHOD. + + + METHOD set_option. + + IF ws_indx-begdt IS INITIAL. + ws_indx-begdt = sy-datum. + ENDIF. + + ws_indx-aedat = sy-datum. + ws_indx-usera = sy-uname. + ws_indx-pgmid = sy-cprog. + + EXPORT p1 = is_option TO DATABASE indx(xl) FROM ws_indx ID ws_indx-srtfd. + + IF sy-subrc = 0. + ws_option = is_option. + ENDIF. + + ENDMETHOD. + + + METHOD write_file. + DATA: l_bytecount TYPE i, + lt_file TYPE solix_tab, + l_dir TYPE string. + + FIELD-SYMBOLS: TYPE ANY TABLE. + + ASSIGN wo_data->* TO . + + IF wo_excel IS BOUND. + get_file( IMPORTING e_bytecount = l_bytecount + et_file = lt_file ) . + IF i_path IS INITIAL. + l_dir = create_path( ) . + ELSE. + l_dir = i_path. + ENDIF. + cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = l_bytecount + filename = l_dir + filetype = 'BIN' + CHANGING data_tab = lt_file ). + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter.clas.locals_def.abap b/src/abap2xlsx/ycl_ecb_converter.clas.locals_def.abap new file mode 100644 index 0000000..411d9cc --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter.clas.locals_def.abap @@ -0,0 +1,49 @@ +*"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + +TYPES ty_style_type TYPE c LENGTH 1. + +TYPES: BEGIN OF ts_alv_types, + seoclass TYPE seoclsname, + clsname TYPE seoclsname, + END OF ts_alv_types, + tt_alv_types TYPE HASHED TABLE OF ts_alv_types WITH UNIQUE KEY seoclass. + +TYPES: BEGIN OF ts_sort_values, + fieldname TYPE fieldname, + row_int TYPE yecb_cell_row, + value TYPE REF TO data, + new TYPE flag, + sort_level TYPE int4, + is_collapsed TYPE flag, + END OF ts_sort_values, + + tt_sort_values TYPE HASHED TABLE OF ts_sort_values WITH UNIQUE KEY fieldname. +TYPES: BEGIN OF ts_subtotal_rows, + row_int TYPE yecb_cell_row, + row_int_start TYPE yecb_cell_row, + columnname TYPE fieldname, + END OF ts_subtotal_rows, + + tt_subtotal_rows TYPE HASHED TABLE OF ts_subtotal_rows WITH UNIQUE KEY row_int. + +TYPES: BEGIN OF ts_styles, + type TYPE ty_style_type, + alignment TYPE yecb_alignment, + inttype TYPE abap_typekind, + decimals TYPE int1, + style TYPE REF TO ycl_ecb_style, + guid TYPE yecb_cell_style, + END OF ts_styles, + + tt_styles TYPE HASHED TABLE OF ts_styles WITH UNIQUE KEY type alignment inttype decimals. + +TYPES: BEGIN OF ts_color_styles, + guid_old TYPE yecb_cell_style, + fontcolor TYPE yecb_style_color_argb, + fillcolor TYPE yecb_style_color_argb, + style_new TYPE REF TO ycl_ecb_style, + END OF ts_color_styles, + + tt_color_styles TYPE HASHED TABLE OF ts_color_styles WITH UNIQUE KEY guid_old fontcolor fillcolor. diff --git a/src/abap2xlsx/ycl_ecb_converter.clas.xml b/src/abap2xlsx/ycl_ecb_converter.clas.xml new file mode 100644 index 0000000..37f6776 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter.clas.xml @@ -0,0 +1,598 @@ + + + + + + YCL_ECB_CONVERTER + E + Salv converter + 1 + X + X + X + + + + I + 001 + Sheet1 + 15 + + + I + 002 + Grand + 10 + + + I + 003 + Total + 10 + + + I + 004 + Minimum + 10 + + + I + 005 + Maximum + 10 + + + I + 006 + Average + 10 + + + I + 007 + Count + 10 + + + I + 008 + Excel creation options + 30 + + + + + ASK_OPTION + E + Ask for user option data + + + ASK_OPTION + I + Ask for user option data + + + BIND_CELLS + E + Create table with set cell method + + + BIND_CELLS + I + Create table with set cell method + + + BIND_TABLE + E + Create table with bind table method + + + BIND_TABLE + I + Create table with bind table method + + + CLASS_CONSTRUCTOR + E + CLASS_CONSTRUCTOR + + + CLASS_CONSTRUCTOR + I + CLASS_CONSTRUCTOR + + + CLEAN_FIELDCATALOG + E + Sort and check on fieldcatalog + + + CLEAN_FIELDCATALOG + I + Sort and check on fieldcatalog + + + CONVERT + E + Convert + + + CONVERT + I + Convert + + + CREATE_COLOR_STYLE + E + Create new color style based on cell style + + + CREATE_COLOR_STYLE + I + Create new color style based on cell style + + + CREATE_FORMULAR_SUBTOTAL + E + Create formular for subtotal + + + CREATE_FORMULAR_SUBTOTAL + I + Create formular for subtotal + + + CREATE_FORMULAR_TOTAL + E + Create formular for column total + + + CREATE_FORMULAR_TOTAL + I + Create formular for column total + + + CREATE_PATH + E + Create file path for download + + + CREATE_PATH + I + Create file path for download + + + CREATE_STYLE_HDR + E + Create header style + + + CREATE_STYLE_HDR + I + Create header style + + + CREATE_STYLE_NORMAL + E + Create line style for stripped + + + CREATE_STYLE_NORMAL + I + Create line style for stripped + + + CREATE_STYLE_STRIPPED + E + Create line style for stripped + + + CREATE_STYLE_STRIPPED + I + Create line style for stripped + + + CREATE_STYLE_SUBTOTAL + E + Create subtotals style + + + CREATE_STYLE_SUBTOTAL + I + Create subtotals style + + + CREATE_STYLE_TOTAL + E + Create totals style + + + CREATE_STYLE_TOTAL + I + Create totals style + + + CREATE_TABLE + E + Create table based on fieldcatalog + + + CREATE_TABLE + I + Create table based on fieldcatalog + + + CREATE_TEXT_SUBTOTAL + E + Create subtoal text for column + + + CREATE_TEXT_SUBTOTAL + I + Create subtoal text for column + + + CREATE_WORKSHEET + E + Create table in worksheet + + + CREATE_WORKSHEET + I + Create table in worksheet + + + C_TYPE_HDR + E + Single-Character Indicator + + + C_TYPE_HDR + I + Single-Character Indicator + + + C_TYPE_NOR + E + Single-Character Indicator + + + C_TYPE_NOR + I + Single-Character Indicator + + + C_TYPE_STR + E + Single-Character Indicator + + + C_TYPE_STR + I + Single-Character Indicator + + + C_TYPE_SUB + E + Single-Character Indicator + + + C_TYPE_SUB + I + Single-Character Indicator + + + C_TYPE_TOT + E + Single-Character Indicator + + + C_TYPE_TOT + I + Single-Character Indicator + + + EXECUTE_CONVERTER + E + Execute the converter based on object provided + + + EXECUTE_CONVERTER + I + Execute the converter based on object provided + + + GET_COLOR_STYLE + E + Look up color style and create if needed + + + GET_COLOR_STYLE + I + Look up color style and create if needed + + + GET_FILE + E + Create excel file + + + GET_FILE + I + Create excel file + + + GET_FUNCTION_NUMBER + E + Convert function name into internal number + + + GET_FUNCTION_NUMBER + I + Convert function name into internal number + + + GET_OPTION + E + Get user option data + + + GET_OPTION + I + Get user option data + + + GET_STYLE + E + Get style for cell + + + GET_STYLE + I + Get style for cell + + + INIT_OPTION + E + Init option structure + + + INIT_OPTION + I + Init option structure + + + LOOP_NORMAL + E + Bind cells with normal loop + + + LOOP_NORMAL + I + Bind cells with normal loop + + + LOOP_SUBTOTAL + E + Bind cells with subtotal loop + + + LOOP_SUBTOTAL + I + Bind cells with subtotal loop + + + OPEN_FILE + E + Open excel file + + + OPEN_FILE + I + Open excel file + + + SET_AUTOFILTER_AREA + E + Create autofilter + + + SET_AUTOFILTER_AREA + I + Create autofilter + + + SET_CELL_FORMAT + E + SET CELL FORMAT + + + SET_CELL_FORMAT + I + SET CELL FORMAT + + + SET_FIELDCATALOG + E + Set fieldcatalog from table + + + SET_FIELDCATALOG + I + Set fieldcatalog from table + + + SET_OPTION + E + Set user option data + + + SET_OPTION + I + Set user option data + + + WO_AUTOFILTER + E + Autofilter + + + WO_AUTOFILTER + I + Autofilter + + + WO_DATA + E + Excel data without unwanted columns + + + WO_DATA + I + Excel data without unwanted columns + + + WO_EXCEL + E + Excel creator + + + WO_EXCEL + I + Excel creator + + + WO_TABLE + E + Table sorted but not reduced + + + WO_TABLE + I + Table sorted but not reduced + + + WO_WORKSHEET + E + Worksheet + + + WO_WORKSHEET + I + Worksheet + + + WRITE_FILE + E + Write excel file + + + WRITE_FILE + I + Write excel file + + + WS_INDX + E + System Table INDX + + + WS_INDX + I + System Table INDX + + + WS_LAYOUT + E + Converter settings for table + + + WS_LAYOUT + I + Converter settings for table + + + WS_OPTION + E + Converter options for grid configuration + + + WS_OPTION + I + Converter options for grid configuration + + + WT_COLORS + E + Table type for color information of cells for converter + + + WT_COLORS + I + Table type for color information of cells for converter + + + WT_FIELDCATALOG + E + Conter table for tabel fields + + + WT_FIELDCATALOG + I + Conter table for tabel fields + + + WT_FILTER + E + Table type for filter information of cells for converter + + + WT_FILTER + I + Table type for filter information of cells for converter + + + WT_OBJECTS + E + ALV object list + + + WT_OBJECTS + I + ALV object list + + + W_COL_INT + E + Cell Column + + + W_COL_INT + I + Cell Column + + + W_FCOUNT + E + Three digit number + + + W_FCOUNT + I + Three digit number + + + W_ROW_INT + E + Cell Row + + + W_ROW_INT + I + Cell Row + + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_alv.clas.abap b/src/abap2xlsx/ycl_ecb_converter_alv.clas.abap new file mode 100644 index 0000000..604a153 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_alv.clas.abap @@ -0,0 +1,600 @@ +CLASS ycl_ecb_converter_alv DEFINITION + PUBLIC + ABSTRACT + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_CONVERTER_ALV +*"* do not include other source files here!!! + PUBLIC SECTION. + + INTERFACES yif_ecb_converter + ALL METHODS ABSTRACT . + + CLASS-METHODS class_constructor . +*"* protected components of class ZCL_EXCEL_CONVERTER_ALV +*"* do not include other source files here!!! + PROTECTED SECTION. + + DATA wt_sort TYPE lvc_t_sort . + DATA wt_filt TYPE lvc_t_filt . + DATA wt_fcat TYPE lvc_t_fcat . + DATA ws_layo TYPE lvc_s_layo . + DATA ws_option TYPE yecb_s_converter_option . + + METHODS update_catalog + CHANGING + !cs_layout TYPE yecb_s_converter_layo + !ct_fieldcatalog TYPE yecb_t_converter_fcat . + METHODS apply_sort + IMPORTING + !it_table TYPE STANDARD TABLE + EXPORTING + !eo_table TYPE REF TO data . + METHODS get_color + IMPORTING + !io_table TYPE REF TO data + EXPORTING + !et_colors TYPE yecb_t_converter_col . + METHODS get_filter + EXPORTING + !et_filter TYPE yecb_t_converter_fil + CHANGING + !xo_table TYPE REF TO data . +*"* private components of class ZCL_EXCEL_CONVERTER_ALV +*"* do not include other source files here!!! + PRIVATE SECTION. + + CLASS-DATA wt_colors TYPE tt_col_converter . +ENDCLASS. + + + +CLASS ycl_ecb_converter_alv IMPLEMENTATION. + + + METHOD apply_sort. + DATA: lt_otab TYPE abap_sortorder_tab, + ls_otab TYPE abap_sortorder. + + FIELD-SYMBOLS: TYPE STANDARD TABLE, + TYPE lvc_s_sort. + + CREATE DATA eo_table LIKE it_table. + ASSIGN eo_table->* TO . + + = it_table. + + SORT wt_sort BY spos. + LOOP AT wt_sort ASSIGNING . + IF -up = abap_true. + ls_otab-name = -fieldname. + ls_otab-descending = abap_false. +* ls_otab-astext = abap_true. " not only text fields + INSERT ls_otab INTO TABLE lt_otab. + ENDIF. + IF -down = abap_true. + ls_otab-name = -fieldname. + ls_otab-descending = abap_true. +* ls_otab-astext = abap_true. " not only text fields + INSERT ls_otab INTO TABLE lt_otab. + ENDIF. + ENDLOOP. + IF lt_otab IS NOT INITIAL. + SORT BY (lt_otab). + ENDIF. + + ENDMETHOD. + + + METHOD class_constructor. +* let's fill the color conversion routines. + DATA: ls_color TYPE ts_col_converter. +* 0 all combination the same + ls_color-col = 0. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 0. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 0. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 0. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + +* Blue + ls_color-col = 1. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFB0E4FC'. " 176 228 252 blue + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 1. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FFB0E4FC'. " 176 228 252 blue + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 1. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FF5FCBFE'. " 095 203 254 Int blue + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 1. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FF5FCBFE'. " 095 203 254 + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 + INSERT ls_color INTO TABLE wt_colors. + +* Gray + ls_color-col = 2. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. + ls_color-fillcolor = 'FFE5EAF0'. " 229 234 240 gray + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 2. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FFE5EAF0'. " 229 234 240 gray + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 2. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFD8E8F4'. " 216 234 244 int gray + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 2. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FFD8E8F4'. " 216 234 244 int gray + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + +*Yellow + ls_color-col = 3. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFEFEB8'. " 254 254 184 yellow + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 3. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FFFEFEB8'. " 254 254 184 yellow + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 3. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFF9ED5D'. " 249 237 093 int yellow + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 3. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FFF9ED5D'. " 249 237 093 int yellow + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + +* light blue + ls_color-col = 4. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFCEE7FB'. " 206 231 251 light blue + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 4. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FFCEE7FB'. " 206 231 251 light blue + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 4. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FF9ACCEF'. " 154 204 239 int light blue + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 4. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FF9ACCEF'. " 154 204 239 int light blue + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + +* Green + ls_color-col = 5. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFCEF8AE'. " 206 248 174 Green + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 5. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FFCEF8AE'. " 206 248 174 Green + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 5. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FF7AC769'. " 122 199 105 int Green + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 5. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FF7AC769'. " 122 199 105 int Green + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + +* Red + ls_color-col = 6. + ls_color-int = 0. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFDBBBC'. " 253 187 188 Red + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 6. + ls_color-int = 0. + ls_color-inv = 1. + ls_color-fontcolor = 'FFFDBBBC'. " 253 187 188 Red + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 6. + ls_color-int = 1. + ls_color-inv = 0. + ls_color-fontcolor = 'FF000000'. " 000 000 000 Black + ls_color-fillcolor = 'FFFB6B6B'. " 251 107 107 int Red + INSERT ls_color INTO TABLE wt_colors. + + ls_color-col = 6. + ls_color-int = 1. + ls_color-inv = 1. + ls_color-fontcolor = 'FFFB6B6B'. " 251 107 107 int Red + ls_color-fillcolor = 'FFFFFFFF'. " 255 255 255 White + INSERT ls_color INTO TABLE wt_colors. + + ENDMETHOD. + + + METHOD get_color. + DATA: ls_con_col TYPE yecb_s_converter_col, + ls_color TYPE ts_col_converter, + l_line TYPE i, + l_color(4) TYPE c. + FIELD-SYMBOLS: TYPE STANDARD TABLE, + TYPE any, + TYPE any, + TYPE STANDARD TABLE, + TYPE any. + +* Loop trough the table to set the color properties of each line. The color properties field is +* Char 4 and the characters is set as follows: +* Char 1 = C = This is a color property +* Char 2 = 6 = Color code (1 - 7) +* Char 3 = Intensified on/of = 1 = on +* Char 4 = Inverse display = 0 = of + + ASSIGN io_table->* TO . + + IF ws_layo-info_fname IS NOT INITIAL OR + ws_layo-ctab_fname IS NOT INITIAL. + LOOP AT ASSIGNING . + l_line = sy-tabix. + IF ws_layo-info_fname IS NOT INITIAL. + ASSIGN COMPONENT ws_layo-info_fname OF STRUCTURE TO . + IF sy-subrc = 0 AND IS NOT INITIAL. + l_color = . + IF l_color(1) = 'C'. + READ TABLE wt_colors INTO ls_color WITH TABLE KEY col = l_color+1(1) + int = l_color+2(1) + inv = l_color+3(1). + IF sy-subrc = 0. + ls_con_col-rownumber = l_line. + ls_con_col-columnname = space. + ls_con_col-fontcolor = ls_color-fontcolor. + ls_con_col-fillcolor = ls_color-fillcolor. + INSERT ls_con_col INTO TABLE et_colors. + ENDIF. + ENDIF. + ENDIF. + ENDIF. + IF ws_layo-ctab_fname IS NOT INITIAL. + + ASSIGN COMPONENT ws_layo-ctab_fname OF STRUCTURE TO . + IF sy-subrc = 0. + LOOP AT ASSIGNING . + ASSIGN COMPONENT 'COLOR' OF STRUCTURE TO . + IF sy-subrc = 0. + IF IS NOT INITIAL. + FIELD-SYMBOLS: TYPE any, + TYPE any, + TYPE any, + TYPE any, + TYPE any. + ASSIGN COMPONENT 'COL' OF STRUCTURE TO . + ASSIGN COMPONENT 'INT' OF STRUCTURE TO . + ASSIGN COMPONENT 'INV' OF STRUCTURE TO . + READ TABLE wt_colors INTO ls_color WITH TABLE KEY col = + int = + inv = . + IF sy-subrc = 0. + ls_con_col-rownumber = l_line. + ASSIGN COMPONENT 'FNAME' OF STRUCTURE TO . + IF sy-subrc NE 0. + ASSIGN COMPONENT 'FIELDNAME' OF STRUCTURE TO . + IF sy-subrc EQ 0. + ls_con_col-columnname = . + ENDIF. + ELSE. + ls_con_col-columnname = . + ENDIF. + + ls_con_col-fontcolor = ls_color-fontcolor. + ls_con_col-fillcolor = ls_color-fillcolor. + ASSIGN COMPONENT 'NOKEYCOL' OF STRUCTURE TO . + IF sy-subrc EQ 0. + ls_con_col-nokeycol = . + ENDIF. + INSERT ls_con_col INTO TABLE et_colors. + ENDIF. + ENDIF. + ENDIF. + ENDLOOP. + ENDIF. + ENDIF. + ENDLOOP. + ENDIF. + ENDMETHOD. + + + METHOD get_filter. + DATA: ls_filt TYPE lvc_s_filt, + l_line TYPE i, + ls_filter TYPE yecb_s_converter_fil. + DATA: lo_addit TYPE REF TO cl_abap_elemdescr, + lt_components_tab TYPE cl_abap_structdescr=>component_table, + ls_components TYPE abap_componentdescr, + lo_table TYPE REF TO cl_abap_tabledescr, + lo_struc TYPE REF TO cl_abap_structdescr, + lo_trange TYPE REF TO data, + lo_srange TYPE REF TO data, + lo_ltabdata TYPE REF TO data. + + FIELD-SYMBOLS: TYPE STANDARD TABLE, + TYPE STANDARD TABLE, + TYPE any, + TYPE any, + TYPE any, + TYPE any, + TYPE STANDARD TABLE. + + IF ws_option-filter = abap_false. + CLEAR et_filter. + RETURN. + ENDIF. + + ASSIGN xo_table->* TO . + + CREATE DATA lo_ltabdata LIKE . + ASSIGN lo_ltabdata->* TO . + + LOOP AT wt_filt INTO ls_filt. + LOOP AT ASSIGNING . + l_line = sy-tabix. + ASSIGN COMPONENT ls_filt-fieldname OF STRUCTURE TO . + IF sy-subrc = 0. + IF l_line = 1. + CLEAR lt_components_tab. + ls_components-name = 'SIGN'. + lo_addit ?= cl_abap_typedescr=>describe_by_data( ls_filt-sign ). + ls_components-type = lo_addit . + INSERT ls_components INTO TABLE lt_components_tab. + ls_components-name = 'OPTION'. + lo_addit ?= cl_abap_typedescr=>describe_by_data( ls_filt-option ). + ls_components-type = lo_addit . + INSERT ls_components INTO TABLE lt_components_tab. + ls_components-name = 'LOW'. + lo_addit ?= cl_abap_typedescr=>describe_by_data( ). + ls_components-type = lo_addit . + INSERT ls_components INTO TABLE lt_components_tab. + ls_components-name = 'HIGH'. + lo_addit ?= cl_abap_typedescr=>describe_by_data( ). + ls_components-type = lo_addit . + INSERT ls_components INTO TABLE lt_components_tab. + "create new line type + TRY. + lo_struc = cl_abap_structdescr=>create( p_components = lt_components_tab + p_strict = abap_false ). + CATCH cx_sy_struct_creation. + CONTINUE. + ENDTRY. + lo_table = cl_abap_tabledescr=>create( lo_struc ). + + CREATE DATA lo_trange TYPE HANDLE lo_table. + CREATE DATA lo_srange TYPE HANDLE lo_struc. + + ASSIGN lo_trange->* TO . + ASSIGN lo_srange->* TO . + ENDIF. + CLEAR . + ASSIGN COMPONENT 'SIGN' OF STRUCTURE TO . + = ls_filt-sign. + ASSIGN COMPONENT 'OPTION' OF STRUCTURE TO . + = ls_filt-option. + ASSIGN COMPONENT 'LOW' OF STRUCTURE TO . + = ls_filt-low. + ASSIGN COMPONENT 'HIGH' OF STRUCTURE TO . + = ls_filt-high. + INSERT INTO TABLE . + IF IN . + IF ws_option-filter = abap_true. + ls_filter-rownumber = l_line. + ls_filter-columnname = ls_filt-fieldname. + INSERT ls_filter INTO TABLE et_filter. + ELSE. + INSERT INTO TABLE . + ENDIF. + ENDIF. + ENDIF. + ENDLOOP. + IF ws_option-filter = abap_undefined. + = . + CLEAR . + ENDIF. + ENDLOOP. + + ENDMETHOD. + + + METHOD update_catalog. + DATA: ls_fieldcatalog TYPE yecb_s_converter_fcat, + ls_fcat TYPE lvc_s_fcat, + ls_sort TYPE lvc_s_sort, + l_decimals TYPE lvc_decmls. + + FIELD-SYMBOLS: TYPE yecb_s_converter_fcat. + + IF ws_layo-zebra IS NOT INITIAL. + cs_layout-is_stripped = abap_true. + ENDIF. + IF ws_layo-no_keyfix IS INITIAL OR + ws_layo-no_keyfix = '0'. + cs_layout-is_fixed = abap_true. + ENDIF. + + LOOP AT wt_fcat INTO ls_fcat. + CLEAR: ls_fieldcatalog, + l_decimals. + CASE ws_option-hidenc. + WHEN abap_false. " We make hiden columns visible + CLEAR ls_fcat-no_out. + WHEN abap_true. +* We convert column and hide it. + WHEN abap_undefined. "We don't convert hiden columns + IF ls_fcat-no_out = abap_true. + ls_fcat-tech = abap_true. + ENDIF. + ENDCASE. + IF ls_fcat-tech = abap_false. + ls_fieldcatalog-tabname = ls_fcat-tabname. + ls_fieldcatalog-fieldname = ls_fcat-fieldname . + ls_fieldcatalog-columnname = ls_fcat-fieldname . + ls_fieldcatalog-position = ls_fcat-col_pos. + ls_fieldcatalog-col_id = ls_fcat-col_id. + ls_fieldcatalog-convexit = ls_fcat-convexit. + ls_fieldcatalog-inttype = ls_fcat-inttype. + ls_fieldcatalog-scrtext_s = ls_fcat-scrtext_s . + ls_fieldcatalog-scrtext_m = ls_fcat-scrtext_m . + ls_fieldcatalog-scrtext_l = ls_fcat-scrtext_l. + l_decimals = ls_fcat-decimals_o. + IF l_decimals IS NOT INITIAL. + ls_fieldcatalog-decimals = l_decimals. + ELSE. + ls_fieldcatalog-decimals = ls_fcat-decimals . + ENDIF. + CASE ws_option-subtot. + WHEN abap_false. " We ignore subtotals + CLEAR ls_fcat-do_sum. + WHEN abap_true. " We convert subtotals and detail + + WHEN abap_undefined. " We should only take subtotals and displayed detail +* for now abap_true + ENDCASE. + CASE ls_fcat-do_sum. + WHEN abap_true. + ls_fieldcatalog-totals_function = ycl_ecb_table=>totals_function_sum. + WHEN 'A'. + ls_fieldcatalog-totals_function = ycl_ecb_table=>totals_function_min. + WHEN 'B' . + ls_fieldcatalog-totals_function = ycl_ecb_table=>totals_function_max. + WHEN 'C' . + ls_fieldcatalog-totals_function = ycl_ecb_table=>totals_function_average. + WHEN OTHERS. + CLEAR ls_fieldcatalog-totals_function . + ENDCASE. + ls_fieldcatalog-fix_column = ls_fcat-fix_column. + IF ws_layo-cwidth_opt IS INITIAL. + IF ls_fcat-col_opt IS NOT INITIAL. + ls_fieldcatalog-is_optimized = abap_true. + ENDIF. + ELSE. + ls_fieldcatalog-is_optimized = abap_true. + ENDIF. + IF ls_fcat-no_out IS NOT INITIAL. + ls_fieldcatalog-is_hidden = abap_true. + ls_fieldcatalog-position = ls_fieldcatalog-col_id. " We hide based on orginal data structure + ENDIF. +* Alignment in each cell + CASE ls_fcat-just. + WHEN 'R'. + ls_fieldcatalog-alignment = ycl_ecb_style_alignment=>c_horizontal_right. + WHEN 'L'. + ls_fieldcatalog-alignment = ycl_ecb_style_alignment=>c_horizontal_left. + WHEN 'C'. + ls_fieldcatalog-alignment = ycl_ecb_style_alignment=>c_horizontal_center. + WHEN OTHERS. + CLEAR ls_fieldcatalog-alignment. + ENDCASE. +* Check for subtotals. + READ TABLE wt_sort INTO ls_sort WITH KEY fieldname = ls_fcat-fieldname. + IF sy-subrc = 0 AND ws_option-subtot <> abap_false. + ls_fieldcatalog-sort_level = 0 . + ls_fieldcatalog-is_subtotalled = ls_sort-subtot. + ls_fieldcatalog-is_collapsed = ls_sort-expa. + IF ls_fieldcatalog-is_subtotalled = abap_true. + ls_fieldcatalog-sort_level = ls_sort-spos. + ls_fieldcatalog-totals_function = ycl_ecb_table=>totals_function_sum. " we need function for text + ENDIF. + ENDIF. + APPEND ls_fieldcatalog TO ct_fieldcatalog. + ENDIF. + ENDLOOP. + + SORT ct_fieldcatalog BY sort_level ASCENDING. + cs_layout-max_subtotal_level = 0. + LOOP AT ct_fieldcatalog ASSIGNING WHERE sort_level > 0. + cs_layout-max_subtotal_level = cs_layout-max_subtotal_level + 1. + -sort_level = cs_layout-max_subtotal_level. + ENDLOOP. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_alv.clas.locals_def.abap b/src/abap2xlsx/ycl_ecb_converter_alv.clas.locals_def.abap new file mode 100644 index 0000000..51743fd --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_alv.clas.locals_def.abap @@ -0,0 +1,12 @@ +*"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature +TYPES: BEGIN OF ts_col_converter, + col TYPE lvc_col, + int TYPE lvc_int, + inv TYPE lvc_inv, + fontcolor TYPE yecb_style_color_argb, + fillcolor TYPE yecb_style_color_argb, + END OF ts_col_converter, + + tt_col_converter TYPE HASHED TABLE OF ts_col_converter WITH UNIQUE KEY col int inv. diff --git a/src/abap2xlsx/ycl_ecb_converter_alv.clas.xml b/src/abap2xlsx/ycl_ecb_converter_alv.clas.xml new file mode 100644 index 0000000..58ec5e1 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_alv.clas.xml @@ -0,0 +1,118 @@ + + + + + + YCL_ECB_CONVERTER_ALV + E + ALV grid interface implementation + 1 + X + X + X + + + + APPLY_SORT + E + Apply sort criteria to data table + + + APPLY_SORT + I + Apply sort criteria to data table + + + CLASS_CONSTRUCTOR + E + CLASS_CONSTRUCTOR + + + CLASS_CONSTRUCTOR + I + CLASS_CONSTRUCTOR + + + GET_COLOR + E + Create color table for formating + + + GET_COLOR + I + Create color table for formating + + + GET_FILTER + E + Create filter values + + + GET_FILTER + I + Create filter values + + + UPDATE_CATALOG + E + Create fieldcatalog and layout + + + UPDATE_CATALOG + I + Create fieldcatalog and layout + + + WS_LAYO + E + ALV control: Layout structure + + + WS_LAYO + I + ALV control: Layout structure + + + WS_OPTION + E + Converter options for grid configuration + + + WS_OPTION + I + Converter options for grid configuration + + + WT_FCAT + E + Field Catalog for List Viewer Control + + + WT_FCAT + I + Field Catalog for List Viewer Control + + + WT_FILT + E + ALV control: Table of filter conditions + + + WT_FILT + I + ALV control: Table of filter conditions + + + WT_SORT + E + ALV Control: Table of Sort Criteria + + + WT_SORT + I + ALV Control: Table of Sort Criteria + + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_alv_grid.clas.abap b/src/abap2xlsx/ycl_ecb_converter_alv_grid.clas.abap new file mode 100644 index 0000000..94a654c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_alv_grid.clas.abap @@ -0,0 +1,77 @@ +CLASS ycl_ecb_converter_alv_grid DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_converter_alv + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS yif_ecb_converter~can_convert_object + REDEFINITION . +*"* public components of class ZCL_EXCEL_CONVERTER_ALV_GRID +*"* do not include other source files here!!! + METHODS yif_ecb_converter~create_fieldcatalog + REDEFINITION . + METHODS yif_ecb_converter~get_supported_class + REDEFINITION . + PROTECTED SECTION. +*"* protected components of class ZCL_EXCEL_CONVERTER_ALV_GRID +*"* do not include other source files here!!! +*"* private components of class ZCL_EXCEL_CONVERTER_ALV_GRID +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_converter_alv_grid IMPLEMENTATION. + + + METHOD yif_ecb_converter~get_supported_class. + rv_supported_class = 'CL_GUI_ALV_GRID'. + ENDMETHOD. + + METHOD yif_ecb_converter~can_convert_object. + DATA: lo_alv TYPE REF TO cl_gui_alv_grid. + + TRY. + lo_alv ?= io_object. + CATCH cx_sy_move_cast_error . + RAISE EXCEPTION TYPE ycx_ecb. + ENDTRY. + + ENDMETHOD. + + + METHOD yif_ecb_converter~create_fieldcatalog. + DATA: lo_alv TYPE REF TO cl_gui_alv_grid. + + yif_ecb_converter~can_convert_object( io_object = io_object ). + + ws_option = is_option. + + lo_alv ?= io_object. + + CLEAR: es_layout, + et_fieldcatalog. + + IF lo_alv IS BOUND. + lo_alv->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = wt_fcat ). + lo_alv->get_frontend_layout( IMPORTING es_layout = ws_layo ). + lo_alv->get_sort_criteria( IMPORTING et_sort = wt_sort ) . + lo_alv->get_filter_criteria( IMPORTING et_filter = wt_filt ) . + + apply_sort( EXPORTING it_table = it_table + IMPORTING eo_table = eo_table ) . + + get_color( EXPORTING io_table = eo_table + IMPORTING et_colors = et_colors ) . + + get_filter( IMPORTING et_filter = et_filter + CHANGING xo_table = eo_table ) . + + update_catalog( CHANGING cs_layout = es_layout + ct_fieldcatalog = et_fieldcatalog ). + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_alv_grid.clas.xml b/src/abap2xlsx/ycl_ecb_converter_alv_grid.clas.xml new file mode 100644 index 0000000..520a520 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_alv_grid.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_CONVERTER_ALV_GRID + E + SALV converter + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_result.clas.abap b/src/abap2xlsx/ycl_ecb_converter_result.clas.abap new file mode 100644 index 0000000..45c6540 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_result.clas.abap @@ -0,0 +1,55 @@ +CLASS ycl_ecb_converter_result DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_converter_alv + ABSTRACT + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_CONVERTER_RESULT +*"* do not include other source files here!!! + PUBLIC SECTION. +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT +*"* do not include other source files here!!! + PROTECTED SECTION. + + METHODS get_table + IMPORTING + !io_object TYPE REF TO object + RETURNING + VALUE(ro_data) TYPE REF TO data . +*"* private components of class ZCL_EXCEL_CONVERTER_RESULT +*"* do not include other source files here!!! +*"* private components of class ZCL_EXCEL_CONVERTER_RESULT +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_converter_result IMPLEMENTATION. + + + METHOD get_table. + DATA: lo_object TYPE REF TO object, + ls_seoclass TYPE seoclass, + l_method TYPE string. + + SELECT SINGLE * INTO ls_seoclass + FROM seoclass + WHERE clsname = 'IF_SALV_BS_DATA_SOURCE'. + + IF sy-subrc = 0. + l_method = 'GET_TABLE_REF'. + lo_object ?= io_object. + CALL METHOD lo_object->(l_method) + RECEIVING + value = ro_data. + ELSE. + l_method = 'GET_REF_TO_TABLE'. + lo_object ?= io_object. + CALL METHOD lo_object->(l_method) + RECEIVING + value = ro_data. + ENDIF. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_result.clas.xml b/src/abap2xlsx/ycl_ecb_converter_result.clas.xml new file mode 100644 index 0000000..9b3441a --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_result.clas.xml @@ -0,0 +1,28 @@ + + + + + + YCL_ECB_CONVERTER_RESULT + E + Result object for table reference + 1 + X + X + X + + + + GET_TABLE + E + Get table + + + GET_TABLE + I + Get table + + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_result_ex.clas.abap b/src/abap2xlsx/ycl_ecb_converter_result_ex.clas.abap new file mode 100644 index 0000000..24ea9b0 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_result_ex.clas.abap @@ -0,0 +1,97 @@ +CLASS ycl_ecb_converter_result_ex DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_converter_result + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_CONVERTER_RESULT_EX +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS yif_ecb_converter~can_convert_object + REDEFINITION . + METHODS yif_ecb_converter~create_fieldcatalog + REDEFINITION . + METHODS yif_ecb_converter~get_supported_class + REDEFINITION . +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_EX +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_EX +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_EX +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_CONVERTER_EX_RESULT +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_converter_result_ex IMPLEMENTATION. + + METHOD yif_ecb_converter~get_supported_class. + rv_supported_class = 'CL_SALV_EX_RESULT_DATA_TABLE'. + ENDMETHOD. + + METHOD yif_ecb_converter~can_convert_object. + + DATA: lo_result TYPE REF TO cl_salv_ex_result_data_table. + + TRY. + lo_result ?= io_object. + CATCH cx_sy_move_cast_error . + RAISE EXCEPTION TYPE ycx_ecb. + ENDTRY. + + ENDMETHOD. + + + METHOD yif_ecb_converter~create_fieldcatalog. + DATA: lo_result TYPE REF TO cl_salv_ex_result_data_table, + lo_ex_cm TYPE REF TO cl_salv_ex_cm, + lo_data TYPE REF TO data. + + FIELD-SYMBOLS: TYPE STANDARD TABLE. + + yif_ecb_converter~can_convert_object( io_object = io_object ). + + ws_option = is_option. + + lo_result ?= io_object. + + CLEAR: es_layout, + et_fieldcatalog. + + IF lo_result IS BOUND. + lo_data = get_table( io_object = lo_result->r_model->r_data ). + IF lo_data IS BOUND. + ASSIGN lo_data->* TO . + + lo_ex_cm ?= lo_result->r_model->r_model. + ws_layo = lo_ex_cm->s_layo. +* T_DRDN Instance Attribute Public Type LVC_T_DROP + wt_fcat = lo_ex_cm->t_fcat. + wt_filt = lo_ex_cm->t_filt. +* T_HYPE Instance Attribute Public Type LVC_T_HYPE +* T_SELECTED_CELLS Instance Attribute Public Type LVC_T_CELL +* T_SELECTED_COLUMNS Instance Attribute Public Type LVC_T_COL + wt_sort = lo_ex_cm->t_sort. + + apply_sort( EXPORTING it_table = + IMPORTING eo_table = eo_table ) . + + get_color( EXPORTING io_table = eo_table + IMPORTING et_colors = et_colors ) . + + get_filter( IMPORTING et_filter = et_filter + CHANGING xo_table = eo_table ) . + + update_catalog( CHANGING cs_layout = es_layout + ct_fieldcatalog = et_fieldcatalog ). + ELSE. +* We have a problem and should stop here. + ENDIF. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_result_ex.clas.xml b/src/abap2xlsx/ycl_ecb_converter_result_ex.clas.xml new file mode 100644 index 0000000..54f0d10 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_result_ex.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_CONVERTER_RESULT_EX + E + SALV - ALV converter for export + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_result_wd.clas.abap b/src/abap2xlsx/ycl_ecb_converter_result_wd.clas.abap new file mode 100644 index 0000000..06ac4e8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_result_wd.clas.abap @@ -0,0 +1,250 @@ +CLASS ycl_ecb_converter_result_wd DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_converter_result + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_CONVERTER_RESULT_WD +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS yif_ecb_converter~can_convert_object + REDEFINITION . + METHODS yif_ecb_converter~create_fieldcatalog + REDEFINITION . + METHODS yif_ecb_converter~get_supported_class + REDEFINITION . +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_WD +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_WD +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_CONVERTER_RESULT_WD +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + DATA wo_config TYPE REF TO cl_salv_wd_config_table . + DATA wt_fields TYPE salv_wd_t_field_ref . + DATA wt_columns TYPE salv_wd_t_column_ref . + + METHODS get_columns_info + CHANGING + !xs_fcat TYPE lvc_s_fcat . + METHODS get_fields_info + CHANGING + !xs_fcat TYPE lvc_s_fcat . + METHODS create_wt_sort . + METHODS create_wt_filt . + METHODS create_wt_fcat + IMPORTING + !io_table TYPE REF TO data . +ENDCLASS. + + + +CLASS ycl_ecb_converter_result_wd IMPLEMENTATION. + + + METHOD create_wt_fcat. + DATA: lr_data TYPE REF TO data, + lo_structdescr TYPE REF TO cl_abap_structdescr, + lt_dfies TYPE ddfields, + ls_dfies TYPE dfies. + + DATA: ls_fcat TYPE lvc_s_fcat. + + FIELD-SYMBOLS: TYPE ANY TABLE. + + ASSIGN io_table->* TO . + CREATE DATA lr_data LIKE LINE OF . + + lo_structdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ). + + lt_dfies = ycl_ecb_common=>describe_structure( io_struct = lo_structdescr ). + + LOOP AT lt_dfies INTO ls_dfies. + MOVE-CORRESPONDING ls_dfies TO ls_fcat. + ls_fcat-col_pos = ls_dfies-position. + ls_fcat-key = ls_dfies-keyflag. + get_fields_info( CHANGING xs_fcat = ls_fcat ) . + + ls_fcat-col_opt = abap_true. + + get_columns_info( CHANGING xs_fcat = ls_fcat ) . + + INSERT ls_fcat INTO TABLE wt_fcat. + ENDLOOP. + + ENDMETHOD. + + + METHOD create_wt_filt. +* No neeed for superclass. +* Only for WD + DATA: lt_filters TYPE salv_wd_t_filter_rule_ref, + ls_filt TYPE lvc_s_filt. + + FIELD-SYMBOLS: TYPE salv_wd_s_field_ref, + TYPE salv_wd_s_filter_rule_ref. + + LOOP AT wt_fields ASSIGNING . + CLEAR lt_filters. + lt_filters = -r_field->if_salv_wd_filter~get_filter_rules( ) . + LOOP AT lt_filters ASSIGNING . + ls_filt-fieldname = -fieldname. + IF -r_filter_rule->get_included( ) = abap_true. + ls_filt-sign = 'I'. + ELSE. + ls_filt-sign = 'E'. + ENDIF. + ls_filt-option = -r_filter_rule->get_operator( ). + ls_filt-high = -r_filter_rule->get_high_value( ) . + ls_filt-low = -r_filter_rule->get_low_value( ) . + INSERT ls_filt INTO TABLE wt_filt. + ENDLOOP. + ENDLOOP. + + ENDMETHOD. + + + METHOD create_wt_sort. + DATA: lo_sort TYPE REF TO cl_salv_wd_sort_rule, + l_sort_order TYPE salv_wd_constant, + ls_sort TYPE lvc_s_sort. + + FIELD-SYMBOLS: TYPE salv_wd_s_field_ref. + + LOOP AT wt_fields ASSIGNING . + lo_sort = -r_field->if_salv_wd_sort~get_sort_rule( ) . + IF lo_sort IS BOUND. + l_sort_order = lo_sort->get_sort_order( ). + IF l_sort_order <> if_salv_wd_c_sort=>sort_order. + CLEAR ls_sort. + ls_sort-spos = lo_sort->get_sort_position( ). + ls_sort-fieldname = -fieldname. + ls_sort-subtot = lo_sort->get_group_aggregation( ). + IF l_sort_order = if_salv_wd_c_sort=>sort_order_ascending. + ls_sort-up = abap_true. + ELSE. + ls_sort-down = abap_true. + ENDIF. + INSERT ls_sort INTO TABLE wt_sort. + ENDIF. + ENDIF. + ENDLOOP. + + ENDMETHOD. + + + METHOD get_columns_info. + DATA: l_numc2 TYPE salv_wd_constant. + + + FIELD-SYMBOLS: TYPE salv_wd_s_column_ref. + + READ TABLE wt_columns ASSIGNING WITH KEY id = xs_fcat-fieldname . + IF sy-subrc = 0. + xs_fcat-col_pos = -r_column->get_position( ) . + l_numc2 = -r_column->get_fixed_position( ). + IF l_numc2 = '02'. + xs_fcat-fix_column = abap_true . + ENDIF. + l_numc2 = -r_column->get_visible( ). + IF l_numc2 = '01'. + xs_fcat-no_out = abap_true . + ENDIF. + ENDIF. + + ENDMETHOD. + + + METHOD get_fields_info. + DATA: lo_aggr TYPE REF TO cl_salv_wd_aggr_rule, + l_aggrtype TYPE salv_wd_constant. + + FIELD-SYMBOLS: TYPE salv_wd_s_field_ref. + + READ TABLE wt_fields ASSIGNING WITH KEY fieldname = xs_fcat-fieldname. + IF sy-subrc = 0. + lo_aggr = -r_field->if_salv_wd_aggr~get_aggr_rule( ) . + IF lo_aggr IS BOUND. + l_aggrtype = lo_aggr->get_aggregation_type( ) . + CASE l_aggrtype. + WHEN if_salv_wd_c_aggregation=>aggrtype_total. + xs_fcat-do_sum = abap_true. + WHEN if_salv_wd_c_aggregation=>aggrtype_minimum. + xs_fcat-do_sum = 'A'. + WHEN if_salv_wd_c_aggregation=>aggrtype_maximum . + xs_fcat-do_sum = 'B'. + WHEN if_salv_wd_c_aggregation=>aggrtype_average . + xs_fcat-do_sum = 'C'. + WHEN OTHERS. + CLEAR xs_fcat-do_sum . + ENDCASE. + ENDIF. + ENDIF. + + ENDMETHOD. + + METHOD yif_ecb_converter~get_supported_class. + rv_supported_class = 'CL_SALV_WD_RESULT_DATA_TABLE'. + ENDMETHOD. + + METHOD yif_ecb_converter~can_convert_object. + + DATA: lo_result TYPE REF TO cl_salv_wd_result_data_table. + + TRY. + lo_result ?= io_object. + CATCH cx_sy_move_cast_error . + RAISE EXCEPTION TYPE ycx_ecb. + ENDTRY. + + ENDMETHOD. + + + METHOD yif_ecb_converter~create_fieldcatalog. + DATA: lo_result TYPE REF TO cl_salv_wd_result_data_table, + lo_data TYPE REF TO data. + + FIELD-SYMBOLS: TYPE STANDARD TABLE. + + yif_ecb_converter~can_convert_object( io_object = io_object ). + + ws_option = is_option. + + lo_result ?= io_object. + + CLEAR: es_layout, + et_fieldcatalog. + + IF lo_result IS BOUND. + lo_data = get_table( io_object = lo_result->r_model->r_data ). + IF lo_data IS BOUND. + ASSIGN lo_data->* TO . + + wo_config ?= lo_result->r_model->r_model. + + IF wo_config IS BOUND. + wt_fields = wo_config->if_salv_wd_field_settings~get_fields( ) . + wt_columns = wo_config->if_salv_wd_column_settings~get_columns( ) . + ENDIF. + + create_wt_fcat( io_table = lo_data ). + create_wt_sort( ). + create_wt_filt( ). + + apply_sort( EXPORTING it_table = + IMPORTING eo_table = eo_table ) . + + get_filter( IMPORTING et_filter = et_filter + CHANGING xo_table = eo_table ) . + + update_catalog( CHANGING cs_layout = es_layout + ct_fieldcatalog = et_fieldcatalog ). + ELSE. +* We have a problem and should stop here + ENDIF. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_result_wd.clas.xml b/src/abap2xlsx/ycl_ecb_converter_result_wd.clas.xml new file mode 100644 index 0000000..17d792a --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_result_wd.clas.xml @@ -0,0 +1,98 @@ + + + + + + YCL_ECB_CONVERTER_RESULT_WD + E + SALV converter for web dynpro + 1 + X + X + X + + + + CREATE_WT_FCAT + E + Create wt_fcat for WD interface + + + CREATE_WT_FCAT + I + Create wt_fcat for WD interface + + + CREATE_WT_FILT + E + Create wt_filt for WD interface + + + CREATE_WT_FILT + I + Create wt_filt for WD interface + + + CREATE_WT_SORT + E + Create wt_sort for WD interface + + + CREATE_WT_SORT + I + Create wt_sort for WD interface + + + GET_COLUMNS_INFO + E + Read data from WD columns object + + + GET_COLUMNS_INFO + I + Read data from WD columns object + + + GET_FIELDS_INFO + E + Get aggregation from field table + + + GET_FIELDS_INFO + I + Get aggregation from field table + + + WO_CONFIG + E + Configuration of the ALV Output + + + WO_CONFIG + I + Configuration of the ALV Output + + + WT_COLUMNS + E + SALV_WD_T_COLUMN_REF + + + WT_COLUMNS + I + SALV_WD_T_COLUMN_REF + + + WT_FIELDS + E + SALV_WD_T_FIELD_REF + + + WT_FIELDS + I + SALV_WD_T_FIELD_REF + + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_salv_model.clas.abap b/src/abap2xlsx/ycl_ecb_converter_salv_model.clas.abap new file mode 100644 index 0000000..8ec2dd6 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_salv_model.clas.abap @@ -0,0 +1,39 @@ +CLASS ycl_ecb_converter_salv_model DEFINITION + PUBLIC + INHERITING FROM cl_salv_model + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + CLASS-METHODS is_get_metadata_callable + IMPORTING + io_salv TYPE REF TO cl_salv_table + RETURNING + VALUE(result) TYPE abap_bool. + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_converter_salv_model IMPLEMENTATION. + + METHOD is_get_metadata_callable. + DATA: lo_object TYPE REF TO object, + lo_model TYPE REF TO cl_salv_model. + + " In 7.52 and older versions, we have a short dump with CL_SALV_TABLE->GET_METADATA if the ALV is not displayed + " (due to io_salv->r_controller->r_adapter not instantiated yet). That's later fixed by SAP (no short dump in 7.57). + " NB: r_controller is always instantiated. + lo_object = io_salv. + TRY. + lo_model ?= lo_object. + CATCH cx_sy_move_cast_error. + " In 7.57, CL_SALV_TABLE is no more a subclass of CL_SALV_MODEL, but CL_SALV_TABLE->GET_METADATA can be called. + result = abap_true. + RETURN. + ENDTRY. + result = boolc( lo_model->r_controller->r_adapter IS BOUND ). + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_salv_model.clas.xml b/src/abap2xlsx/ycl_ecb_converter_salv_model.clas.xml new file mode 100644 index 0000000..b4c24b2 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_salv_model.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_CONVERTER_SALV_MODEL + E + SALV model utility methods + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_converter_salv_table.clas.abap b/src/abap2xlsx/ycl_ecb_converter_salv_table.clas.abap new file mode 100644 index 0000000..c9a5f4a --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_salv_table.clas.abap @@ -0,0 +1,273 @@ +CLASS ycl_ecb_converter_salv_table DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_converter_alv + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_CONVERTER_SALV_TABLE +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS yif_ecb_converter~can_convert_object + REDEFINITION . + METHODS yif_ecb_converter~create_fieldcatalog + REDEFINITION . + METHODS yif_ecb_converter~get_supported_class + REDEFINITION . +*"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_CONVERTER_SALV_TABLE +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + METHODS load_data + IMPORTING + !io_salv TYPE REF TO cl_salv_table + !it_table TYPE STANDARD TABLE . + METHODS is_intercept_data_active + RETURNING + VALUE(rv_result) TYPE abap_bool. +ENDCLASS. + + + +CLASS ycl_ecb_converter_salv_table IMPLEMENTATION. + + + METHOD load_data. + DATA: lo_columns TYPE REF TO cl_salv_columns_table, + lo_aggregations TYPE REF TO cl_salv_aggregations, + lo_sorts TYPE REF TO cl_salv_sorts, + lo_filters TYPE REF TO cl_salv_filters, + lo_functional TYPE REF TO cl_salv_functional_settings, + lo_display TYPE REF TO cl_salv_display_settings. + + DATA: ls_vari TYPE disvariant, + lo_layout TYPE REF TO cl_salv_layout. + + DATA lt_kkblo_fieldcat TYPE kkblo_t_fieldcat. + DATA ls_kkblo_layout TYPE kkblo_layout. + DATA lt_kkblo_filter TYPE kkblo_t_filter. + DATA lt_kkblo_sort TYPE kkblo_t_sortinfo. + DATA: lv_intercept_data_active TYPE abap_bool, + ls_layout_key TYPE salv_s_layout_key. + + lo_layout = io_salv->get_layout( ) . + lo_columns = io_salv->get_columns( ). + lo_aggregations = io_salv->get_aggregations( ) . + lo_sorts = io_salv->get_sorts( ) . + lo_filters = io_salv->get_filters( ) . + lo_display = io_salv->get_display_settings( ) . + lo_functional = io_salv->get_functional_settings( ) . + + CLEAR: wt_fcat, wt_sort, wt_filt. + + lv_intercept_data_active = is_intercept_data_active( ). + +* First update metadata if we can. + IF io_salv->is_offline( ) = abap_false. + IF lv_intercept_data_active = abap_true. + ls_layout_key = lo_layout->get_key( ). + ls_vari-report = ls_layout_key-report. + ls_vari-handle = ls_layout_key-handle. + ls_vari-log_group = ls_layout_key-logical_group. + ls_vari-variant = lo_layout->get_initial_layout( ). + ELSE. + IF ycl_ecb_converter_salv_model=>is_get_metadata_callable( io_salv ) = abap_true. + io_salv->get_metadata( ) . + ELSE. + " (do same as offline below) + cl_salv_controller_metadata=>get_variant( + EXPORTING + r_layout = lo_layout + CHANGING + s_variant = ls_vari ). + ENDIF. + ENDIF. + ELSE. +* If we are offline we need to build this. + cl_salv_controller_metadata=>get_variant( + EXPORTING + r_layout = lo_layout + CHANGING + s_variant = ls_vari ). + ENDIF. + +*... get the column information + wt_fcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog( + r_columns = lo_columns + r_aggregations = lo_aggregations ). + +*... get the layout information + cl_salv_controller_metadata=>get_lvc_layout( + EXPORTING + r_functional_settings = lo_functional + r_display_settings = lo_display + r_columns = lo_columns + r_aggregations = lo_aggregations + CHANGING + s_layout = ws_layo ). + +* the fieldcatalog is not complete yet! + CALL FUNCTION 'LVC_FIELDCAT_COMPLETE' + EXPORTING + i_complete = 'X' + i_refresh_buffer = space + i_buffer_active = space + is_layout = ws_layo + i_test = '1' + i_fcat_complete = 'X' + IMPORTING + es_layout = ws_layo + CHANGING + ct_fieldcat = wt_fcat. + + IF ls_vari IS NOT INITIAL AND + ( io_salv->is_offline( ) = abap_true + OR lv_intercept_data_active = abap_true ). + CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO' + EXPORTING + it_fieldcat_lvc = wt_fcat + is_layout_lvc = ws_layo + IMPORTING + et_fieldcat_kkblo = lt_kkblo_fieldcat + es_layout_kkblo = ls_kkblo_layout + TABLES + it_data = it_table + EXCEPTIONS + it_data_missing = 1 + it_fieldcat_lvc_missing = 2 + OTHERS = 3. + IF sy-subrc <> 0. + ENDIF. + + CALL FUNCTION 'LT_VARIANT_LOAD' + EXPORTING + i_tabname = '1' + i_dialog = ' ' + i_user_specific = 'X' + i_fcat_complete = 'X' + IMPORTING + et_fieldcat = lt_kkblo_fieldcat + et_sort = lt_kkblo_sort + et_filter = lt_kkblo_filter + CHANGING + cs_layout = ls_kkblo_layout + ct_default_fieldcat = lt_kkblo_fieldcat + cs_variant = ls_vari + EXCEPTIONS + wrong_input = 1 + fc_not_complete = 2 + not_found = 3 + OTHERS = 4. + IF sy-subrc <> 0. + ENDIF. + + CALL FUNCTION 'LVC_TRANSFER_FROM_KKBLO' + EXPORTING + it_fieldcat_kkblo = lt_kkblo_fieldcat + it_sort_kkblo = lt_kkblo_sort + it_filter_kkblo = lt_kkblo_filter + is_layout_kkblo = ls_kkblo_layout + IMPORTING + et_fieldcat_lvc = wt_fcat + et_sort_lvc = wt_sort + et_filter_lvc = wt_filt + es_layout_lvc = ws_layo + TABLES + it_data = it_table + EXCEPTIONS + it_data_missing = 1 + OTHERS = 2. + IF sy-subrc <> 0. + ENDIF. + + ELSE. +* ... get the sort information + wt_sort = cl_salv_controller_metadata=>get_lvc_sort( lo_sorts ). + +* ... get the filter information + wt_filt = cl_salv_controller_metadata=>get_lvc_filter( lo_filters ). + ENDIF. + + ENDMETHOD. + + + METHOD yif_ecb_converter~get_supported_class. + rv_supported_class = 'CL_SALV_TABLE'. + ENDMETHOD. + + METHOD yif_ecb_converter~can_convert_object. + + DATA: lo_salv TYPE REF TO cl_salv_table. + + TRY. + lo_salv ?= io_object. + CATCH cx_sy_move_cast_error . + RAISE EXCEPTION TYPE ycx_ecb. + ENDTRY. + + ENDMETHOD. + + + METHOD yif_ecb_converter~create_fieldcatalog. + DATA: lo_salv TYPE REF TO cl_salv_table. + + yif_ecb_converter~can_convert_object( io_object = io_object ). + + ws_option = is_option. + + lo_salv ?= io_object. + + CLEAR: es_layout, + et_fieldcatalog, + et_colors . + + IF lo_salv IS BOUND. + load_data( EXPORTING io_salv = lo_salv + it_table = it_table ). + apply_sort( EXPORTING it_table = it_table + IMPORTING eo_table = eo_table ) . + + get_color( EXPORTING io_table = eo_table + IMPORTING et_colors = et_colors ) . + + get_filter( IMPORTING et_filter = et_filter + CHANGING xo_table = eo_table ) . + + update_catalog( CHANGING cs_layout = es_layout + ct_fieldcatalog = et_fieldcatalog ). + ENDIF. + ENDMETHOD. + + METHOD is_intercept_data_active. + + DATA: lr_s_type_runtime_info TYPE REF TO data. + FIELD-SYMBOLS: TYPE any, + TYPE any, + TYPE any. + + rv_result = abap_false. + TRY. + CREATE DATA lr_s_type_runtime_info TYPE ('CL_SALV_BS_RUNTIME_INFO=>S_TYPE_RUNTIME_INFO'). + ASSIGN lr_s_type_runtime_info->* TO . + CALL METHOD ('CL_SALV_BS_RUNTIME_INFO')=>('GET') + RECEIVING + value = . + ASSIGN ('-DISPLAY') TO . + CHECK sy-subrc = 0. + ASSIGN ('-DATA') TO . + CHECK sy-subrc = 0. + IF = abap_false AND = abap_true. + rv_result = abap_true. + ENDIF. + CATCH cx_sy_create_data_error cx_sy_dyn_call_error cx_salv_bs_sc_runtime_info. + rv_result = abap_false. + ENDTRY. + + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_converter_salv_table.clas.xml b/src/abap2xlsx/ycl_ecb_converter_salv_table.clas.xml new file mode 100644 index 0000000..afd05b2 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_converter_salv_table.clas.xml @@ -0,0 +1,28 @@ + + + + + + YCL_ECB_CONVERTER_SALV_TABLE + E + SALV converter + 1 + X + X + X + + + + LOAD_DATA + E + Fill internal layout tables + + + LOAD_DATA + I + Fill internal layout tables + + + + + diff --git a/src/abap2xlsx/ycl_ecb_data_validation.clas.abap b/src/abap2xlsx/ycl_ecb_data_validation.clas.abap new file mode 100644 index 0000000..892536b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_data_validation.clas.abap @@ -0,0 +1,82 @@ +CLASS ycl_ecb_data_validation DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! + + DATA errorstyle TYPE yecb_data_val_error_style . + DATA operator TYPE yecb_data_val_operator . + DATA allowblank TYPE flag VALUE 'X'. "#EC NOTEXT . . . . . . . . . . " . + DATA cell_column TYPE yecb_cell_column_alpha . + DATA cell_column_to TYPE yecb_cell_column_alpha . + DATA cell_row TYPE yecb_cell_row . + DATA cell_row_to TYPE yecb_cell_row . + CONSTANTS c_type_custom TYPE yecb_data_val_type VALUE 'custom'. "#EC NOTEXT + CONSTANTS c_type_list TYPE yecb_data_val_type VALUE 'list'. "#EC NOTEXT + DATA showerrormessage TYPE abap_bool VALUE 'X'. "#EC NOTEXT . . . . . . . . . . " . + DATA showinputmessage TYPE abap_bool VALUE 'X'. "#EC NOTEXT . . . . . . . . . . " . + DATA type TYPE yecb_data_val_type . + DATA formula1 TYPE yecb_validation_formula1 . + DATA formula2 TYPE yecb_validation_formula1 . + CONSTANTS c_type_none TYPE yecb_data_val_type VALUE 'none'. "#EC NOTEXT + CONSTANTS c_type_date TYPE yecb_data_val_type VALUE 'date'. "#EC NOTEXT + CONSTANTS c_type_decimal TYPE yecb_data_val_type VALUE 'decimal'. "#EC NOTEXT + CONSTANTS c_type_textlength TYPE yecb_data_val_type VALUE 'textLength'. "#EC NOTEXT + CONSTANTS c_type_time TYPE yecb_data_val_type VALUE 'time'. "#EC NOTEXT + CONSTANTS c_type_whole TYPE yecb_data_val_type VALUE 'whole'. "#EC NOTEXT + CONSTANTS c_style_stop TYPE yecb_data_val_error_style VALUE 'stop'. "#EC NOTEXT + CONSTANTS c_style_warning TYPE yecb_data_val_error_style VALUE 'warning'. "#EC NOTEXT + CONSTANTS c_style_information TYPE yecb_data_val_error_style VALUE 'information'. "#EC NOTEXT + CONSTANTS c_operator_between TYPE yecb_data_val_operator VALUE 'between'. "#EC NOTEXT + CONSTANTS c_operator_equal TYPE yecb_data_val_operator VALUE 'equal'. "#EC NOTEXT + CONSTANTS c_operator_greaterthan TYPE yecb_data_val_operator VALUE 'greaterThan'. "#EC NOTEXT + CONSTANTS c_operator_greaterthanorequal TYPE yecb_data_val_operator VALUE 'greaterThanOrEqual'. "#EC NOTEXT + CONSTANTS c_operator_lessthan TYPE yecb_data_val_operator VALUE 'lessThan'. "#EC NOTEXT + CONSTANTS c_operator_lessthanorequal TYPE yecb_data_val_operator VALUE 'lessThanOrEqual'. "#EC NOTEXT + CONSTANTS c_operator_notbetween TYPE yecb_data_val_operator VALUE 'notBetween'. "#EC NOTEXT + CONSTANTS c_operator_notequal TYPE yecb_data_val_operator VALUE 'notEqual'. "#EC NOTEXT + DATA showdropdown TYPE abap_bool . + DATA errortitle TYPE string . + DATA error TYPE string . + DATA prompttitle TYPE string . + DATA prompt TYPE string . + + METHODS constructor . +*"* protected components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_data_validation IMPLEMENTATION. + + + METHOD constructor. + " Initialise instance variables + formula1 = ''. + formula2 = ''. + type = me->c_type_none. + errorstyle = me->c_style_stop. + operator = ''. + allowblank = abap_false. + showdropdown = abap_false. + showinputmessage = abap_true. + showerrormessage = abap_true. + errortitle = ''. + error = ''. + prompttitle = ''. + prompt = ''. +* inizialize dimension range + cell_row = 1. + cell_column = 'A'. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_data_validation.clas.xml b/src/abap2xlsx/ycl_ecb_data_validation.clas.xml new file mode 100644 index 0000000..6892a8c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_data_validation.clas.xml @@ -0,0 +1,348 @@ + + + + + + YCL_ECB_DATA_VALIDATION + E + Data validation + 1 + X + X + X + + + + ALLOWBLANK + E + General Flag + + + ALLOWBLANK + I + General Flag + + + CELL_COLUMN + E + Cell Column + + + CELL_COLUMN + I + Cell Column + + + CELL_COLUMN_TO + E + Cell Column + + + CELL_COLUMN_TO + I + Cell Column + + + CELL_ROW + E + Cell Row + + + CELL_ROW + I + Cell Row + + + CELL_ROW_TO + E + Cell Row + + + CELL_ROW_TO + I + Cell Row + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_OPERATOR_BETWEEN + E + Data validation operator + + + C_OPERATOR_BETWEEN + I + Data validation operator + + + C_OPERATOR_EQUAL + E + Data validation operator + + + C_OPERATOR_EQUAL + I + Data validation operator + + + C_OPERATOR_GREATERTHAN + E + Data validation operator + + + C_OPERATOR_GREATERTHAN + I + Data validation operator + + + C_OPERATOR_GREATERTHANOREQUAL + E + Data validation operator + + + C_OPERATOR_GREATERTHANOREQUAL + I + Data validation operator + + + C_OPERATOR_LESSTHAN + E + Data validation operator + + + C_OPERATOR_LESSTHAN + I + Data validation operator + + + C_OPERATOR_LESSTHANOREQUAL + E + Data validation operator + + + C_OPERATOR_LESSTHANOREQUAL + I + Data validation operator + + + C_OPERATOR_NOTBETWEEN + E + Data validation operator + + + C_OPERATOR_NOTBETWEEN + I + Data validation operator + + + C_OPERATOR_NOTEQUAL + E + Data validation operator + + + C_OPERATOR_NOTEQUAL + I + Data validation operator + + + C_STYLE_INFORMATION + E + Data validation error style + + + C_STYLE_INFORMATION + I + Data validation error style + + + C_STYLE_STOP + E + Data validation error style + + + C_STYLE_STOP + I + Data validation error style + + + C_STYLE_WARNING + E + Data validation error style + + + C_STYLE_WARNING + I + Data validation error style + + + C_TYPE_CUSTOM + E + Data validation type + + + C_TYPE_CUSTOM + I + Data validation type + + + C_TYPE_DATE + E + Data validation type + + + C_TYPE_DATE + I + Data validation type + + + C_TYPE_DECIMAL + E + Data validation type + + + C_TYPE_DECIMAL + I + Data validation type + + + C_TYPE_LIST + E + Data validation type + + + C_TYPE_LIST + I + Data validation type + + + C_TYPE_NONE + E + Data validation type + + + C_TYPE_NONE + I + Data validation type + + + C_TYPE_TEXTLENGTH + E + Data validation type + + + C_TYPE_TEXTLENGTH + I + Data validation type + + + C_TYPE_TIME + E + Data validation type + + + C_TYPE_TIME + I + Data validation type + + + C_TYPE_WHOLE + E + Data validation type + + + C_TYPE_WHOLE + I + Data validation type + + + ERRORSTYLE + E + Data validation error style + + + ERRORSTYLE + I + Data validation error style + + + FORMULA1 + E + Validation formula1 + + + FORMULA1 + I + Validation formula1 + + + FORMULA2 + E + Validation formula2 + + + FORMULA2 + I + Validation formula2 + + + OPERATOR + E + Data validation operator + + + OPERATOR + I + Data validation operator + + + SHOWDROPDOWN + E + Show DropDown + + + SHOWDROPDOWN + I + Show DropDown + + + SHOWERRORMESSAGE + E + General Flag + + + SHOWERRORMESSAGE + I + General Flag + + + SHOWINPUTMESSAGE + E + General Flag + + + SHOWINPUTMESSAGE + I + General Flag + + + TYPE + E + Data validation type + + + TYPE + I + Data validation type + + + + + diff --git a/src/abap2xlsx/ycl_ecb_data_validations.clas.abap b/src/abap2xlsx/ycl_ecb_data_validations.clas.abap new file mode 100644 index 0000000..1dd94b7 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_data_validations.clas.abap @@ -0,0 +1,77 @@ +CLASS ycl_ecb_data_validations DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS add + IMPORTING + !ip_data_validation TYPE REF TO ycl_ecb_data_validation . + METHODS clear . + METHODS constructor . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !ip_data_validation TYPE REF TO ycl_ecb_data_validation . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . +*"* protected components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_DATA_VALIDATIONS +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA data_validations TYPE REF TO ycl_ecb_collection . +ENDCLASS. + + + +CLASS ycl_ecb_data_validations IMPLEMENTATION. + + + METHOD add. + data_validations->add( ip_data_validation ). + ENDMETHOD. + + + METHOD clear. + data_validations->clear( ). + ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT data_validations. + + ENDMETHOD. + + + METHOD get_iterator. + eo_iterator ?= data_validations->get_iterator( ). + ENDMETHOD. + + + METHOD is_empty. + is_empty = data_validations->is_empty( ). + ENDMETHOD. + + + METHOD remove. + data_validations->remove( ip_data_validation ). + ENDMETHOD. + + + METHOD size. + ep_size = data_validations->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_data_validations.clas.xml b/src/abap2xlsx/ycl_ecb_data_validations.clas.xml new file mode 100644 index 0000000..7858e88 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_data_validations.clas.xml @@ -0,0 +1,88 @@ + + + + + + YCL_ECB_DATA_VALIDATIONS + E + Data validations collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + ADD + I + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CLEAR + I + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + GET_ITERATOR + E + Returns an iterator + + + GET_ITERATOR + I + Returns an iterator + + + IS_EMPTY + E + Checks whether elements are contained + + + IS_EMPTY + I + Checks whether elements are contained + + + REMOVE + E + Deletes an Element from the Collection + + + REMOVE + I + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + SIZE + I + Specifies number of contained elements + + + + + diff --git a/src/abap2xlsx/ycl_ecb_drawing.clas.abap b/src/abap2xlsx/ycl_ecb_drawing.clas.abap new file mode 100644 index 0000000..482549b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_drawing.clas.abap @@ -0,0 +1,1136 @@ +CLASS ycl_ecb_drawing DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + CONSTANTS c_graph_pie TYPE yecb_graph_type VALUE 1. "#EC NOTEXT + CONSTANTS c_graph_line TYPE yecb_graph_type VALUE 2. "#EC NOTEXT + CONSTANTS c_graph_bars TYPE yecb_graph_type VALUE 0. "#EC NOTEXT + DATA graph_type TYPE yecb_graph_type . + DATA title TYPE string VALUE 'image1.jpg'. "#EC NOTEXT + CONSTANTS type_image TYPE yecb_drawing_type VALUE 'image'. "#EC NOTEXT + CONSTANTS type_chart TYPE yecb_drawing_type VALUE 'chart'. "#EC NOTEXT + CONSTANTS anchor_absolute TYPE yecb_drawing_anchor VALUE 'ABS'. "#EC NOTEXT + CONSTANTS anchor_one_cell TYPE yecb_drawing_anchor VALUE 'ONE'. "#EC NOTEXT + CONSTANTS anchor_two_cell TYPE yecb_drawing_anchor VALUE 'TWO'. "#EC NOTEXT + DATA graph TYPE REF TO ycl_ecb_graph . + CONSTANTS c_media_type_bmp TYPE string VALUE 'bmp'. "#EC NOTEXT + CONSTANTS c_media_type_xml TYPE string VALUE 'xml'. "#EC NOTEXT + CONSTANTS c_media_type_jpg TYPE string VALUE 'jpg'. "#EC NOTEXT + CONSTANTS type_image_header_footer TYPE yecb_drawing_type VALUE 'hd_ft'. "#EC NOTEXT + CONSTANTS: BEGIN OF namespace, + c TYPE string VALUE 'http://schemas.openxmlformats.org/drawingml/2006/chart', + a TYPE string VALUE 'http://schemas.openxmlformats.org/drawingml/2006/main', + r TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + mc TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006', + c14 TYPE string VALUE 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart', + END OF namespace. + + METHODS constructor + IMPORTING + !ip_type TYPE yecb_drawing_type DEFAULT ycl_ecb_drawing=>type_image + !ip_title TYPE clike OPTIONAL . + METHODS create_media_name + IMPORTING + !ip_index TYPE i . + METHODS get_from_col + RETURNING + VALUE(r_from_col) TYPE yecb_cell_column . + METHODS get_from_row + RETURNING + VALUE(r_from_row) TYPE yecb_cell_row . + METHODS get_guid + RETURNING + VALUE(ep_guid) TYPE yecb_guid . + METHODS get_height_emu_str + RETURNING + VALUE(r_height) TYPE string . + METHODS get_media + RETURNING + VALUE(r_media) TYPE xstring . + METHODS get_media_name + RETURNING + VALUE(r_name) TYPE string . + METHODS get_media_type + RETURNING + VALUE(r_type) TYPE string . + METHODS get_name + RETURNING + VALUE(r_name) TYPE string . + METHODS get_to_col + RETURNING + VALUE(r_to_col) TYPE yecb_cell_column . + METHODS get_to_row + RETURNING + VALUE(r_to_row) TYPE yecb_cell_row . + METHODS get_width_emu_str + RETURNING + VALUE(r_width) TYPE string . + CLASS-METHODS pixel2emu + IMPORTING + !ip_pixel TYPE int4 + !ip_dpi TYPE int2 OPTIONAL + RETURNING + VALUE(r_emu) TYPE string . + CLASS-METHODS emu2pixel + IMPORTING + !ip_emu TYPE int4 + !ip_dpi TYPE int2 OPTIONAL + RETURNING + VALUE(r_pixel) TYPE int4 . + METHODS set_media + IMPORTING + !ip_media TYPE xstring OPTIONAL + !ip_media_type TYPE string + !ip_width TYPE int4 DEFAULT 0 + !ip_height TYPE int4 DEFAULT 0 . + METHODS set_media_mime + IMPORTING + !ip_io TYPE skwf_io + !ip_width TYPE int4 + !ip_height TYPE int4 . + METHODS set_media_www + IMPORTING + !ip_key TYPE wwwdatatab + !ip_width TYPE int4 + !ip_height TYPE int4 . + METHODS set_position + IMPORTING + !ip_from_row TYPE yecb_cell_row + !ip_from_col TYPE yecb_cell_column_alpha + !ip_rowoff TYPE int4 OPTIONAL + !ip_coloff TYPE int4 OPTIONAL + RAISING + ycx_ecb . + METHODS set_position2 + IMPORTING + !ip_from TYPE yecb_drawing_location + !ip_to TYPE yecb_drawing_location + !ip_anchor TYPE yecb_drawing_anchor OPTIONAL . + METHODS get_position + RETURNING + VALUE(rp_position) TYPE yecb_drawing_position . + METHODS get_type + RETURNING + VALUE(rp_type) TYPE yecb_drawing_type . + METHODS get_index + RETURNING + VALUE(rp_index) TYPE string . + METHODS load_chart_attributes + IMPORTING + VALUE(ip_chart) TYPE REF TO if_ixml_document . + PROTECTED SECTION. + PRIVATE SECTION. + +*"* private components of class ZCL_EXCEL_DRAWING +*"* do not include other source files here!!! + DATA type TYPE yecb_drawing_type VALUE type_image. "#EC NOTEXT . . . . . . . . . . . " . + DATA index TYPE string . + DATA anchor TYPE yecb_drawing_anchor VALUE anchor_one_cell. "#EC NOTEXT . . . . . . . . . . . " . + CONSTANTS c_media_source_www TYPE c VALUE 1. "#EC NOTEXT + CONSTANTS c_media_source_xstring TYPE c VALUE 0. "#EC NOTEXT + CONSTANTS c_media_source_mime TYPE c VALUE 2. "#EC NOTEXT + DATA guid TYPE yecb_guid . + DATA media TYPE xstring . + DATA media_key_www TYPE wwwdatatab . + DATA media_name TYPE string . + DATA media_source TYPE c . + DATA media_type TYPE string . + DATA io TYPE skwf_io . + DATA from_loc TYPE yecb_drawing_location . + DATA to_loc TYPE yecb_drawing_location . + DATA size TYPE yecb_drawing_size . + CONSTANTS c_ixml_iid_element TYPE i VALUE 130. + +ENDCLASS. + + + +CLASS ycl_ecb_drawing IMPLEMENTATION. + + + METHOD constructor. + + me->guid = ycl_ecb_obsolete_func_wrap=>guid_create( ). " ins issue #379 - replacement for outdated function call + + IF ip_title IS NOT INITIAL. + title = ip_title. + ELSE. + title = me->guid. + ENDIF. + + me->type = ip_type. + +* inizialize dimension range + anchor = anchor_one_cell. + from_loc-col = 1. + from_loc-row = 1. + ENDMETHOD. + + + METHOD create_media_name. + +* if media name is initial, create unique name + CHECK media_name IS INITIAL. + + index = ip_index. + CONCATENATE me->type index INTO media_name. + CONDENSE media_name NO-GAPS. + ENDMETHOD. + + + METHOD emu2pixel. +* suppose 96 DPI + IF ip_dpi IS SUPPLIED. + r_pixel = ip_emu * ip_dpi / 914400. + ELSE. +* suppose 96 DPI + r_pixel = ip_emu * 96 / 914400. + ENDIF. + ENDMETHOD. + + + METHOD get_from_col. + r_from_col = me->from_loc-col. + ENDMETHOD. + + + METHOD get_from_row. + r_from_row = me->from_loc-row. + ENDMETHOD. + + + METHOD get_guid. + + ep_guid = me->guid. + + ENDMETHOD. + + + METHOD get_height_emu_str. + r_height = pixel2emu( size-height ). + CONDENSE r_height NO-GAPS. + ENDMETHOD. + + + METHOD get_index. + rp_index = me->index. + ENDMETHOD. + + + METHOD get_media. + + DATA: lv_language LIKE sy-langu. + DATA: lt_bin_mime TYPE sdokcntbins. + DATA: lt_mime TYPE tsfmime, + lv_filesize TYPE i, + lv_filesizec(10). + + CASE media_source. + WHEN c_media_source_xstring. + r_media = media. + WHEN c_media_source_www. + CALL FUNCTION 'WWWDATA_IMPORT' + EXPORTING + key = media_key_www + TABLES + mime = lt_mime + EXCEPTIONS + OTHERS = 1. + + CALL FUNCTION 'WWWPARAMS_READ' + EXPORTING + relid = media_key_www-relid + objid = media_key_www-objid + name = 'filesize' + IMPORTING + value = lv_filesizec. + + lv_filesize = lv_filesizec. + CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' + EXPORTING + input_length = lv_filesize + IMPORTING + buffer = r_media + TABLES + binary_tab = lt_mime + EXCEPTIONS + failed = 1 + OTHERS = 2. + WHEN c_media_source_mime. + lv_language = sy-langu. + cl_wb_mime_repository=>load_mime( EXPORTING + io = me->io + IMPORTING + filesize = lv_filesize + bin_data = lt_bin_mime + CHANGING + language = lv_language ). + + CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' + EXPORTING + input_length = lv_filesize + IMPORTING + buffer = r_media + TABLES + binary_tab = lt_bin_mime + EXCEPTIONS + failed = 1 + OTHERS = 2. + ENDCASE. + ENDMETHOD. + + + METHOD get_media_name. + CONCATENATE media_name `.` media_type INTO r_name. + ENDMETHOD. + + + METHOD get_media_type. + r_type = media_type. + ENDMETHOD. + + + METHOD get_name. + r_name = title. + ENDMETHOD. + + + METHOD get_position. + rp_position-anchor = anchor. + rp_position-from = from_loc. + rp_position-to = to_loc. + rp_position-size = size. + ENDMETHOD. + + + METHOD get_to_col. + r_to_col = me->to_loc-col. + ENDMETHOD. + + + METHOD get_to_row. + r_to_row = me->to_loc-row. + ENDMETHOD. + + + METHOD get_type. + rp_type = me->type. + ENDMETHOD. + + + METHOD get_width_emu_str. + r_width = pixel2emu( size-width ). + CONDENSE r_width NO-GAPS. + ENDMETHOD. + + + METHOD load_chart_attributes. + DATA: node TYPE REF TO if_ixml_element. + DATA: node2 TYPE REF TO if_ixml_element. + DATA: node3 TYPE REF TO if_ixml_element. + DATA: node4 TYPE REF TO if_ixml_element. + + DATA lo_barchart TYPE REF TO ycl_ecb_graph_bars. + DATA lo_piechart TYPE REF TO ycl_ecb_graph_pie. + DATA lo_linechart TYPE REF TO ycl_ecb_graph_line. + + TYPES: BEGIN OF t_prop, + val TYPE string, + rtl TYPE string, + lang TYPE string, + formatcode TYPE string, + sourcelinked TYPE string, + END OF t_prop. + + TYPES: BEGIN OF t_pagemargins, + b TYPE string, + l TYPE string, + r TYPE string, + t TYPE string, + header TYPE string, + footer TYPE string, + END OF t_pagemargins. + + DATA ls_prop TYPE t_prop. + DATA ls_pagemargins TYPE t_pagemargins. + + DATA lo_collection TYPE REF TO if_ixml_node_collection. + DATA lo_node TYPE REF TO if_ixml_node. + DATA lo_iterator TYPE REF TO if_ixml_node_iterator. + DATA lv_idx TYPE i. + DATA lv_order TYPE i. + DATA lv_invertifnegative TYPE string. + DATA lv_symbol TYPE string. + DATA lv_smooth TYPE c. + DATA lv_sername TYPE string. + DATA lv_label TYPE string. + DATA lv_value TYPE string. + DATA lv_axid TYPE string. + DATA lv_orientation TYPE string. + DATA lv_delete TYPE string. + DATA lv_axpos TYPE string. + DATA lv_formatcode TYPE string. + DATA lv_sourcelinked TYPE string. + DATA lv_majortickmark TYPE string. + DATA lv_minortickmark TYPE string. + DATA lv_ticklblpos TYPE string. + DATA lv_crossax TYPE string. + DATA lv_crosses TYPE string. + DATA lv_auto TYPE string. + DATA lv_lblalgn TYPE string. + DATA lv_lbloffset TYPE string. + DATA lv_nomultilvllbl TYPE string. + DATA lv_crossbetween TYPE string. + + node ?= ip_chart->if_ixml_node~get_first_child( ). + CHECK node IS NOT INITIAL. + + CASE me->graph_type. + WHEN c_graph_bars. + CREATE OBJECT lo_barchart. + me->graph = lo_barchart. + WHEN c_graph_pie. + CREATE OBJECT lo_piechart. + me->graph = lo_piechart. + WHEN c_graph_line. + CREATE OBJECT lo_linechart. + me->graph = lo_linechart. + WHEN OTHERS. + ENDCASE. + + "Fill properties + node2 ?= node->find_from_name_ns( name = 'date1904' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_1904val = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'lang' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_langval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'roundedCorners' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_roundedcornersval = ls_prop-val. + + "style + node2 ?= node->find_from_name_ns( name = 'style' uri = namespace-c14 ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_c14styleval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'style' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_styleval = ls_prop-val. + "---------------------------Read graph properties + "ADDED + CLEAR node2. + node2 ?= node->find_from_name_ns( name = 'title' uri = namespace-c ). + IF node2 IS BOUND AND node2 IS NOT INITIAL. + node3 ?= node2->find_from_name_ns( name = 't' uri = namespace-a ). + me->graph->title = node3->get_value( ). + ENDIF. + "END + + node2 ?= node->find_from_name_ns( name = 'autoTitleDeleted' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_autotitledeletedval = ls_prop-val. + + "plotArea + CASE me->graph_type. + WHEN c_graph_bars. + node2 ?= node->find_from_name_ns( name = 'barDir' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_bardirval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'grouping' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_groupingval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'varyColors' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_varycolorsval = ls_prop-val. + + "Load series + CALL METHOD node->get_elements_by_tag_name_ns + EXPORTING +* depth = 0 + name = 'ser' + uri = namespace-c + RECEIVING + rval = lo_collection. + CALL METHOD lo_collection->create_iterator + RECEIVING + rval = lo_iterator. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + WHILE lo_node IS BOUND. + node3 ?= node2->find_from_name_ns( name = 'idx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_idx = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'order' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_order = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'invertIfNegative' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_invertifnegative = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'v' uri = namespace-c ). + IF node3 IS BOUND. + lv_sername = node3->get_value( ). + ENDIF. + node3 ?= node2->find_from_name_ns( name = 'strRef' uri = namespace-c ). + IF node3 IS BOUND. + node4 ?= node3->find_from_name_ns( name = 'f' uri = namespace-c ). + lv_label = node4->get_value( ). + ENDIF. + node3 ?= node2->find_from_name_ns( name = 'numRef' uri = namespace-c ). + IF node3 IS BOUND. + node4 ?= node3->find_from_name_ns( name = 'f' uri = namespace-c ). + lv_value = node4->get_value( ). + ENDIF. + CALL METHOD lo_barchart->create_serie + EXPORTING + ip_idx = lv_idx + ip_order = lv_order + ip_invertifnegative = lv_invertifnegative + ip_lbl = lv_label + ip_ref = lv_value + ip_sername = lv_sername. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + ENDWHILE. + "note: numCache avoided + node2 ?= node->find_from_name_ns( name = 'showLegendKey' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_showlegendkeyval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showVal' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_showvalval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showCatName' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_showcatnameval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showSerName' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_showsernameval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showPercent' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_showpercentval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showBubbleSize' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_showbubblesizeval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'gapWidth' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_gapwidthval = ls_prop-val. + + "Load axes + node2 ?= node->find_from_name_ns( name = 'barChart' uri = namespace-c ). + CALL METHOD node2->get_elements_by_tag_name_ns + EXPORTING +* depth = 0 + name = 'axId' + uri = namespace-c + RECEIVING + rval = lo_collection. + CALL METHOD lo_collection->create_iterator + RECEIVING + rval = lo_iterator. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + WHILE lo_node IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lv_axid = ls_prop-val. + IF sy-index EQ 1. "catAx + node2 ?= node->find_from_name_ns( name = 'catAx' uri = namespace-c ). + node3 ?= node2->find_from_name_ns( name = 'orientation' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_orientation = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'delete' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_delete = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'axPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_axpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'numFmt' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_formatcode = ls_prop-formatcode. + lv_sourcelinked = ls_prop-sourcelinked. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_majortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_minortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'tickLblPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_ticklblpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crossAx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crossax = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crosses' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crosses = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'auto' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_auto = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'lblAlgn' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_lblalgn = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'lblOffset' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_lbloffset = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'noMultiLvlLbl' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_nomultilvllbl = ls_prop-val. + CALL METHOD lo_barchart->create_ax + EXPORTING + ip_axid = lv_axid + ip_type = ycl_ecb_graph_bars=>c_catax + ip_orientation = lv_orientation + ip_delete = lv_delete + ip_axpos = lv_axpos + ip_formatcode = lv_formatcode + ip_sourcelinked = lv_sourcelinked + ip_majortickmark = lv_majortickmark + ip_minortickmark = lv_minortickmark + ip_ticklblpos = lv_ticklblpos + ip_crossax = lv_crossax + ip_crosses = lv_crosses + ip_auto = lv_auto + ip_lblalgn = lv_lblalgn + ip_lbloffset = lv_lbloffset + ip_nomultilvllbl = lv_nomultilvllbl. + ELSEIF sy-index EQ 2. "valAx + node2 ?= node->find_from_name_ns( name = 'valAx' uri = namespace-c ). + node3 ?= node2->find_from_name_ns( name = 'orientation' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_orientation = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'delete' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_delete = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'axPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_axpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'numFmt' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_formatcode = ls_prop-formatcode. + lv_sourcelinked = ls_prop-sourcelinked. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_majortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_minortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'tickLblPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_ticklblpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crossAx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crossax = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crosses' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crosses = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crossBetween' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crossbetween = ls_prop-val. + CALL METHOD lo_barchart->create_ax + EXPORTING + ip_axid = lv_axid + ip_type = ycl_ecb_graph_bars=>c_valax + ip_orientation = lv_orientation + ip_delete = lv_delete + ip_axpos = lv_axpos + ip_formatcode = lv_formatcode + ip_sourcelinked = lv_sourcelinked + ip_majortickmark = lv_majortickmark + ip_minortickmark = lv_minortickmark + ip_ticklblpos = lv_ticklblpos + ip_crossax = lv_crossax + ip_crosses = lv_crosses + ip_crossbetween = lv_crossbetween. + ENDIF. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + ENDWHILE. + + WHEN c_graph_pie. + node2 ?= node->find_from_name_ns( name = 'varyColors' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_varycolorsval = ls_prop-val. + + "Load series + CALL METHOD node->get_elements_by_tag_name_ns + EXPORTING +* depth = 0 + name = 'ser' + uri = namespace-c + RECEIVING + rval = lo_collection. + CALL METHOD lo_collection->create_iterator + RECEIVING + rval = lo_iterator. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + WHILE lo_node IS BOUND. + node3 ?= node2->find_from_name_ns( name = 'idx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_idx = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'order' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_order = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'v' uri = namespace-c ). + IF node3 IS BOUND. + lv_sername = node3->get_value( ). + ENDIF. + node3 ?= node2->find_from_name_ns( name = 'strRef' uri = namespace-c ). + IF node3 IS BOUND. + node4 ?= node3->find_from_name_ns( name = 'f' uri = namespace-c ). + lv_label = node4->get_value( ). + ENDIF. + node3 ?= node2->find_from_name_ns( name = 'numRef' uri = namespace-c ). + IF node3 IS BOUND. + node4 ?= node3->find_from_name_ns( name = 'f' uri = namespace-c ). + lv_value = node4->get_value( ). + ENDIF. + CALL METHOD lo_piechart->create_serie + EXPORTING + ip_idx = lv_idx + ip_order = lv_order + ip_lbl = lv_label + ip_ref = lv_value + ip_sername = lv_sername. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + ENDWHILE. + + "note: numCache avoided + node2 ?= node->find_from_name_ns( name = 'showLegendKey' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showlegendkeyval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showVal' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showvalval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showCatName' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showcatnameval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showSerName' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showsernameval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showPercent' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showpercentval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showBubbleSize' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showbubblesizeval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showLeaderLines' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_showleaderlinesval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'firstSliceAng' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_firstsliceangval = ls_prop-val. + WHEN c_graph_line. + node2 ?= node->find_from_name_ns( name = 'grouping' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_groupingval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'varyColors' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_varycolorsval = ls_prop-val. + + "Load series + CALL METHOD node->get_elements_by_tag_name_ns + EXPORTING +* depth = 0 + name = 'ser' + uri = namespace-c + RECEIVING + rval = lo_collection. + CALL METHOD lo_collection->create_iterator + RECEIVING + rval = lo_iterator. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + WHILE lo_node IS BOUND. + node3 ?= node2->find_from_name_ns( name = 'idx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_idx = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'order' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_order = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'symbol' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_symbol = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'smooth' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_smooth = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'v' uri = namespace-c ). + IF node3 IS BOUND. + lv_sername = node3->get_value( ). + ENDIF. + node3 ?= node2->find_from_name_ns( name = 'strRef' uri = namespace-c ). + IF node3 IS BOUND. + node4 ?= node3->find_from_name_ns( name = 'f' uri = namespace-c ). + lv_label = node4->get_value( ). + ENDIF. + node3 ?= node2->find_from_name_ns( name = 'numRef' uri = namespace-c ). + IF node3 IS BOUND. + node4 ?= node3->find_from_name_ns( name = 'f' uri = namespace-c ). + lv_value = node4->get_value( ). + ENDIF. + CALL METHOD lo_linechart->create_serie + EXPORTING + ip_idx = lv_idx + ip_order = lv_order + ip_symbol = lv_symbol + ip_smooth = lv_smooth + ip_lbl = lv_label + ip_ref = lv_value + ip_sername = lv_sername. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + ENDWHILE. + "note: numCache avoided + node2 ?= node->find_from_name_ns( name = 'showLegendKey' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_showlegendkeyval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showVal' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_showvalval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showCatName' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_showcatnameval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showSerName' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_showsernameval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showPercent' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_showpercentval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showBubbleSize' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_showbubblesizeval = ls_prop-val. + + node ?= node->find_from_name_ns( name = 'lineChart' uri = namespace-c ). + node2 ?= node->find_from_name_ns( name = 'marker' uri = namespace-c depth = '1' ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_markerval = ls_prop-val. + ENDIF. + node2 ?= node->find_from_name_ns( name = 'smooth' uri = namespace-c depth = '1' ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_smoothval = ls_prop-val. + node ?= ip_chart->if_ixml_node~get_first_child( ). + CHECK node IS NOT INITIAL. + + "Load axes + node2 ?= node->find_from_name_ns( name = 'lineChart' uri = namespace-c ). + CALL METHOD node2->get_elements_by_tag_name_ns + EXPORTING +* depth = 0 + name = 'axId' + uri = namespace-c + RECEIVING + rval = lo_collection. + CALL METHOD lo_collection->create_iterator + RECEIVING + rval = lo_iterator. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + WHILE lo_node IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lv_axid = ls_prop-val. + IF sy-index EQ 1. "catAx + node2 ?= node->find_from_name_ns( name = 'catAx' uri = namespace-c ). + node3 ?= node2->find_from_name_ns( name = 'orientation' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_orientation = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'delete' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_delete = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'axPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_axpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_majortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_minortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'tickLblPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_ticklblpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crossAx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crossax = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crosses' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crosses = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'auto' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_auto = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'lblAlgn' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_lblalgn = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'lblOffset' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_lbloffset = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'noMultiLvlLbl' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_nomultilvllbl = ls_prop-val. + CALL METHOD lo_linechart->create_ax + EXPORTING + ip_axid = lv_axid + ip_type = ycl_ecb_graph_line=>c_catax + ip_orientation = lv_orientation + ip_delete = lv_delete + ip_axpos = lv_axpos + ip_formatcode = lv_formatcode + ip_sourcelinked = lv_sourcelinked + ip_majortickmark = lv_majortickmark + ip_minortickmark = lv_minortickmark + ip_ticklblpos = lv_ticklblpos + ip_crossax = lv_crossax + ip_crosses = lv_crosses + ip_auto = lv_auto + ip_lblalgn = lv_lblalgn + ip_lbloffset = lv_lbloffset + ip_nomultilvllbl = lv_nomultilvllbl. + ELSEIF sy-index EQ 2. "valAx + node2 ?= node->find_from_name_ns( name = 'valAx' uri = namespace-c ). + node3 ?= node2->find_from_name_ns( name = 'orientation' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_orientation = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'delete' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_delete = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'axPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_axpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'numFmt' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_formatcode = ls_prop-formatcode. + lv_sourcelinked = ls_prop-sourcelinked. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_majortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'majorTickMark' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_minortickmark = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'tickLblPos' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_ticklblpos = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crossAx' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crossax = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crosses' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crosses = ls_prop-val. + node3 ?= node2->find_from_name_ns( name = 'crossBetween' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = ls_prop ). + lv_crossbetween = ls_prop-val. + CALL METHOD lo_linechart->create_ax + EXPORTING + ip_axid = lv_axid + ip_type = ycl_ecb_graph_line=>c_valax + ip_orientation = lv_orientation + ip_delete = lv_delete + ip_axpos = lv_axpos + ip_formatcode = lv_formatcode + ip_sourcelinked = lv_sourcelinked + ip_majortickmark = lv_majortickmark + ip_minortickmark = lv_minortickmark + ip_ticklblpos = lv_ticklblpos + ip_crossax = lv_crossax + ip_crosses = lv_crosses + ip_crossbetween = lv_crossbetween. + ENDIF. + lo_node = lo_iterator->get_next( ). + IF lo_node IS BOUND. + node2 ?= lo_node->query_interface( c_ixml_iid_element ). + ENDIF. + ENDWHILE. + WHEN OTHERS. + ENDCASE. + + "legend + CASE me->graph_type. + WHEN c_graph_bars. + node2 ?= node->find_from_name_ns( name = 'legendPos' uri = namespace-c ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_legendposval = ls_prop-val. + ENDIF. + node2 ?= node->find_from_name_ns( name = 'overlay' uri = namespace-c ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_barchart->ns_overlayval = ls_prop-val. + ENDIF. + WHEN c_graph_line. + node2 ?= node->find_from_name_ns( name = 'legendPos' uri = namespace-c ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_legendposval = ls_prop-val. + ENDIF. + node2 ?= node->find_from_name_ns( name = 'overlay' uri = namespace-c ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_linechart->ns_overlayval = ls_prop-val. + ENDIF. + WHEN c_graph_pie. + node2 ?= node->find_from_name_ns( name = 'legendPos' uri = namespace-c ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_legendposval = ls_prop-val. + ENDIF. + node2 ?= node->find_from_name_ns( name = 'overlay' uri = namespace-c ). + IF node2 IS BOUND. + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_overlayval = ls_prop-val. + ENDIF. + node2 ?= node->find_from_name_ns( name = 'pPr' uri = namespace-a ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_pprrtl = ls_prop-rtl. + node2 ?= node->find_from_name_ns( name = 'endParaRPr' uri = namespace-a ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lo_piechart->ns_endpararprlang = ls_prop-lang. + + WHEN OTHERS. + ENDCASE. + + node2 ?= node->find_from_name_ns( name = 'plotVisOnly' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_plotvisonlyval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'dispBlanksAs' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_dispblanksasval = ls_prop-val. + node2 ?= node->find_from_name_ns( name = 'showDLblsOverMax' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + me->graph->ns_showdlblsovermaxval = ls_prop-val. + "--------------------- + + node2 ?= node->find_from_name_ns( name = 'pageMargins' uri = namespace-c ). + ycl_ecb_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_pagemargins ). + me->graph->pagemargins = ls_pagemargins. + + + ENDMETHOD. + + + METHOD pixel2emu. +* suppose 96 DPI + IF ip_dpi IS SUPPLIED. + r_emu = ip_pixel * 914400 / ip_dpi. + ELSE. +* suppose 96 DPI + r_emu = ip_pixel * 914400 / 96. + ENDIF. + ENDMETHOD. + + + METHOD set_media. + IF ip_media IS SUPPLIED. + media = ip_media. + ENDIF. + media_type = ip_media_type. + media_source = c_media_source_xstring. + IF ip_width IS SUPPLIED. + size-width = ip_width. + ENDIF. + IF ip_height IS SUPPLIED. + size-height = ip_height. + ENDIF. + ENDMETHOD. + + + METHOD set_media_mime. + + DATA: lv_language LIKE sy-langu. + + io = ip_io. + media_source = c_media_source_mime. + size-width = ip_width. + size-height = ip_height. + + lv_language = sy-langu. + cl_wb_mime_repository=>load_mime( EXPORTING + io = ip_io + IMPORTING + filename = media_name + "mimetype = media_type + CHANGING + language = lv_language ). + + SPLIT media_name AT '.' INTO media_name media_type. + + ENDMETHOD. + + + METHOD set_media_www. + DATA: lv_value(20). + + media_key_www = ip_key. + media_source = c_media_source_www. + + CALL FUNCTION 'WWWPARAMS_READ' + EXPORTING + relid = media_key_www-relid + objid = media_key_www-objid + name = 'fileextension' + IMPORTING + value = lv_value. + media_type = lv_value. + SHIFT media_type LEFT DELETING LEADING '.'. + + size-width = ip_width. + size-height = ip_height. + ENDMETHOD. + + + METHOD set_position. + from_loc-col = ycl_ecb_common=>convert_column2int( ip_from_col ) - 1. + IF ip_coloff IS SUPPLIED. + from_loc-col_offset = ip_coloff. + ENDIF. + from_loc-row = ip_from_row - 1. + IF ip_rowoff IS SUPPLIED. + from_loc-row_offset = ip_rowoff. + ENDIF. + anchor = anchor_one_cell. + ENDMETHOD. + + + METHOD set_position2. + + DATA: lv_anchor TYPE yecb_drawing_anchor. + lv_anchor = ip_anchor. + + IF lv_anchor IS INITIAL. + IF ip_to IS NOT INITIAL. + lv_anchor = anchor_two_cell. + ELSE. + lv_anchor = anchor_one_cell. + ENDIF. + ENDIF. + + CASE lv_anchor. + WHEN anchor_absolute OR anchor_one_cell. + CLEAR: me->to_loc. + WHEN anchor_two_cell. + CLEAR: me->size. + ENDCASE. + + me->from_loc = ip_from. + me->to_loc = ip_to. + me->anchor = lv_anchor. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_drawing.clas.xml b/src/abap2xlsx/ycl_ecb_drawing.clas.xml new file mode 100644 index 0000000..8e0ad94 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_drawing.clas.xml @@ -0,0 +1,488 @@ + + + + + + YCL_ECB_DRAWING + E + Drawing + 1 + X + X + X + + + + ANCHOR + E + Excel Drawing anchor + + + ANCHOR + I + Excel Drawing anchor + + + ANCHOR_ABSOLUTE + E + Excel Drawing anchor + + + ANCHOR_ABSOLUTE + I + Excel Drawing anchor + + + ANCHOR_ONE_CELL + E + Excel Drawing anchor + + + ANCHOR_ONE_CELL + I + Excel Drawing anchor + + + ANCHOR_TWO_CELL + E + Excel Drawing anchor + + + ANCHOR_TWO_CELL + I + Excel Drawing anchor + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + CREATE_MEDIA_NAME + E + Generate media name image#.ext + + + CREATE_MEDIA_NAME + I + Generate media name image#.ext + + + C_GRAPH_BARS + E + Graph type + + + C_GRAPH_BARS + I + Graph type + + + C_GRAPH_LINE + E + Graph type + + + C_GRAPH_LINE + I + Graph type + + + C_GRAPH_PIE + E + Graph type + + + C_GRAPH_PIE + I + Graph type + + + C_MEDIA_SOURCE_MIME + E + miem repository + + + C_MEDIA_SOURCE_MIME + I + miem repository + + + C_MEDIA_SOURCE_WWW + E + www repository SMW0 + + + C_MEDIA_SOURCE_WWW + I + www repository SMW0 + + + C_MEDIA_SOURCE_XSTRING + E + Binary data as XSTRING + + + C_MEDIA_SOURCE_XSTRING + I + Binary data as XSTRING + + + EMU2PIXEL + E + Convert EMU to pixel + + + FROM_LOC + E + Drawing location for Excel + + + FROM_LOC + I + Drawing location for Excel + + + GET_FROM_COL + E + From col + + + GET_FROM_COL + I + From col + + + GET_FROM_ROW + E + From row + + + GET_FROM_ROW + I + From row + + + GET_GUID + E + Get sheet guid + + + GET_GUID + I + Get sheet guid + + + GET_HEIGHT_EMU_STR + E + Height of bitmap in EMU as string + + + GET_HEIGHT_EMU_STR + I + Height of bitmap in EMU as string + + + GET_INDEX + E + Get index + + + GET_INDEX + I + Get index + + + GET_MEDIA + E + Returns media as XSTRING + + + GET_MEDIA + I + Returns media as XSTRING + + + GET_POSITION + E + Get position of drawing + + + GET_POSITION + I + Get position of drawing + + + GET_TO_COL + E + To col + + + GET_TO_COL + I + To col + + + GET_TO_ROW + E + To row + + + GET_TO_ROW + I + To row + + + GET_TYPE + E + Get drawing type + + + GET_TYPE + I + Get drawing type + + + GET_WIDTH_EMU_STR + E + Width of bitmap in EMU as string + + + GET_WIDTH_EMU_STR + I + Width of bitmap in EMU as string + + + GRAPH + E + Graphic + + + GRAPH + I + Graphic + + + GRAPH_TYPE + E + Graph type + + + GRAPH_TYPE + I + Graph type + + + GUID + E + GUID in 'RAW' format + + + GUID + I + GUID in 'RAW' format + + + INDEX + E + Index in collection + + + INDEX + I + Index in collection + + + IO + E + KW Framework: Object Key + + + IO + I + KW Framework: Object Key + + + LOAD_CHART_ATTRIBUTES + E + Load chart attributes + + + LOAD_CHART_ATTRIBUTES + I + Load chart attributes + + + MEDIA_KEY_WWW + E + Contents of table WWWDATA + + + MEDIA_KEY_WWW + I + Contents of table WWWDATA + + + MEDIA_NAME + E + Generated file name + + + MEDIA_NAME + I + Generated file name + + + MEDIA_SOURCE + E + 0=XSTRING, 1=WWW + + + MEDIA_SOURCE + I + 0=XSTRING, 1=WWW + + + MEDIA_TYPE + E + Type of media, file extension + + + MEDIA_TYPE + I + Type of media, file extension + + + PIXEL2EMU + E + Convert pixel to EMU + + + PIXEL2EMU + I + Convert pixel to EMU + + + SET_MEDIA + E + Add media to drawing as XSTRING + + + SET_MEDIA + I + Add media to drawing as XSTRING + + + SET_MEDIA_MIME + E + Add media from mime repository + + + SET_MEDIA_MIME + I + Add media from mime repository + + + SET_MEDIA_WWW + E + Add media from www repository SMW0 + + + SET_MEDIA_WWW + I + Add media from www repository SMW0 + + + SET_POSITION + E + Set position of drawing + + + SET_POSITION + I + Set position of drawing + + + SET_POSITION2 + E + Set position of drawing + + + SET_POSITION2 + I + Set position of drawing + + + SIZE + E + Drawing size for Excel + + + SIZE + I + Drawing size for Excel + + + TITLE + E + Title + + + TITLE + I + Title + + + TO_LOC + E + Drawing location for Excel + + + TO_LOC + I + Drawing location for Excel + + + TYPE + E + Drawing type: image|chart + + + TYPE + I + Drawing type: image|chart + + + TYPE_CHART + E + Excel Drawing type + + + TYPE_CHART + I + Excel Drawing type + + + TYPE_IMAGE + E + Excel Drawing type + + + TYPE_IMAGE + I + Excel Drawing type + + + TYPE_IMAGE_HEADER_FOOTER + E + Excel Drawing type + + + + + diff --git a/src/abap2xlsx/ycl_ecb_drawings.clas.abap b/src/abap2xlsx/ycl_ecb_drawings.clas.abap new file mode 100644 index 0000000..e48a737 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_drawings.clas.abap @@ -0,0 +1,123 @@ +CLASS ycl_ecb_drawings DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + +*"* public components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! + DATA type TYPE yecb_drawing_type READ-ONLY VALUE 'IMAGE'. "#EC NOTEXT . . . . . . . . . . " . + + METHODS add + IMPORTING + !ip_drawing TYPE REF TO ycl_ecb_drawing . + METHODS include + IMPORTING + !ip_drawing TYPE REF TO ycl_ecb_drawing . + METHODS clear . + METHODS constructor + IMPORTING + !ip_type TYPE yecb_drawing_type . + METHODS get + IMPORTING + !ip_index TYPE yecb_active_worksheet + RETURNING + VALUE(eo_drawing) TYPE REF TO ycl_ecb_drawing . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !ip_drawing TYPE REF TO ycl_ecb_drawing . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . + METHODS get_type + RETURNING + VALUE(rp_type) TYPE yecb_drawing_type . +*"* protected components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + +*"* private components of class ZCL_EXCEL_DRAWINGS +*"* do not include other source files here!!! + DATA drawings TYPE REF TO ycl_ecb_collection . +ENDCLASS. + + + +CLASS ycl_ecb_drawings IMPLEMENTATION. + + + METHOD add. + DATA: lv_index TYPE i. + + drawings->add( ip_drawing ). + lv_index = drawings->size( ). + ip_drawing->create_media_name( + ip_index = lv_index ). + ENDMETHOD. + + + METHOD clear. + + drawings->clear( ). + ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT drawings. + type = ip_type. + + ENDMETHOD. + + + METHOD get. + + DATA lv_index TYPE i. + lv_index = ip_index. + eo_drawing ?= drawings->get( lv_index ). + ENDMETHOD. + + + METHOD get_iterator. + + eo_iterator ?= drawings->get_iterator( ). + ENDMETHOD. + + + METHOD get_type. + rp_type = me->type. + ENDMETHOD. + + + METHOD include. + drawings->add( ip_drawing ). + ENDMETHOD. + + + METHOD is_empty. + + is_empty = drawings->is_empty( ). + ENDMETHOD. + + + METHOD remove. + + drawings->remove( ip_drawing ). + ENDMETHOD. + + + METHOD size. + + ep_size = drawings->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_drawings.clas.xml b/src/abap2xlsx/ycl_ecb_drawings.clas.xml new file mode 100644 index 0000000..8ad6275 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_drawings.clas.xml @@ -0,0 +1,128 @@ + + + + + + YCL_ECB_DRAWINGS + E + Drawings collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + ADD + I + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CLEAR + I + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + GET + E + Gets Element + + + GET + I + Gets Element + + + GET_ITERATOR + E + Returns an iterator + + + GET_ITERATOR + I + Returns an iterator + + + GET_TYPE + E + Get drawing type for collection + + + GET_TYPE + I + Get drawing type for collection + + + INCLUDE + E + Adds an Element to the Collection + + + INCLUDE + I + Adds an Element to the Collection + + + IS_EMPTY + E + Checks whether elements are contained + + + IS_EMPTY + I + Checks whether elements are contained + + + REMOVE + E + Deletes an Element from the Collection + + + REMOVE + I + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + SIZE + I + Specifies number of contained elements + + + TYPE + E + Excel Drawing type + + + TYPE + I + Excel Drawing type + + + + + diff --git a/src/abap2xlsx/ycl_ecb_fill_template.clas.abap b/src/abap2xlsx/ycl_ecb_fill_template.clas.abap new file mode 100644 index 0000000..7b7bac9 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_fill_template.clas.abap @@ -0,0 +1,649 @@ +CLASS ycl_ecb_fill_template DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: tv_range_name TYPE c LENGTH 30, + BEGIN OF ts_range, + sheet TYPE yecb_sheet_title, + name TYPE tv_range_name, + start TYPE yecb_cell_row, + stop TYPE yecb_cell_row, + id TYPE i, + parent TYPE i, + length TYPE i, + END OF ts_range, + tt_ranges TYPE STANDARD TABLE OF ts_range WITH DEFAULT KEY, + BEGIN OF ts_variable, + sheet TYPE yecb_sheet_title, + parent TYPE i, + name TYPE tv_range_name, + END OF ts_variable, + BEGIN OF ts_name_style, + sheet TYPE yecb_sheet_title, + name TYPE tv_range_name, + parent TYPE i, + numeric_counter TYPE i, + date_counter TYPE i, + time_counter TYPE i, + text_counter TYPE i, + END OF ts_name_style, + tt_variables TYPE STANDARD TABLE OF ts_variable WITH DEFAULT KEY, + tt_sheet_titles TYPE STANDARD TABLE OF yecb_sheet_title WITH DEFAULT KEY, + tt_name_styles TYPE STANDARD TABLE OF ts_name_style WITH DEFAULT KEY. + + DATA mt_sheet TYPE tt_sheet_titles READ-ONLY. + DATA mt_range TYPE tt_ranges READ-ONLY. + DATA mt_var TYPE tt_variables READ-ONLY. + DATA mo_excel TYPE REF TO ycl_ecb READ-ONLY. + DATA mt_name_styles TYPE tt_name_styles READ-ONLY. + + CLASS-METHODS create + IMPORTING + !io_excel TYPE REF TO ycl_ecb + RETURNING + VALUE(eo_template_filler) TYPE REF TO ycl_ecb_fill_template + RAISING + ycx_ecb. + + METHODS fill_sheet + IMPORTING + !iv_data TYPE ycl_ecb_template_data=>ts_template_data_sheet + RAISING + ycx_ecb . + + PROTECTED SECTION. + PRIVATE SECTION. + + TYPES: tt_cell_data_no_key TYPE STANDARD TABLE OF yecb_s_cell_data WITH DEFAULT KEY. + + METHODS fill_range + IMPORTING + !iv_sheet TYPE yecb_sheet_title + !iv_parent TYPE yecb_cell_row + !iv_data TYPE data + VALUE(iv_range_length) TYPE yecb_cell_row + !io_sheet TYPE REF TO ycl_ecb_worksheet + CHANGING + !ct_cells TYPE tt_cell_data_no_key + !cv_diff TYPE yecb_cell_row + !ct_merged_cells TYPE ycl_ecb_worksheet=>mty_ts_merge + RAISING + ycx_ecb . + METHODS get_range . + METHODS validate_range + IMPORTING + !io_range TYPE REF TO ycl_ecb_range . + METHODS discard_overlapped . + METHODS sign_range . + METHODS find_var + RAISING + ycx_ecb . + +ENDCLASS. + + + +CLASS ycl_ecb_fill_template IMPLEMENTATION. + + + METHOD create. + + CREATE OBJECT eo_template_filler . + + eo_template_filler->mo_excel = io_excel. + eo_template_filler->get_range( ). + eo_template_filler->discard_overlapped( ). + eo_template_filler->sign_range( ). + eo_template_filler->find_var( ). + + ENDMETHOD. + + + METHOD discard_overlapped. + DATA: + lt_range TYPE tt_ranges. + FIELD-SYMBOLS: + TYPE ts_range, + TYPE ts_range. + + SORT mt_range BY sheet start stop. + + LOOP AT mt_range ASSIGNING . + + LOOP AT mt_range ASSIGNING WHERE sheet = -sheet + AND name <> -name + AND stop >= -start + AND start < -start + AND stop < -stop. + EXIT. + ENDLOOP. + + IF sy-subrc NE 0. + APPEND TO lt_range. + ENDIF. + + ENDLOOP. + + mt_range = lt_range. + + SORT mt_range BY sheet start stop DESCENDING. + + ENDMETHOD. + + + METHOD fill_range. + + DATA: lt_tmp_cells_template TYPE tt_cell_data_no_key, + lt_cells_result TYPE tt_cell_data_no_key, + lt_tmp_cells TYPE tt_cell_data_no_key, + ls_cell TYPE yecb_s_cell_data, + lt_tmp_merged_cells_template TYPE ycl_ecb_worksheet=>mty_ts_merge, + lt_merged_cells_result TYPE ycl_ecb_worksheet=>mty_ts_merge, + lt_tmp_merged_cells TYPE ycl_ecb_worksheet=>mty_ts_merge, + ls_merged_cell LIKE LINE OF lt_tmp_merged_cells, + lv_start_row TYPE i, + lv_stop_row TYPE i, + lv_cell_row TYPE i, + lv_column_alpha TYPE string, + lt_matches TYPE match_result_tab, + lv_search TYPE string, + lv_var_name TYPE string, + lv_cell_value TYPE string. + + FIELD-SYMBOLS: + TYPE ANY TABLE, + TYPE any, + TYPE ts_range, + TYPE yecb_s_cell_data, + TYPE match_result, + TYPE any. + + + cv_diff = cv_diff + iv_range_length . + + lv_start_row = 1. + + +* recursive fill nested range + + LOOP AT mt_range ASSIGNING WHERE sheet = iv_sheet + AND parent = iv_parent. + + + lv_stop_row = -start - 1. + +* update cells before any range + + LOOP AT ct_cells INTO ls_cell WHERE cell_row >= lv_start_row AND cell_row <= lv_stop_row . + ls_cell-cell_row = ls_cell-cell_row + cv_diff. + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( ls_cell-cell_column ). + + ls_cell-cell_coords = ls_cell-cell_row. + CONCATENATE lv_column_alpha ls_cell-cell_coords INTO ls_cell-cell_coords. + CONDENSE ls_cell-cell_coords NO-GAPS. + + APPEND ls_cell TO lt_cells_result. + ENDLOOP. + + + +* update merged cells before range + + LOOP AT ct_merged_cells INTO ls_merged_cell WHERE row_from >= lv_start_row AND row_to <= lv_stop_row. + ls_merged_cell-row_from = ls_merged_cell-row_from + cv_diff. + ls_merged_cell-row_to = ls_merged_cell-row_to + cv_diff. + + APPEND ls_merged_cell TO lt_merged_cells_result. + + ENDLOOP. + + + + lv_start_row = -stop + 1. + + + + CLEAR: + lt_tmp_cells_template, + lt_tmp_merged_cells_template. + + +*copy cell template + LOOP AT ct_cells INTO ls_cell WHERE cell_row >= -start AND cell_row <= -stop. + APPEND ls_cell TO lt_tmp_cells_template. + ENDLOOP. + + LOOP AT ct_merged_cells INTO ls_merged_cell WHERE row_from >= -start AND row_to <= -stop. + APPEND ls_merged_cell TO lt_tmp_merged_cells_template. + ENDLOOP. + + + ASSIGN COMPONENT -name OF STRUCTURE iv_data TO
. + CHECK sy-subrc = 0. + + cv_diff = cv_diff - -length. + +*merge each line of data table with template + LOOP AT
ASSIGNING . +* make local copy + lt_tmp_cells = lt_tmp_cells_template. + lt_tmp_merged_cells = lt_tmp_merged_cells_template. + +*fill data + + fill_range( + EXPORTING + io_sheet = io_sheet + iv_sheet = iv_sheet + iv_parent = -id + iv_data = + iv_range_length = -length + CHANGING + ct_cells = lt_tmp_cells + ct_merged_cells = lt_tmp_merged_cells + cv_diff = cv_diff ). + +*collect data + + APPEND LINES OF lt_tmp_cells TO lt_cells_result. + APPEND LINES OF lt_tmp_merged_cells TO lt_merged_cells_result. + + ENDLOOP. + + ENDLOOP. + + + IF IS ASSIGNED. + + LOOP AT ct_cells INTO ls_cell WHERE cell_row > -stop . + ls_cell-cell_row = ls_cell-cell_row + cv_diff. + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( ls_cell-cell_column ). + + ls_cell-cell_coords = ls_cell-cell_row. + CONCATENATE lv_column_alpha ls_cell-cell_coords INTO ls_cell-cell_coords. + CONDENSE ls_cell-cell_coords NO-GAPS. + + APPEND ls_cell TO lt_cells_result. + ENDLOOP. + + ct_cells = lt_cells_result. + + LOOP AT ct_merged_cells INTO ls_merged_cell WHERE row_from > -stop. + ls_merged_cell-row_from = ls_merged_cell-row_from + cv_diff. + ls_merged_cell-row_to = ls_merged_cell-row_to + cv_diff. + + APPEND ls_merged_cell TO lt_merged_cells_result. + ENDLOOP. + + ct_merged_cells = lt_merged_cells_result. + + ELSE. + + + LOOP AT ct_cells ASSIGNING . + -cell_row = -cell_row + cv_diff. + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( -cell_column ). + + -cell_coords = -cell_row. + CONCATENATE lv_column_alpha -cell_coords INTO -cell_coords. + CONDENSE -cell_coords NO-GAPS. + ENDLOOP. + + LOOP AT ct_merged_cells INTO ls_merged_cell . + ls_merged_cell-row_from = ls_merged_cell-row_from + cv_diff. + ls_merged_cell-row_to = ls_merged_cell-row_to + cv_diff. + + APPEND ls_merged_cell TO lt_merged_cells_result. + ENDLOOP. + + ct_merged_cells = lt_merged_cells_result. + + ENDIF. + + +*check if variables in this range + READ TABLE mt_var TRANSPORTING NO FIELDS WITH KEY sheet = iv_sheet parent = iv_parent. + + IF sy-subrc = 0. + +* replace variables of current range with data + LOOP AT ct_cells ASSIGNING . + + CLEAR lt_matches. + + lv_cell_value = -cell_value. + + FIND ALL OCCURRENCES OF REGEX '\[[^\]]*\]' IN -cell_value RESULTS lt_matches. + + SORT lt_matches BY offset DESCENDING . + + LOOP AT lt_matches ASSIGNING . + lv_search = -cell_value+-offset(-length). + lv_var_name = lv_search. + + TRANSLATE lv_var_name TO UPPER CASE. + TRANSLATE lv_var_name USING '[ ] '. + CONDENSE lv_var_name . + + ASSIGN COMPONENT lv_var_name OF STRUCTURE iv_data TO . + CHECK sy-subrc = 0. + + " Use SET_CELL to format correctly + io_sheet->set_cell( ip_column = -cell_column ip_row = -cell_row - cv_diff ip_value = ). + lv_cell_row = -cell_row - cv_diff. + READ TABLE io_sheet->sheet_content INTO ls_cell + WITH KEY cell_column = -cell_column + cell_row = lv_cell_row. + REPLACE ALL OCCURRENCES OF lv_search IN -cell_value WITH ls_cell-cell_value. + ENDLOOP. + + IF lines( lt_matches ) = 1. + lv_cell_row = -cell_row - cv_diff. + READ TABLE io_sheet->sheet_content INTO ls_cell + WITH KEY cell_column = -cell_column + cell_row = lv_cell_row. + -data_type = ls_cell-data_type. + ENDIF. + + ENDLOOP. + ENDIF. + + ENDMETHOD. + + + METHOD fill_sheet. + + DATA: lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lt_sheet_cells TYPE tt_cell_data_no_key, + lt_merged_cells TYPE ycl_ecb_worksheet=>mty_ts_merge, + lt_merged_cells_2 TYPE ycl_ecb_worksheet=>mty_ts_merge, + lv_initial_diff TYPE i. + FIELD-SYMBOLS: + TYPE any, + TYPE yecb_s_cell_data, + TYPE ycl_ecb_worksheet=>mty_merge. + + + lo_worksheet = mo_excel->get_worksheet_by_name( iv_data-sheet ). + + lt_sheet_cells = lo_worksheet->sheet_content. + lt_merged_cells = lo_worksheet->mt_merged_cells. + + ASSIGN iv_data-data->* TO . + + fill_range( + EXPORTING + io_sheet = lo_worksheet + iv_range_length = 0 + iv_sheet = iv_data-sheet + iv_parent = 0 + iv_data = + CHANGING + ct_cells = lt_sheet_cells + ct_merged_cells = lt_merged_cells + cv_diff = lv_initial_diff ). + + + CLEAR lo_worksheet->sheet_content. + + LOOP AT lt_sheet_cells ASSIGNING . + INSERT INTO TABLE lo_worksheet->sheet_content. + ENDLOOP. + + lt_merged_cells_2 = lo_worksheet->mt_merged_cells. + LOOP AT lt_merged_cells_2 ASSIGNING . + lo_worksheet->delete_merge( ip_cell_column = -col_from ip_cell_row = -row_from ). + ENDLOOP. + + LOOP AT lt_merged_cells ASSIGNING . + lo_worksheet->set_merge( + ip_column_start = -col_from + ip_column_end = -col_to + ip_row = -row_from + ip_row_to = -row_to ). + ENDLOOP. + + ENDMETHOD. + + + METHOD find_var. + + DATA: lv_row TYPE i, + lv_column TYPE i, + lv_column_alpha TYPE string, + lv_value TYPE string, + ls_name_style TYPE ts_name_style, + lo_style TYPE REF TO ycl_ecb_style, + lo_worksheet TYPE REF TO ycl_ecb_worksheet, + ls_variable TYPE ts_variable, + lv_highest_column TYPE yecb_cell_column, + lv_highest_row TYPE int4, + lt_matches TYPE match_result_tab, + lv_search TYPE string, + lv_replace TYPE string. + + FIELD-SYMBOLS: + TYPE match_result, + TYPE ts_range, + TYPE yecb_sheet_title, + TYPE ts_name_style. + + + LOOP AT mt_sheet ASSIGNING . + + lo_worksheet ?= mo_excel->get_worksheet_by_name( ). + lv_row = 1. + + lv_highest_column = lo_worksheet->get_highest_column( ). + lv_highest_row = lo_worksheet->get_highest_row( ). + + WHILE lv_row <= lv_highest_row. + lv_column = 1. + WHILE lv_column <= lv_highest_column. + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( lv_column ). + CLEAR lo_style. + lo_worksheet->get_cell( + EXPORTING + ip_column = lv_column_alpha + ip_row = lv_row + IMPORTING + ep_value = lv_value + ep_style = lo_style ). + + FIND ALL OCCURRENCES OF REGEX '\[[^\]]*\]' IN lv_value RESULTS lt_matches. + + LOOP AT lt_matches ASSIGNING . + lv_search = lv_value+-offset(-length). + lv_replace = lv_search. + + TRANSLATE lv_replace TO UPPER CASE. + + CLEAR ls_variable. + + ls_variable-sheet = . + ls_variable-name = lv_replace. + TRANSLATE ls_variable-name USING '[ ] '. + CONDENSE ls_variable-name . + + LOOP AT mt_range ASSIGNING WHERE sheet = + AND start <= lv_row + AND stop >= lv_row. + ls_variable-parent = -id. + EXIT. + ENDLOOP. + + READ TABLE mt_var TRANSPORTING NO FIELDS WITH KEY sheet = ls_variable-sheet name = ls_variable-name parent = ls_variable-parent. + IF sy-subrc NE 0. + APPEND ls_variable TO mt_var. + ENDIF. + + READ TABLE mt_name_styles WITH KEY sheet = ls_variable-sheet name = ls_variable-name parent = ls_variable-parent ASSIGNING . + IF sy-subrc NE 0. + CLEAR ls_name_style. + ls_name_style-sheet = . + ls_name_style-name = ls_variable-name. + ls_name_style-parent = ls_variable-parent. + APPEND ls_name_style TO mt_name_styles ASSIGNING . + ENDIF. + IF lo_style IS NOT BOUND. + -text_counter = -text_counter + 1. + ELSE. + IF lo_style->number_format->format_code CA '0' + AND lo_style->number_format->format_code NS '0]'. + -numeric_counter = -numeric_counter + 1. + ELSEIF lo_style->number_format->format_code CA 'm' + AND lo_style->number_format->format_code CA 'd' + AND lo_style->number_format->format_code NA 'h'. + -date_counter = -date_counter + 1. + ELSEIF ( lo_style->number_format->format_code CA 'h' OR lo_style->number_format->format_code CA 's' ) + AND lo_style->number_format->format_code NA 'd'. + -time_counter = -time_counter + 1. + ELSE. + -text_counter = -text_counter + 1. + ENDIF. + ENDIF. + + ENDLOOP. + lv_column = lv_column + 1. + ENDWHILE. + lv_row = lv_row + 1. + ENDWHILE. + ENDLOOP. + + SORT mt_range BY id . + ENDMETHOD. + + + METHOD get_range. + + DATA: + lo_worksheets_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lo_range_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_range TYPE REF TO ycl_ecb_range. + + + lo_worksheets_iterator = mo_excel->get_worksheets_iterator( ). + + + WHILE lo_worksheets_iterator->has_next( ) = abap_true. + lo_worksheet ?= lo_worksheets_iterator->get_next( ). + APPEND lo_worksheet->get_title( ) TO mt_sheet. + ENDWHILE. + + lo_range_iterator = mo_excel->get_ranges_iterator( ). + + WHILE lo_range_iterator->has_next( ) = abap_true. + lo_range ?= lo_range_iterator->get_next( ). + validate_range( lo_range ). + ENDWHILE. + + ENDMETHOD. + + + METHOD sign_range. + + DATA: lv_tabix TYPE i. + FIELD-SYMBOLS: + TYPE ts_range, + TYPE ts_range. + + LOOP AT mt_range ASSIGNING . + -id = sy-tabix. + ENDLOOP. + + LOOP AT mt_range ASSIGNING . + lv_tabix = sy-tabix + 1. + + LOOP AT mt_range ASSIGNING + FROM lv_tabix + WHERE sheet = -sheet. + + IF -start >= -start AND -stop <= -stop. + -parent = -id. + ENDIF. + + ENDLOOP. + + ENDLOOP. + + SORT mt_range BY id DESCENDING. + ENDMETHOD. + + + METHOD validate_range. + + DATA: lv_range_name TYPE string, + lv_range_address TYPE string, + lv_range_start TYPE string, + lv_range_stop TYPE string, + lv_range_sheet TYPE string, + lv_tmp_value TYPE string, + lt_cell_coord_parts TYPE TABLE OF string, + lv_cell_coord_start TYPE string, + lv_cell_coord_stop TYPE string, + lv_column_start TYPE yecb_cell_column_alpha, + lv_column_end TYPE yecb_cell_column_alpha, + lv_row_start TYPE yecb_cell_row, + lv_row_end TYPE yecb_cell_row. + + FIELD-SYMBOLS: TYPE ts_range. + + + lv_range_name = io_range->name. + TRANSLATE lv_range_name TO UPPER CASE. + lv_range_address = io_range->get_value( ). + + SPLIT lv_range_address AT '!' INTO lv_range_sheet lv_tmp_value. + + SPLIT lv_tmp_value AT ':' INTO lv_range_start lv_range_stop. + + SPLIT lv_range_start AT '$' INTO TABLE lt_cell_coord_parts. + + IF lines( lt_cell_coord_parts ) > 2. + TRY. + ycl_ecb_common=>convert_range2column_a_row( + EXPORTING + i_range = lv_range_address + IMPORTING + e_column_start = lv_column_start + e_column_end = lv_column_end + e_row_start = lv_row_start + e_row_end = lv_row_end + ). + CATCH ycx_ecb. " + RETURN. + ENDTRY. + IF lv_column_start = 'A' AND lv_column_end = 'XFD'. + lv_cell_coord_start = |{ lv_row_start }|. + lv_cell_coord_stop = |{ lv_row_end }|. + CLEAR lt_cell_coord_parts. + CLEAR lv_range_stop. + ELSE. + RETURN. + ENDIF. + ENDIF. + + IF lines( lt_cell_coord_parts ) >= 2. + READ TABLE lt_cell_coord_parts INTO lv_cell_coord_start INDEX 2. + ENDIF. + + IF lv_cell_coord_start CO '0123456789'. + APPEND INITIAL LINE TO mt_range ASSIGNING . + -sheet = lv_range_sheet. + -name = lv_range_name. + -start = lv_cell_coord_start. + + SPLIT lv_range_stop AT '$' INTO TABLE lt_cell_coord_parts. + READ TABLE lt_cell_coord_parts INTO lv_cell_coord_stop INDEX 2. + -stop = lv_cell_coord_stop. + + -length = -stop - -start + 1. + + ENDIF. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_fill_template.clas.xml b/src/abap2xlsx/ycl_ecb_fill_template.clas.xml new file mode 100644 index 0000000..fd600ba --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_fill_template.clas.xml @@ -0,0 +1,38 @@ + + + + + + YCL_ECB_FILL_TEMPLATE + E + poopulate excell template with data + 1 + X + X + X + + + + MO_EXCEL + E + Excel creator + + + MT_RANGE + E + Range description + + + MT_SHEET + E + table of sheet title + + + MT_VAR + E + var description + + + + + diff --git a/src/abap2xlsx/ycl_ecb_font.clas.abap b/src/abap2xlsx/ycl_ecb_font.clas.abap new file mode 100644 index 0000000..77a41bb --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_font.clas.abap @@ -0,0 +1,183 @@ +CLASS ycl_ecb_font DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: + BEGIN OF mty_s_font_metric, + char TYPE c LENGTH 1, + char_width TYPE tdcwidths, + END OF mty_s_font_metric . + TYPES: + mty_th_font_metrics + TYPE HASHED TABLE OF mty_s_font_metric + WITH UNIQUE KEY char . + TYPES: + BEGIN OF mty_s_font_cache, + font_name TYPE yecb_style_font_name, + font_height TYPE tdfontsize, + flag_bold TYPE abap_bool, + flag_italic TYPE abap_bool, + th_font_metrics TYPE mty_th_font_metrics, + END OF mty_s_font_cache . + TYPES: + mty_th_font_cache + 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 yecb_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 yecb_style_font_name + !iv_font_height TYPE tdfontsize + !iv_flag_bold TYPE abap_bool + !iv_flag_italic TYPE abap_bool + !iv_cell_value TYPE yecb_cell_value + RETURNING + VALUE(rv_width) TYPE f . + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_font IMPLEMENTATION. + + + METHOD calculate_text_width. + + CONSTANTS lc_excel_cell_padding TYPE f VALUE '0.75'. + + DATA: ld_current_character TYPE c LENGTH 1, + lt_itcfc TYPE STANDARD TABLE OF itcfc, + ld_offset TYPE i, + ld_length TYPE i, + ld_uccp TYPE i, + ls_font_metric TYPE mty_s_font_metric, + ld_width_from_font_metrics TYPE i, + ld_font_family TYPE itcfh-tdfamily, + lt_font_families LIKE STANDARD TABLE OF ld_font_family, + ls_font_cache TYPE mty_s_font_cache. + + FIELD-SYMBOLS: TYPE mty_s_font_cache, + TYPE mty_s_font_metric, + TYPE itcfc. + + " Check if the same font (font name and font attributes) was already + " used before + READ TABLE mth_font_cache + WITH TABLE KEY + font_name = iv_font_name + font_height = iv_font_height + flag_bold = iv_flag_bold + flag_italic = iv_flag_italic + ASSIGNING . + + IF sy-subrc <> 0. + " Font is used for the first time + " Add the font to our local font cache + ls_font_cache-font_name = iv_font_name. + ls_font_cache-font_height = iv_font_height. + ls_font_cache-flag_bold = iv_flag_bold. + ls_font_cache-flag_italic = iv_flag_italic. + INSERT ls_font_cache INTO TABLE mth_font_cache + ASSIGNING . + + " Determine the SAPscript font family name from the Excel + " font name + SELECT tdfamily + FROM tfo01 + INTO TABLE lt_font_families + UP TO 1 ROWS + WHERE tdtext = iv_font_name + ORDER BY PRIMARY KEY. + + " Check if a matching font family was found + " Fonts can be uploaded from TTF files using transaction SE73 + IF lines( lt_font_families ) > 0. + READ TABLE lt_font_families INDEX 1 INTO ld_font_family. + + " Load font metrics (returns a table with the size of each letter + " in the font) + CALL FUNCTION 'LOAD_FONT' + EXPORTING + family = ld_font_family + height = iv_font_height + printer = 'SWIN' + bold = iv_flag_bold + italic = iv_flag_italic + TABLES + metric = lt_itcfc + EXCEPTIONS + font_family = 1 + codepage = 2 + device_type = 3 + OTHERS = 4. + IF sy-subrc <> 0. + CLEAR lt_itcfc. + ENDIF. + + " For faster access, convert each character number to the actual + " character, and store the characters and their sizes in a hash + " table + LOOP AT lt_itcfc ASSIGNING . + ld_uccp = -cpcharno. + ls_font_metric-char = + cl_abap_conv_in_ce=>uccpi( ld_uccp ). + ls_font_metric-char_width = -tdcwidths. + INSERT ls_font_metric + INTO TABLE -th_font_metrics. + ENDLOOP. + + ENDIF. + ENDIF. + + " Calculate the cell width + " If available, use font metrics + IF lines( -th_font_metrics ) = 0. + " Font metrics are not available + " -> Calculate the cell width using only the font size + ld_length = strlen( iv_cell_value ). + rv_width = ld_length * iv_font_height / lc_default_font_height + lc_excel_cell_padding. + + ELSE. + " Font metrics are available + + " Calculate the size of the text by adding the sizes of each + " letter + ld_length = strlen( iv_cell_value ). + DO ld_length TIMES. + " Subtract 1, because the first character is at offset 0 + ld_offset = sy-index - 1. + + " Read the current character from the cell value + ld_current_character = iv_cell_value+ld_offset(1). + + " Look up the size of the current letter + READ TABLE -th_font_metrics + WITH TABLE KEY char = ld_current_character + ASSIGNING . + IF sy-subrc = 0. + " The size of the letter is known + " -> Add the actual size of the letter + ADD -char_width TO ld_width_from_font_metrics. + ELSE. + " The size of the letter is unknown + " -> Add the font height as the default letter size + ADD iv_font_height TO ld_width_from_font_metrics. + ENDIF. + ENDDO. + + " Add cell padding (Excel makes columns a bit wider than the space + " that is needed for the text itself) and convert unit + " (division by 100) + rv_width = ld_width_from_font_metrics / 100 + lc_excel_cell_padding. + ENDIF. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_font.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_font.clas.testclasses.abap new file mode 100644 index 0000000..182781b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_font.clas.testclasses.abap @@ -0,0 +1,27 @@ +CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. + + PRIVATE SECTION. + METHODS calculate FOR TESTING RAISING cx_static_check. +ENDCLASS. + + +CLASS ltcl_test IMPLEMENTATION. + + METHOD calculate. + + DATA lv_width TYPE f. + + lv_width = ycl_ecb_font=>calculate_text_width( + iv_font_name = 'foobar' + iv_font_height = 20 + iv_flag_bold = abap_false + iv_flag_italic = abap_false + iv_cell_value = 'hello world' ). + + cl_abap_unit_assert=>assert_equals( + act = lv_width + exp = '2.75' ). + + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_font.clas.xml b/src/abap2xlsx/ycl_ecb_font.clas.xml new file mode 100644 index 0000000..a430e09 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_font.clas.xml @@ -0,0 +1,17 @@ + + + + + + YCL_ECB_FONT + E + abap2xlsx - Font Logic + 1 + X + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_graph.clas.abap b/src/abap2xlsx/ycl_ecb_graph.clas.abap new file mode 100644 index 0000000..de560ef --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph.clas.abap @@ -0,0 +1,410 @@ +CLASS ycl_ecb_graph DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: +*"* public components of class ZCL_EXCEL_GRAPH +*"* do not include other source files here!!! + BEGIN OF s_style, + c14style TYPE i, + cstyle TYPE i, + END OF s_style . + TYPES: + BEGIN OF s_series, + idx TYPE i, + order TYPE i, + invertifnegative TYPE string, + symbol TYPE string, + smooth TYPE string, + lbl TYPE string, + ref TYPE string, + sername TYPE string, + END OF s_series . + TYPES: + t_series TYPE STANDARD TABLE OF s_series . + TYPES: + BEGIN OF s_pagemargins, + b TYPE string, + l TYPE string, + r TYPE string, + t TYPE string, + header TYPE string, + footer TYPE string, + END OF s_pagemargins . + + DATA ns_1904val TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA ns_langval TYPE string VALUE 'it-IT'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA ns_roundedcornersval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA pagemargins TYPE s_pagemargins . + DATA ns_autotitledeletedval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA ns_plotvisonlyval TYPE string VALUE '1'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA ns_dispblanksasval TYPE string VALUE 'gap'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA ns_showdlblsovermaxval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA title TYPE string . . . " . + DATA series TYPE t_series . + DATA ns_c14styleval TYPE string VALUE '102'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA print_label TYPE c VALUE 'X'. "#EC NOTEXT . . . . . . . . . . . . . . " . + DATA ns_styleval TYPE string VALUE '2'. "#EC NOTEXT . . . . . . . . . . . . . . " . + CONSTANTS: + BEGIN OF c_style_default, + c14style TYPE i VALUE 102, + cstyle TYPE i VALUE 2, + END OF c_style_default . + CONSTANTS: + BEGIN OF c_style_1, + c14style TYPE i VALUE 101, + cstyle TYPE i VALUE 1, + END OF c_style_1 . + CONSTANTS: + BEGIN OF c_style_3, + c14style TYPE i VALUE 103, + cstyle TYPE i VALUE 3, + END OF c_style_3 . + CONSTANTS: + BEGIN OF c_style_4, + c14style TYPE i VALUE 104, + cstyle TYPE i VALUE 4, + END OF c_style_4 . + CONSTANTS: + BEGIN OF c_style_5, + c14style TYPE i VALUE 105, + cstyle TYPE i VALUE 5, + END OF c_style_5 . + CONSTANTS: + BEGIN OF c_style_6, + c14style TYPE i VALUE 106, + cstyle TYPE i VALUE 6, + END OF c_style_6 . + CONSTANTS: + BEGIN OF c_style_7, + c14style TYPE i VALUE 107, + cstyle TYPE i VALUE 7, + END OF c_style_7 . + CONSTANTS: + BEGIN OF c_style_8, + c14style TYPE i VALUE 108, + cstyle TYPE i VALUE 8, + END OF c_style_8 . + CONSTANTS: + BEGIN OF c_style_9, + c14style TYPE i VALUE 109, + cstyle TYPE i VALUE 9, + END OF c_style_9 . + CONSTANTS: + BEGIN OF c_style_10, + c14style TYPE i VALUE 110, + cstyle TYPE i VALUE 10, + END OF c_style_10 . + CONSTANTS: + BEGIN OF c_style_11, + c14style TYPE i VALUE 111, + cstyle TYPE i VALUE 11, + END OF c_style_11 . + CONSTANTS: + BEGIN OF c_style_12, + c14style TYPE i VALUE 112, + cstyle TYPE i VALUE 12, + END OF c_style_12 . + CONSTANTS: + BEGIN OF c_style_13, + c14style TYPE i VALUE 113, + cstyle TYPE i VALUE 13, + END OF c_style_13 . + CONSTANTS: + BEGIN OF c_style_14, + c14style TYPE i VALUE 114, + cstyle TYPE i VALUE 14, + END OF c_style_14 . + CONSTANTS: + BEGIN OF c_style_15, + c14style TYPE i VALUE 115, + cstyle TYPE i VALUE 15, + END OF c_style_15 . + CONSTANTS: + BEGIN OF c_style_16, + c14style TYPE i VALUE 116, + cstyle TYPE i VALUE 16, + END OF c_style_16 . + CONSTANTS: + BEGIN OF c_style_17, + c14style TYPE i VALUE 117, + cstyle TYPE i VALUE 17, + END OF c_style_17 . + CONSTANTS: + BEGIN OF c_style_18, + c14style TYPE i VALUE 118, + cstyle TYPE i VALUE 18, + END OF c_style_18 . + CONSTANTS: + BEGIN OF c_style_19, + c14style TYPE i VALUE 119, + cstyle TYPE i VALUE 19, + END OF c_style_19 . + CONSTANTS: + BEGIN OF c_style_20, + c14style TYPE i VALUE 120, + cstyle TYPE i VALUE 20, + END OF c_style_20 . + CONSTANTS: + BEGIN OF c_style_21, + c14style TYPE i VALUE 121, + cstyle TYPE i VALUE 21, + END OF c_style_21 . + CONSTANTS: + BEGIN OF c_style_22, + c14style TYPE i VALUE 122, + cstyle TYPE i VALUE 22, + END OF c_style_22 . + CONSTANTS: + BEGIN OF c_style_23, + c14style TYPE i VALUE 123, + cstyle TYPE i VALUE 23, + END OF c_style_23 . + CONSTANTS: + BEGIN OF c_style_24, + c14style TYPE i VALUE 124, + cstyle TYPE i VALUE 24, + END OF c_style_24 . + CONSTANTS: + BEGIN OF c_style_25, + c14style TYPE i VALUE 125, + cstyle TYPE i VALUE 25, + END OF c_style_25 . + CONSTANTS: + BEGIN OF c_style_26, + c14style TYPE i VALUE 126, + cstyle TYPE i VALUE 26, + END OF c_style_26 . + CONSTANTS: + BEGIN OF c_style_27, + c14style TYPE i VALUE 127, + cstyle TYPE i VALUE 27, + END OF c_style_27 . + CONSTANTS: + BEGIN OF c_style_28, + c14style TYPE i VALUE 128, + cstyle TYPE i VALUE 28, + END OF c_style_28 . + CONSTANTS: + BEGIN OF c_style_29, + c14style TYPE i VALUE 129, + cstyle TYPE i VALUE 29, + END OF c_style_29 . + CONSTANTS: + BEGIN OF c_style_30, + c14style TYPE i VALUE 130, + cstyle TYPE i VALUE 30, + END OF c_style_30 . + CONSTANTS: + BEGIN OF c_style_31, + c14style TYPE i VALUE 131, + cstyle TYPE i VALUE 31, + END OF c_style_31 . + CONSTANTS: + BEGIN OF c_style_32, + c14style TYPE i VALUE 132, + cstyle TYPE i VALUE 32, + END OF c_style_32 . + CONSTANTS: + BEGIN OF c_style_33, + c14style TYPE i VALUE 133, + cstyle TYPE i VALUE 33, + END OF c_style_33 . + CONSTANTS: + BEGIN OF c_style_34, + c14style TYPE i VALUE 134, + cstyle TYPE i VALUE 34, + END OF c_style_34 . + CONSTANTS: + BEGIN OF c_style_35, + c14style TYPE i VALUE 135, + cstyle TYPE i VALUE 35, + END OF c_style_35 . + CONSTANTS: + BEGIN OF c_style_36, + c14style TYPE i VALUE 136, + cstyle TYPE i VALUE 36, + END OF c_style_36 . + CONSTANTS: + BEGIN OF c_style_37, + c14style TYPE i VALUE 137, + cstyle TYPE i VALUE 37, + END OF c_style_37 . + CONSTANTS: + BEGIN OF c_style_38, + c14style TYPE i VALUE 138, + cstyle TYPE i VALUE 38, + END OF c_style_38 . + CONSTANTS: + BEGIN OF c_style_39, + c14style TYPE i VALUE 139, + cstyle TYPE i VALUE 39, + END OF c_style_39 . + CONSTANTS: + BEGIN OF c_style_40, + c14style TYPE i VALUE 140, + cstyle TYPE i VALUE 40, + END OF c_style_40 . + CONSTANTS: + BEGIN OF c_style_41, + c14style TYPE i VALUE 141, + cstyle TYPE i VALUE 41, + END OF c_style_41 . + CONSTANTS: + BEGIN OF c_style_42, + c14style TYPE i VALUE 142, + cstyle TYPE i VALUE 42, + END OF c_style_42 . + CONSTANTS: + BEGIN OF c_style_43, + c14style TYPE i VALUE 143, + cstyle TYPE i VALUE 43, + END OF c_style_43 . + CONSTANTS: + BEGIN OF c_style_44, + c14style TYPE i VALUE 144, + cstyle TYPE i VALUE 44, + END OF c_style_44 . + CONSTANTS: + BEGIN OF c_style_45, + c14style TYPE i VALUE 145, + cstyle TYPE i VALUE 45, + END OF c_style_45 . + CONSTANTS: + BEGIN OF c_style_46, + c14style TYPE i VALUE 146, + cstyle TYPE i VALUE 46, + END OF c_style_46 . + CONSTANTS: + BEGIN OF c_style_47, + c14style TYPE i VALUE 147, + cstyle TYPE i VALUE 47, + END OF c_style_47 . + CONSTANTS: + BEGIN OF c_style_48, + c14style TYPE i VALUE 148, + cstyle TYPE i VALUE 48, + END OF c_style_48 . + CONSTANTS c_show_true TYPE c VALUE '1'. "#EC NOTEXT + CONSTANTS c_show_false TYPE c VALUE '0'. "#EC NOTEXT + CONSTANTS c_print_lbl_true TYPE c VALUE '1'. "#EC NOTEXT + CONSTANTS c_print_lbl_false TYPE c VALUE '0'. "#EC NOTEXT + + METHODS constructor . + METHODS create_serie + IMPORTING + !ip_idx TYPE i OPTIONAL + !ip_order TYPE i + !ip_invertifnegative TYPE string OPTIONAL + !ip_symbol TYPE string OPTIONAL + !ip_smooth TYPE c OPTIONAL + !ip_lbl_from_col TYPE yecb_cell_column_alpha OPTIONAL + !ip_lbl_from_row TYPE yecb_cell_row OPTIONAL + !ip_lbl_to_col TYPE yecb_cell_column_alpha OPTIONAL + !ip_lbl_to_row TYPE yecb_cell_row OPTIONAL + !ip_lbl TYPE string OPTIONAL + !ip_ref_from_col TYPE yecb_cell_column_alpha OPTIONAL + !ip_ref_from_row TYPE yecb_cell_row OPTIONAL + !ip_ref_to_col TYPE yecb_cell_column_alpha OPTIONAL + !ip_ref_to_row TYPE yecb_cell_row OPTIONAL + !ip_ref TYPE string OPTIONAL + !ip_sername TYPE string + !ip_sheet TYPE yecb_sheet_title OPTIONAL . + METHODS set_style + IMPORTING + !ip_style TYPE s_style . + METHODS set_print_lbl + IMPORTING + !ip_value TYPE c . + METHODS set_title + IMPORTING + ip_value TYPE string . + PROTECTED SECTION. +*"* protected components of class ZCL_EXCEL_GRAPH +*"* do not include other source files here!!! + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_GRAPH +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_graph IMPLEMENTATION. + + + METHOD constructor. + "Load default values + me->pagemargins-b = '0.75'. + me->pagemargins-l = '0.7'. + me->pagemargins-r = '0.7'. + me->pagemargins-t = '0.75'. + me->pagemargins-header = '0.3'. + me->pagemargins-footer = '0.3'. + ENDMETHOD. + + + METHOD create_serie. + DATA ls_serie TYPE s_series. + + DATA: lv_start_row_c TYPE c LENGTH 7, + lv_stop_row_c TYPE c LENGTH 7. + + + IF ip_lbl IS NOT SUPPLIED. + lv_stop_row_c = ip_lbl_to_row. + SHIFT lv_stop_row_c RIGHT DELETING TRAILING space. + SHIFT lv_stop_row_c LEFT DELETING LEADING space. + lv_start_row_c = ip_lbl_from_row. + SHIFT lv_start_row_c RIGHT DELETING TRAILING space. + SHIFT lv_start_row_c LEFT DELETING LEADING space. + ls_serie-lbl = ip_sheet. + ls_serie-lbl = ycl_ecb_common=>escape_string( ip_value = ls_serie-lbl ). + CONCATENATE ls_serie-lbl '!$' ip_lbl_from_col '$' lv_start_row_c ':$' ip_lbl_to_col '$' lv_stop_row_c INTO ls_serie-lbl. + CLEAR: lv_start_row_c, lv_stop_row_c. + ELSE. + ls_serie-lbl = ip_lbl. + ENDIF. + IF ip_ref IS NOT SUPPLIED. + lv_stop_row_c = ip_ref_to_row. + SHIFT lv_stop_row_c RIGHT DELETING TRAILING space. + SHIFT lv_stop_row_c LEFT DELETING LEADING space. + lv_start_row_c = ip_ref_from_row. + SHIFT lv_start_row_c RIGHT DELETING TRAILING space. + SHIFT lv_start_row_c LEFT DELETING LEADING space. + ls_serie-ref = ip_sheet. + ls_serie-ref = ycl_ecb_common=>escape_string( ip_value = ls_serie-ref ). + CONCATENATE ls_serie-ref '!$' ip_ref_from_col '$' lv_start_row_c ':$' ip_ref_to_col '$' lv_stop_row_c INTO ls_serie-ref. + CLEAR: lv_start_row_c, lv_stop_row_c. + ELSE. + ls_serie-ref = ip_ref. + ENDIF. + ls_serie-idx = ip_idx. + ls_serie-order = ip_order. + ls_serie-invertifnegative = ip_invertifnegative. + ls_serie-symbol = ip_symbol. + ls_serie-smooth = ip_smooth. + ls_serie-sername = ip_sername. + APPEND ls_serie TO me->series. + SORT me->series BY order ASCENDING. + ENDMETHOD. + + + METHOD set_print_lbl. + me->print_label = ip_value. + ENDMETHOD. + + + METHOD set_style. + me->ns_c14styleval = ip_style-c14style. + CONDENSE me->ns_c14styleval NO-GAPS. + me->ns_styleval = ip_style-cstyle. + CONDENSE me->ns_styleval NO-GAPS. + ENDMETHOD. + + + METHOD set_title. + me->title = ip_value. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_graph.clas.xml b/src/abap2xlsx/ycl_ecb_graph.clas.xml new file mode 100644 index 0000000..c2949cf --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph.clas.xml @@ -0,0 +1,68 @@ + + + + + + YCL_ECB_GRAPH + E + Graphic + 1 + X + X + X + + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_PRINT_LBL_FALSE + E + Single-Character Flag + + + C_PRINT_LBL_FALSE + I + Single-Character Flag + + + C_PRINT_LBL_TRUE + E + Single-Character Flag + + + C_PRINT_LBL_TRUE + I + Single-Character Flag + + + C_SHOW_FALSE + E + Single-Character Flag + + + C_SHOW_FALSE + I + Single-Character Flag + + + C_SHOW_TRUE + E + Single-Character Flag + + + C_SHOW_TRUE + I + Single-Character Flag + + + + + diff --git a/src/abap2xlsx/ycl_ecb_graph_bars.clas.abap b/src/abap2xlsx/ycl_ecb_graph_bars.clas.abap new file mode 100644 index 0000000..3a518d9 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph_bars.clas.abap @@ -0,0 +1,283 @@ +CLASS ycl_ecb_graph_bars DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_graph + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: +*"* public components of class ZCL_EXCEL_GRAPH_BARS +*"* do not include other source files here!!! + tv_type TYPE c LENGTH 5, + BEGIN OF s_ax, + axid TYPE string, + type TYPE tv_type, + orientation TYPE string, + delete TYPE string, + axpos TYPE string, + formatcode TYPE string, + sourcelinked TYPE string, + majortickmark TYPE string, + minortickmark TYPE string, + ticklblpos TYPE string, + crossax TYPE string, + crosses TYPE string, + auto TYPE string, + lblalgn TYPE string, + lbloffset TYPE string, + nomultilvllbl TYPE string, + crossbetween TYPE string, + END OF s_ax . + TYPES: + t_ax TYPE STANDARD TABLE OF s_ax . + + DATA ns_bardirval TYPE string VALUE 'col'. "#EC NOTEXT . . . . . . . . . . . " . + CONSTANTS c_groupingval_clustered TYPE string VALUE 'clustered'. "#EC NOTEXT + CONSTANTS c_groupingval_stacked TYPE string VALUE 'stacked'. "#EC NOTEXT + DATA ns_groupingval TYPE string VALUE c_groupingval_clustered. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_varycolorsval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_showlegendkeyval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_showvalval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_showcatnameval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_showsernameval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_showpercentval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_showbubblesizeval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_gapwidthval TYPE string VALUE '150'. "#EC NOTEXT . . . . . . . . . . . " . + DATA axes TYPE t_ax . + CONSTANTS: + c_valax TYPE c LENGTH 5 VALUE 'VALAX'. "#EC NOTEXT + CONSTANTS: + c_catax TYPE c LENGTH 5 VALUE 'CATAX'. "#EC NOTEXT + DATA ns_legendposval TYPE string VALUE 'r'. "#EC NOTEXT . . . . . . . . . . . " . + DATA ns_overlayval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . . " . + CONSTANTS c_invertifnegative_yes TYPE string VALUE '1'. "#EC NOTEXT + CONSTANTS c_invertifnegative_no TYPE string VALUE '0'. "#EC NOTEXT + + METHODS create_ax + IMPORTING + !ip_axid TYPE string OPTIONAL + !ip_type TYPE tv_type + !ip_orientation TYPE string OPTIONAL + !ip_delete TYPE string OPTIONAL + !ip_axpos TYPE string OPTIONAL + !ip_formatcode TYPE string OPTIONAL + !ip_sourcelinked TYPE string OPTIONAL + !ip_majortickmark TYPE string OPTIONAL + !ip_minortickmark TYPE string OPTIONAL + !ip_ticklblpos TYPE string OPTIONAL + !ip_crossax TYPE string OPTIONAL + !ip_crosses TYPE string OPTIONAL + !ip_auto TYPE string OPTIONAL + !ip_lblalgn TYPE string OPTIONAL + !ip_lbloffset TYPE string OPTIONAL + !ip_nomultilvllbl TYPE string OPTIONAL + !ip_crossbetween TYPE string OPTIONAL . + METHODS set_show_legend_key + IMPORTING + !ip_value TYPE c . + METHODS set_show_values + IMPORTING + !ip_value TYPE c . + METHODS set_show_cat_name + IMPORTING + !ip_value TYPE c . + METHODS set_show_ser_name + IMPORTING + !ip_value TYPE c . + METHODS set_show_percent + IMPORTING + !ip_value TYPE c . + METHODS set_varycolor + IMPORTING + !ip_value TYPE c . + PROTECTED SECTION. +*"* protected components of class ZCL_EXCEL_GRAPH_BARS +*"* do not include other source files here!!! + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_GRAPH_BARS +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_graph_bars IMPLEMENTATION. + + + METHOD create_ax. + DATA ls_ax TYPE s_ax. + ls_ax-type = ip_type. + + IF ip_type = c_catax. + IF ip_axid IS SUPPLIED. + ls_ax-axid = ip_axid. + ELSE. + ls_ax-axid = '1'. + ENDIF. + IF ip_orientation IS SUPPLIED. + ls_ax-orientation = ip_orientation. + ELSE. + ls_ax-orientation = 'minMax'. + ENDIF. + IF ip_delete IS SUPPLIED. + ls_ax-delete = ip_delete. + ELSE. + ls_ax-delete = '0'. + ENDIF. + IF ip_axpos IS SUPPLIED. + ls_ax-axpos = ip_axpos. + ELSE. + ls_ax-axpos = 'b'. + ENDIF. + IF ip_formatcode IS SUPPLIED. + ls_ax-formatcode = ip_formatcode. + ELSE. + ls_ax-formatcode = 'General'. + ENDIF. + IF ip_sourcelinked IS SUPPLIED. + ls_ax-sourcelinked = ip_sourcelinked. + ELSE. + ls_ax-sourcelinked = '1'. + ENDIF. + IF ip_majortickmark IS SUPPLIED. + ls_ax-majortickmark = ip_majortickmark. + ELSE. + ls_ax-majortickmark = 'out'. + ENDIF. + IF ip_minortickmark IS SUPPLIED. + ls_ax-minortickmark = ip_minortickmark. + ELSE. + ls_ax-minortickmark = 'none'. + ENDIF. + IF ip_ticklblpos IS SUPPLIED. + ls_ax-ticklblpos = ip_ticklblpos. + ELSE. + ls_ax-ticklblpos = 'nextTo'. + ENDIF. + IF ip_crossax IS SUPPLIED. + ls_ax-crossax = ip_crossax. + ELSE. + ls_ax-crossax = '2'. + ENDIF. + IF ip_crosses IS SUPPLIED. + ls_ax-crosses = ip_crosses. + ELSE. + ls_ax-crosses = 'autoZero'. + ENDIF. + IF ip_auto IS SUPPLIED. + ls_ax-auto = ip_auto. + ELSE. + ls_ax-auto = '1'. + ENDIF. + IF ip_lblalgn IS SUPPLIED. + ls_ax-lblalgn = ip_lblalgn. + ELSE. + ls_ax-lblalgn = 'ctr'. + ENDIF. + IF ip_lbloffset IS SUPPLIED. + ls_ax-lbloffset = ip_lbloffset. + ELSE. + ls_ax-lbloffset = '100'. + ENDIF. + IF ip_nomultilvllbl IS SUPPLIED. + ls_ax-nomultilvllbl = ip_nomultilvllbl. + ELSE. + ls_ax-nomultilvllbl = '0'. + ENDIF. + ELSEIF ip_type = c_valax. + IF ip_axid IS SUPPLIED. + ls_ax-axid = ip_axid. + ELSE. + ls_ax-axid = '2'. + ENDIF. + IF ip_orientation IS SUPPLIED. + ls_ax-orientation = ip_orientation. + ELSE. + ls_ax-orientation = 'minMax'. + ENDIF. + IF ip_delete IS SUPPLIED. + ls_ax-delete = ip_delete. + ELSE. + ls_ax-delete = '0'. + ENDIF. + IF ip_axpos IS SUPPLIED. + ls_ax-axpos = ip_axpos. + ELSE. + ls_ax-axpos = 'l'. + ENDIF. + IF ip_formatcode IS SUPPLIED. + ls_ax-formatcode = ip_formatcode. + ELSE. + ls_ax-formatcode = 'General'. + ENDIF. + IF ip_sourcelinked IS SUPPLIED. + ls_ax-sourcelinked = ip_sourcelinked. + ELSE. + ls_ax-sourcelinked = '1'. + ENDIF. + IF ip_majortickmark IS SUPPLIED. + ls_ax-majortickmark = ip_majortickmark. + ELSE. + ls_ax-majortickmark = 'out'. + ENDIF. + IF ip_minortickmark IS SUPPLIED. + ls_ax-minortickmark = ip_minortickmark. + ELSE. + ls_ax-minortickmark = 'none'. + ENDIF. + IF ip_ticklblpos IS SUPPLIED. + ls_ax-ticklblpos = ip_ticklblpos. + ELSE. + ls_ax-ticklblpos = 'nextTo'. + ENDIF. + IF ip_crossax IS SUPPLIED. + ls_ax-crossax = ip_crossax. + ELSE. + ls_ax-crossax = '1'. + ENDIF. + IF ip_crosses IS SUPPLIED. + ls_ax-crosses = ip_crosses. + ELSE. + ls_ax-crosses = 'autoZero'. + ENDIF. + IF ip_crossbetween IS SUPPLIED. + ls_ax-crossbetween = ip_crossbetween. + ELSE. + ls_ax-crossbetween = 'between'. + ENDIF. + ENDIF. + + APPEND ls_ax TO me->axes. + SORT me->axes BY axid ASCENDING. + ENDMETHOD. + + + METHOD set_show_cat_name. + ns_showcatnameval = ip_value. + ENDMETHOD. + + + METHOD set_show_legend_key. + ns_showlegendkeyval = ip_value. + ENDMETHOD. + + + METHOD set_show_percent. + ns_showpercentval = ip_value. + ENDMETHOD. + + + METHOD set_show_ser_name. + ns_showsernameval = ip_value. + ENDMETHOD. + + + METHOD set_show_values. + ns_showvalval = ip_value. + ENDMETHOD. + + + METHOD set_varycolor. + ns_varycolorsval = ip_value. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_graph_bars.clas.xml b/src/abap2xlsx/ycl_ecb_graph_bars.clas.xml new file mode 100644 index 0000000..494c57b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph_bars.clas.xml @@ -0,0 +1,88 @@ + + + + + + YCL_ECB_GRAPH_BARS + E + Bars Graphic + 1 + X + X + X + + + + C_GROUPINGVAL_CLUSTERED + E + Group parts of bars with offset + + + C_GROUPINGVAL_STACKED + E + Group bars on top of each other + + + SET_SHOW_CAT_NAME + E + Show the category name on the bar chart + + + SET_SHOW_CAT_NAME + I + Show the category name on the bar chart + + + SET_SHOW_LEGEND_KEY + E + Show the legend key on the bar chart + + + SET_SHOW_LEGEND_KEY + I + Show the legend key on the bar chart + + + SET_SHOW_PERCENT + E + Values as percent + + + SET_SHOW_PERCENT + I + Values as percent + + + SET_SHOW_SER_NAME + E + Show the serie name on the bar chart + + + SET_SHOW_SER_NAME + I + Show the serie name on the bar chart + + + SET_SHOW_VALUES + E + Show values on the bar chart + + + SET_SHOW_VALUES + I + Show values on the bar chart + + + SET_VARYCOLOR + E + Show vary colors + + + SET_VARYCOLOR + I + Show vary colors + + + + + diff --git a/src/abap2xlsx/ycl_ecb_graph_line.clas.abap b/src/abap2xlsx/ycl_ecb_graph_line.clas.abap new file mode 100644 index 0000000..36f566b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph_line.clas.abap @@ -0,0 +1,281 @@ +CLASS ycl_ecb_graph_line DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_graph + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: +*"* public components of class ZCL_EXCEL_GRAPH_LINE +*"* do not include other source files here!!! + tv_type TYPE c LENGTH 5, + BEGIN OF s_ax, + axid TYPE string, + type TYPE tv_type, + orientation TYPE string, + delete TYPE string, + axpos TYPE string, + formatcode TYPE string, + sourcelinked TYPE string, + majortickmark TYPE string, + minortickmark TYPE string, + ticklblpos TYPE string, + crossax TYPE string, + crosses TYPE string, + auto TYPE string, + lblalgn TYPE string, + lbloffset TYPE string, + nomultilvllbl TYPE string, + crossbetween TYPE string, + END OF s_ax . + TYPES: + t_ax TYPE STANDARD TABLE OF s_ax . + + DATA ns_groupingval TYPE string VALUE 'standard'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_varycolorsval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showlegendkeyval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showvalval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showcatnameval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showsernameval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showpercentval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showbubblesizeval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_markerval TYPE string VALUE '1'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_smoothval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA axes TYPE t_ax . + CONSTANTS: + c_valax TYPE c LENGTH 5 VALUE 'VALAX'. "#EC NOTEXT + CONSTANTS: + c_catax TYPE c LENGTH 5 VALUE 'CATAX'. "#EC NOTEXT + DATA ns_legendposval TYPE string VALUE 'r'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_overlayval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + CONSTANTS c_symbol_auto TYPE string VALUE 'auto'. "#EC NOTEXT + CONSTANTS c_symbol_none TYPE string VALUE 'none'. "#EC NOTEXT + + METHODS create_ax + IMPORTING + !ip_axid TYPE string OPTIONAL + !ip_type TYPE tv_type + !ip_orientation TYPE string OPTIONAL + !ip_delete TYPE string OPTIONAL + !ip_axpos TYPE string OPTIONAL + !ip_formatcode TYPE string OPTIONAL + !ip_sourcelinked TYPE string OPTIONAL + !ip_majortickmark TYPE string OPTIONAL + !ip_minortickmark TYPE string OPTIONAL + !ip_ticklblpos TYPE string OPTIONAL + !ip_crossax TYPE string OPTIONAL + !ip_crosses TYPE string OPTIONAL + !ip_auto TYPE string OPTIONAL + !ip_lblalgn TYPE string OPTIONAL + !ip_lbloffset TYPE string OPTIONAL + !ip_nomultilvllbl TYPE string OPTIONAL + !ip_crossbetween TYPE string OPTIONAL . + METHODS set_show_legend_key + IMPORTING + !ip_value TYPE c . + METHODS set_show_values + IMPORTING + !ip_value TYPE c . + METHODS set_show_cat_name + IMPORTING + !ip_value TYPE c . + METHODS set_show_ser_name + IMPORTING + !ip_value TYPE c . + METHODS set_show_percent + IMPORTING + !ip_value TYPE c . + METHODS set_varycolor + IMPORTING + !ip_value TYPE c . + PROTECTED SECTION. +*"* protected components of class ZCL_EXCEL_GRAPH_LINE +*"* do not include other source files here!!! + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_GRAPH_LINE +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_graph_line IMPLEMENTATION. + + + METHOD create_ax. + DATA ls_ax TYPE s_ax. + ls_ax-type = ip_type. + + IF ip_type = c_catax. + IF ip_axid IS SUPPLIED. + ls_ax-axid = ip_axid. + ELSE. + ls_ax-axid = '1'. + ENDIF. + IF ip_orientation IS SUPPLIED. + ls_ax-orientation = ip_orientation. + ELSE. + ls_ax-orientation = 'minMax'. + ENDIF. + IF ip_delete IS SUPPLIED. + ls_ax-delete = ip_delete. + ELSE. + ls_ax-delete = '0'. + ENDIF. + IF ip_axpos IS SUPPLIED. + ls_ax-axpos = ip_axpos. + ELSE. + ls_ax-axpos = 'b'. + ENDIF. + IF ip_formatcode IS SUPPLIED. + ls_ax-formatcode = ip_formatcode. + ELSE. + ls_ax-formatcode = 'General'. + ENDIF. + IF ip_sourcelinked IS SUPPLIED. + ls_ax-sourcelinked = ip_sourcelinked. + ELSE. + ls_ax-sourcelinked = '1'. + ENDIF. + IF ip_majortickmark IS SUPPLIED. + ls_ax-majortickmark = ip_majortickmark. + ELSE. + ls_ax-majortickmark = 'out'. + ENDIF. + IF ip_minortickmark IS SUPPLIED. + ls_ax-minortickmark = ip_minortickmark. + ELSE. + ls_ax-minortickmark = 'none'. + ENDIF. + IF ip_ticklblpos IS SUPPLIED. + ls_ax-ticklblpos = ip_ticklblpos. + ELSE. + ls_ax-ticklblpos = 'nextTo'. + ENDIF. + IF ip_crossax IS SUPPLIED. + ls_ax-crossax = ip_crossax. + ELSE. + ls_ax-crossax = '2'. + ENDIF. + IF ip_crosses IS SUPPLIED. + ls_ax-crosses = ip_crosses. + ELSE. + ls_ax-crosses = 'autoZero'. + ENDIF. + IF ip_auto IS SUPPLIED. + ls_ax-auto = ip_auto. + ELSE. + ls_ax-auto = '1'. + ENDIF. + IF ip_lblalgn IS SUPPLIED. + ls_ax-lblalgn = ip_lblalgn. + ELSE. + ls_ax-lblalgn = 'ctr'. + ENDIF. + IF ip_lbloffset IS SUPPLIED. + ls_ax-lbloffset = ip_lbloffset. + ELSE. + ls_ax-lbloffset = '100'. + ENDIF. + IF ip_nomultilvllbl IS SUPPLIED. + ls_ax-nomultilvllbl = ip_nomultilvllbl. + ELSE. + ls_ax-nomultilvllbl = '0'. + ENDIF. + ELSEIF ip_type = c_valax. + IF ip_axid IS SUPPLIED. + ls_ax-axid = ip_axid. + ELSE. + ls_ax-axid = '2'. + ENDIF. + IF ip_orientation IS SUPPLIED. + ls_ax-orientation = ip_orientation. + ELSE. + ls_ax-orientation = 'minMax'. + ENDIF. + IF ip_delete IS SUPPLIED. + ls_ax-delete = ip_delete. + ELSE. + ls_ax-delete = '0'. + ENDIF. + IF ip_axpos IS SUPPLIED. + ls_ax-axpos = ip_axpos. + ELSE. + ls_ax-axpos = 'l'. + ENDIF. + IF ip_formatcode IS SUPPLIED. + ls_ax-formatcode = ip_formatcode. + ELSE. + ls_ax-formatcode = 'General'. + ENDIF. + IF ip_sourcelinked IS SUPPLIED. + ls_ax-sourcelinked = ip_sourcelinked. + ELSE. + ls_ax-sourcelinked = '1'. + ENDIF. + IF ip_majortickmark IS SUPPLIED. + ls_ax-majortickmark = ip_majortickmark. + ELSE. + ls_ax-majortickmark = 'out'. + ENDIF. + IF ip_minortickmark IS SUPPLIED. + ls_ax-minortickmark = ip_minortickmark. + ELSE. + ls_ax-minortickmark = 'none'. + ENDIF. + IF ip_ticklblpos IS SUPPLIED. + ls_ax-ticklblpos = ip_ticklblpos. + ELSE. + ls_ax-ticklblpos = 'nextTo'. + ENDIF. + IF ip_crossax IS SUPPLIED. + ls_ax-crossax = ip_crossax. + ELSE. + ls_ax-crossax = '1'. + ENDIF. + IF ip_crosses IS SUPPLIED. + ls_ax-crosses = ip_crosses. + ELSE. + ls_ax-crosses = 'autoZero'. + ENDIF. + IF ip_crossbetween IS SUPPLIED. + ls_ax-crossbetween = ip_crossbetween. + ELSE. + ls_ax-crossbetween = 'between'. + ENDIF. + ENDIF. + + APPEND ls_ax TO me->axes. + SORT me->axes BY axid ASCENDING. + ENDMETHOD. + + + METHOD set_show_cat_name. + ns_showcatnameval = ip_value. + ENDMETHOD. + + + METHOD set_show_legend_key. + ns_showlegendkeyval = ip_value. + ENDMETHOD. + + + METHOD set_show_percent. + ns_showpercentval = ip_value. + ENDMETHOD. + + + METHOD set_show_ser_name. + ns_showsernameval = ip_value. + ENDMETHOD. + + + METHOD set_show_values. + ns_showvalval = ip_value. + ENDMETHOD. + + + METHOD set_varycolor. + ns_varycolorsval = ip_value. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_graph_line.clas.xml b/src/abap2xlsx/ycl_ecb_graph_line.clas.xml new file mode 100644 index 0000000..1bb8d03 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph_line.clas.xml @@ -0,0 +1,78 @@ + + + + + + YCL_ECB_GRAPH_LINE + E + Bars Graphic + 1 + X + X + X + + + + SET_SHOW_CAT_NAME + E + Show the category name on the bar chart + + + SET_SHOW_CAT_NAME + I + Show the category name on the bar chart + + + SET_SHOW_LEGEND_KEY + E + Show the legend key on the bar chart + + + SET_SHOW_LEGEND_KEY + I + Show the legend key on the bar chart + + + SET_SHOW_PERCENT + E + Values as percent + + + SET_SHOW_PERCENT + I + Values as percent + + + SET_SHOW_SER_NAME + E + Show the serie name on the bar chart + + + SET_SHOW_SER_NAME + I + Show the serie name on the bar chart + + + SET_SHOW_VALUES + E + Show values on the bar chart + + + SET_SHOW_VALUES + I + Show values on the bar chart + + + SET_VARYCOLOR + E + Show vary colors + + + SET_VARYCOLOR + I + Show vary colors + + + + + diff --git a/src/abap2xlsx/ycl_ecb_graph_pie.clas.abap b/src/abap2xlsx/ycl_ecb_graph_pie.clas.abap new file mode 100644 index 0000000..e0cad9c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph_pie.clas.abap @@ -0,0 +1,92 @@ +CLASS ycl_ecb_graph_pie DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_graph + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + +*"* public components of class ZCL_EXCEL_GRAPH_PIE +*"* do not include other source files here!!! + DATA ns_legendposval TYPE string VALUE 'r'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_overlayval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_pprrtl TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_endpararprlang TYPE string VALUE 'it-IT'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_varycolorsval TYPE string VALUE '1'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_firstsliceangval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showlegendkeyval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showvalval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showcatnameval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showsernameval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showpercentval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showbubblesizeval TYPE string VALUE '0'. "#EC NOTEXT . . . . . . . . . . " . + DATA ns_showleaderlinesval TYPE string VALUE '1'. "#EC NOTEXT . . . . . . . . . . " . + + METHODS set_show_legend_key + IMPORTING + !ip_value TYPE c . + METHODS set_show_values + IMPORTING + !ip_value TYPE c . + METHODS set_show_cat_name + IMPORTING + !ip_value TYPE c . + METHODS set_show_ser_name + IMPORTING + !ip_value TYPE c . + METHODS set_show_percent + IMPORTING + !ip_value TYPE c . + METHODS set_show_leader_lines + IMPORTING + !ip_value TYPE c . + METHODS set_varycolor + IMPORTING + !ip_value TYPE c . + PROTECTED SECTION. +*"* protected components of class ZCL_EXCEL_GRAPH_PIE +*"* do not include other source files here!!! + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_GRAPH_PIE +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_graph_pie IMPLEMENTATION. + + + METHOD set_show_cat_name. + ns_showcatnameval = ip_value. + ENDMETHOD. + + + METHOD set_show_leader_lines. + ns_showleaderlinesval = ip_value. + ENDMETHOD. + + + METHOD set_show_legend_key. + ns_showlegendkeyval = ip_value. + ENDMETHOD. + + + METHOD set_show_percent. + ns_showpercentval = ip_value. + ENDMETHOD. + + + METHOD set_show_ser_name. + ns_showsernameval = ip_value. + ENDMETHOD. + + + METHOD set_show_values. + ns_showvalval = ip_value. + ENDMETHOD. + + + METHOD set_varycolor. + ns_varycolorsval = ip_value. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_graph_pie.clas.xml b/src/abap2xlsx/ycl_ecb_graph_pie.clas.xml new file mode 100644 index 0000000..21b6180 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_graph_pie.clas.xml @@ -0,0 +1,88 @@ + + + + + + YCL_ECB_GRAPH_PIE + E + Pie Graphic + 1 + X + X + X + + + + SET_SHOW_CAT_NAME + E + Show the category name on the pie chart + + + SET_SHOW_CAT_NAME + I + Show the category name on the pie chart + + + SET_SHOW_LEADER_LINES + E + Show leader lines on the pie chart + + + SET_SHOW_LEADER_LINES + I + Show leader lines on the pie chart + + + SET_SHOW_LEGEND_KEY + E + Show the legend key on the pie chart + + + SET_SHOW_LEGEND_KEY + I + Show the legend key on the pie chart + + + SET_SHOW_PERCENT + E + Values as percent + + + SET_SHOW_PERCENT + I + Values as percent + + + SET_SHOW_SER_NAME + E + Show the serie name on the pie chart + + + SET_SHOW_SER_NAME + I + Show the serie name on the pie chart + + + SET_SHOW_VALUES + E + Show values on the pie chart + + + SET_SHOW_VALUES + I + Show values on the pie chart + + + SET_VARYCOLOR + E + Show vary colors + + + SET_VARYCOLOR + I + Show vary colors + + + + + diff --git a/src/abap2xlsx/ycl_ecb_hyperlink.clas.abap b/src/abap2xlsx/ycl_ecb_hyperlink.clas.abap new file mode 100644 index 0000000..cc08c45 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_hyperlink.clas.abap @@ -0,0 +1,107 @@ +CLASS ycl_ecb_hyperlink DEFINITION + PUBLIC + FINAL + CREATE PRIVATE . + +*"* public components of class ZCL_EXCEL_HYPERLINK +*"* do not include other source files here!!! + PUBLIC SECTION. + + CLASS-METHODS create_external_link + IMPORTING + !iv_url TYPE string + RETURNING + VALUE(ov_link) TYPE REF TO ycl_ecb_hyperlink . + CLASS-METHODS create_internal_link + IMPORTING + !iv_location TYPE string + RETURNING + VALUE(ov_link) TYPE REF TO ycl_ecb_hyperlink . + METHODS is_internal + RETURNING + VALUE(ev_ret) TYPE abap_bool . + METHODS set_cell_reference + IMPORTING + !ip_column TYPE simple + !ip_row TYPE yecb_cell_row + RAISING + ycx_ecb . + METHODS get_ref + RETURNING + VALUE(ev_ref) TYPE string . + METHODS get_url + RETURNING + VALUE(ev_url) TYPE string . +*"* protected components of class ZCL_EXCEL_HYPERLINK +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_HYPERLINK +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA location TYPE string . + DATA cell_reference TYPE string . + DATA internal TYPE abap_bool . + DATA column TYPE yecb_cell_column_alpha . + DATA row TYPE yecb_cell_row . + + CLASS-METHODS create + IMPORTING + !iv_url TYPE string + !iv_internal TYPE abap_bool + RETURNING + VALUE(ov_link) TYPE REF TO ycl_ecb_hyperlink . +ENDCLASS. + + + +CLASS ycl_ecb_hyperlink IMPLEMENTATION. + + + METHOD create. + DATA: lo_hyperlink TYPE REF TO ycl_ecb_hyperlink. + + CREATE OBJECT lo_hyperlink. + + lo_hyperlink->location = iv_url. + lo_hyperlink->internal = iv_internal. + + ov_link = lo_hyperlink. + ENDMETHOD. + + + METHOD create_external_link. + + ov_link = ycl_ecb_hyperlink=>create( iv_url = iv_url + iv_internal = abap_false ). + ENDMETHOD. + + + METHOD create_internal_link. + ov_link = ycl_ecb_hyperlink=>create( iv_url = iv_location + iv_internal = abap_true ). + ENDMETHOD. + + + METHOD get_ref. + ev_ref = row. + CONDENSE ev_ref. + CONCATENATE column ev_ref INTO ev_ref. + ENDMETHOD. + + + METHOD get_url. + ev_url = me->location. + ENDMETHOD. + + + METHOD is_internal. + ev_ret = me->internal. + ENDMETHOD. + + + METHOD set_cell_reference. + me->column = ycl_ecb_common=>convert_column2alpha( ip_column ). " issue #155 - less restrictive typing for ip_column + me->row = ip_row. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_hyperlink.clas.xml b/src/abap2xlsx/ycl_ecb_hyperlink.clas.xml new file mode 100644 index 0000000..d8edee7 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_hyperlink.clas.xml @@ -0,0 +1,108 @@ + + + + + + YCL_ECB_HYPERLINK + E + Hyperlink + 1 + X + X + X + + + + COLUMN + E + Cell Column + + + COLUMN + I + Cell Column + + + CREATE + E + Creates new instance of hyperlink + + + CREATE + I + Creates new instance of hyperlink + + + CREATE_EXTERNAL_LINK + E + Creates new instance of external link (URL) + + + CREATE_EXTERNAL_LINK + I + Creates new instance of external link (URL) + + + CREATE_INTERNAL_LINK + E + Creates new instance of internal link + + + CREATE_INTERNAL_LINK + I + Creates new instance of internal link + + + GET_REF + E + Gets the reference string + + + GET_REF + I + Gets the reference string + + + GET_URL + E + Gets the urls of the link + + + GET_URL + I + Gets the urls of the link + + + IS_INTERNAL + E + Checks if link is pointing to internall location + + + IS_INTERNAL + I + Checks if link is pointing to internall location + + + ROW + E + Cell Row + + + ROW + I + Cell Row + + + SET_CELL_REFERENCE + E + Sets reference to the cell + + + SET_CELL_REFERENCE + I + Sets reference to the cell + + + + + diff --git a/src/abap2xlsx/ycl_ecb_legacy_palette.clas.abap b/src/abap2xlsx/ycl_ecb_legacy_palette.clas.abap new file mode 100644 index 0000000..1995c38 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_legacy_palette.clas.abap @@ -0,0 +1,161 @@ +CLASS ycl_ecb_legacy_palette DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_LEGACY_PALETTE +*"* do not include other source files here!!! + + METHODS constructor . + METHODS is_modified + RETURNING + VALUE(ep_modified) TYPE abap_bool . + METHODS get_color + IMPORTING + !ip_index TYPE i + RETURNING + VALUE(ep_color) TYPE yecb_style_color_argb + RAISING + ycx_ecb . + METHODS get_colors + RETURNING + VALUE(ep_colors) TYPE yecb_t_style_color_argb . + METHODS set_color + IMPORTING + !ip_index TYPE i + !ip_color TYPE yecb_style_color_argb + RAISING + ycx_ecb . + PROTECTED SECTION. +*"* protected components of class ZCL_EXCEL_LEGACY_PALETTE +*"* do not include other source files here!!! + PRIVATE SECTION. + +*"* private components of class ZCL_EXCEL_LEGACY_PALETTE +*"* do not include other source files here!!! + DATA modified TYPE abap_bool VALUE abap_false. "#EC NOTEXT . . . . . . . . . . " . + DATA colors TYPE yecb_t_style_color_argb . +ENDCLASS. + + + +CLASS ycl_ecb_legacy_palette IMPLEMENTATION. + + + METHOD constructor. + " default Excel palette based on + " http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.indexedcolors.aspx + + APPEND '00000000' TO colors. + APPEND '00FFFFFF' TO colors. + APPEND '00FF0000' TO colors. + APPEND '0000FF00' TO colors. + APPEND '000000FF' TO colors. + APPEND '00FFFF00' TO colors. + APPEND '00FF00FF' TO colors. + APPEND '0000FFFF' TO colors. + APPEND '00000000' TO colors. + APPEND '00FFFFFF' TO colors. + + APPEND '00FF0000' TO colors. + APPEND '0000FF00' TO colors. + APPEND '000000FF' TO colors. + APPEND '00FFFF00' TO colors. + APPEND '00FF00FF' TO colors. + APPEND '0000FFFF' TO colors. + APPEND '00800000' TO colors. + APPEND '00008000' TO colors. + APPEND '00000080' TO colors. + APPEND '00808000' TO colors. + + APPEND '00800080' TO colors. + APPEND '00008080' TO colors. + APPEND '00C0C0C0' TO colors. + APPEND '00808080' TO colors. + APPEND '009999FF' TO colors. + APPEND '00993366' TO colors. + APPEND '00FFFFCC' TO colors. + APPEND '00CCFFFF' TO colors. + APPEND '00660066' TO colors. + APPEND '00FF8080' TO colors. + + APPEND '000066CC' TO colors. + APPEND '00CCCCFF' TO colors. + APPEND '00000080' TO colors. + APPEND '00FF00FF' TO colors. + APPEND '00FFFF00' TO colors. + APPEND '0000FFFF' TO colors. + APPEND '00800080' TO colors. + APPEND '00800000' TO colors. + APPEND '00008080' TO colors. + APPEND '000000FF' TO colors. + + APPEND '0000CCFF' TO colors. + APPEND '00CCFFFF' TO colors. + APPEND '00CCFFCC' TO colors. + APPEND '00FFFF99' TO colors. + APPEND '0099CCFF' TO colors. + APPEND '00FF99CC' TO colors. + APPEND '00CC99FF' TO colors. + APPEND '00FFCC99' TO colors. + APPEND '003366FF' TO colors. + APPEND '0033CCCC' TO colors. + + APPEND '0099CC00' TO colors. + APPEND '00FFCC00' TO colors. + APPEND '00FF9900' TO colors. + APPEND '00FF6600' TO colors. + APPEND '00666699' TO colors. + APPEND '00969696' TO colors. + APPEND '00003366' TO colors. + APPEND '00339966' TO colors. + APPEND '00003300' TO colors. + APPEND '00333300' TO colors. + + APPEND '00993300' TO colors. + APPEND '00993366' TO colors. + APPEND '00333399' TO colors. + APPEND '00333333' TO colors. + + ENDMETHOD. + + + METHOD get_color. + DATA: lv_index TYPE i. + + lv_index = ip_index + 1. + READ TABLE colors INTO ep_color INDEX lv_index. + IF sy-subrc <> 0. + ycx_ecb=>raise_text( 'Invalid color index' ). + ENDIF. + ENDMETHOD. + + + METHOD get_colors. + ep_colors = colors. + ENDMETHOD. + + + METHOD is_modified. + ep_modified = modified. + ENDMETHOD. + + + METHOD set_color. + DATA: lv_index TYPE i. + + FIELD-SYMBOLS: LIKE LINE OF colors. + + lv_index = ip_index + 1. + READ TABLE colors ASSIGNING INDEX lv_index. + IF sy-subrc <> 0. + ycx_ecb=>raise_text( 'Invalid color index' ). + ENDIF. + + IF <> ip_color. + modified = abap_true. + = ip_color. + ENDIF. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_legacy_palette.clas.xml b/src/abap2xlsx/ycl_ecb_legacy_palette.clas.xml new file mode 100644 index 0000000..ef6959f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_legacy_palette.clas.xml @@ -0,0 +1,78 @@ + + + + + + YCL_ECB_LEGACY_PALETTE + E + Excel legacy color palette + 1 + X + X + X + + + + COLORS + E + Table of RGB colors + + + COLORS + I + Table of RGB colors + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + GET_COLOR + E + Get color + + + GET_COLOR + I + Get color + + + GET_COLORS + E + Get all colors + + + GET_COLORS + I + Get all colors + + + IS_MODIFIED + E + Is the palette modified from standard? + + + IS_MODIFIED + I + Is the palette modified from standard? + + + SET_COLOR + E + Set (replace) color + + + SET_COLOR + I + Set (replace) color + + + + + diff --git a/src/abap2xlsx/ycl_ecb_obsolete_func_wrap.clas.abap b/src/abap2xlsx/ycl_ecb_obsolete_func_wrap.clas.abap new file mode 100644 index 0000000..462d622 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_obsolete_func_wrap.clas.abap @@ -0,0 +1,38 @@ +CLASS ycl_ecb_obsolete_func_wrap DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + + CLASS-METHODS guid_create + RETURNING + VALUE(rv_guid_16) TYPE yecb_guid . + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_obsolete_func_wrap IMPLEMENTATION. + + + METHOD guid_create. + + TRY. + rv_guid_16 = cl_system_uuid=>if_system_uuid_static~create_uuid_x16( ). + CATCH cx_uuid_error. + ENDTRY. + +*--------------------------------------------------------------------* +* If you are on a release that does not yet have the class cl_system_uuid +* please use the following coding instead which is using the function +* call that was used before but which has been flagged as obsolete +* in newer SAP releases +*--------------------------------------------------------------------* +* +*Before ABAP 7.02: CALL FUNCTION 'GUID_CREATE' +*Before ABAP 7.02: IMPORTING +*Before ABAP 7.02: ev_guid_16 = rv_guid_16. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_obsolete_func_wrap.clas.xml b/src/abap2xlsx/ycl_ecb_obsolete_func_wrap.clas.xml new file mode 100644 index 0000000..d448964 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_obsolete_func_wrap.clas.xml @@ -0,0 +1,77 @@ + + + + + + YCL_ECB_OBSOLETE_FUNC_WRAP + E + Wrap obsolete functioncalls + 1 + X + X + X + + + + U1 + &FUNCTIONALITY& + + + AS + Some function are becoming flagged as obsolete in later SAP releases. + + + This class will wrap all functions that we are using in ABAP2XLSX in a + + + static method where we'll use the newer version that SAP suggests + + + / + We'll keep the old function call as a comment in the method - that way + + + anyone installing on an older system may remove the comments to activate + + + the previous coding + + + U1 + &RELATIONS& + + + AS + + + U1 + &EXAMPLE& + + + AS + + + U1 + &HINTS& + + + AS + + + U1 + &FURTHER_SOURCES_OF_INF& + + + AS + + + + + GUID_CREATE + E + Wrapper for obsolete function GUID_CREATE + + + + + diff --git a/src/abap2xlsx/ycl_ecb_ole.clas.abap b/src/abap2xlsx/ycl_ecb_ole.clas.abap new file mode 100644 index 0000000..b06ba9c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_ole.clas.abap @@ -0,0 +1,2091 @@ +CLASS ycl_ecb_ole DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + TYPES ty_doc_url TYPE c LENGTH 255. + + CLASS-METHODS bind_alv_ole2 + IMPORTING + !i_document_url TYPE ty_doc_url DEFAULT space + !i_xls TYPE c DEFAULT space + !i_save_path TYPE string + !io_alv TYPE REF TO cl_gui_alv_grid + !it_listheader TYPE slis_t_listheader OPTIONAL + !i_top TYPE i DEFAULT 1 + !i_left TYPE i DEFAULT 1 + !i_columns_header TYPE c DEFAULT 'X' + !i_columns_autofit TYPE c DEFAULT 'X' + !i_format_col_header TYPE soi_format_item OPTIONAL + !i_format_subtotal TYPE soi_format_item OPTIONAL + !i_format_total TYPE soi_format_item OPTIONAL + EXCEPTIONS + miss_guide + ex_transfer_kkblo_error + fatal_error + inv_data_range + dim_mismatch_vkey + dim_mismatch_sema + error_in_sema . + + PROTECTED SECTION. + PRIVATE SECTION. + + CLASS-METHODS close_document. + CLASS-METHODS error_doi. + + CLASS-DATA: lo_spreadsheet TYPE REF TO i_oi_spreadsheet, + lo_control TYPE REF TO i_oi_container_control, + lo_proxy TYPE REF TO i_oi_document_proxy, + lo_error TYPE REF TO i_oi_error, + lc_retcode TYPE soi_ret_string. + +ENDCLASS. + + + +CLASS ycl_ecb_ole IMPLEMENTATION. + + METHOD bind_alv_ole2. +*--------------------------------------------------------------------* +* Method description: +* Method use to export a CL_GUI_ALV_GRID object to xlsx/xls file +* with list header and characteristics of ALV field catalog such as: +* + Total, group's subtotal +* + Quantity fields, amount fields (dependent fields) +* + No_out, no_zero, ... +* Technique use in method: +* SAP Desktop Office Integration (DOI) +*--------------------------------------------------------------------* + +* Data for session 0: DOI constructor +* ------------------------------------------ + + DATA: li_has TYPE i. "Proxy has spreadsheet interface? + +* Data for session 1: Get LVC data from ALV object +* ------------------------------------------ + + DATA: l_has_activex, + l_doctype_excel_sheet(11) TYPE c. + +* LVC + DATA: lt_fieldcat_lvc TYPE lvc_t_fcat. + DATA: wa_fieldcat_lvc TYPE lvc_s_fcat. + DATA: lt_sort_lvc TYPE lvc_t_sort. + DATA: lt_filter_idx_lvc TYPE lvc_t_fidx. + DATA: lt_grouplevels_lvc TYPE lvc_t_grpl. + +* KKBLO + DATA: lt_fieldcat_kkblo TYPE kkblo_t_fieldcat. + DATA: lt_sort_kkblo TYPE kkblo_t_sortinfo. + DATA: lt_grouplevels_kkblo TYPE kkblo_t_grouplevels. + DATA: lt_filter_idx_kkblo TYPE kkblo_t_sfinfo. + DATA: wa_listheader LIKE LINE OF it_listheader. + +* Subtotal + DATA: lt_collect00 TYPE REF TO data. + DATA: lt_collect01 TYPE REF TO data. + DATA: lt_collect02 TYPE REF TO data. + DATA: lt_collect03 TYPE REF TO data. + DATA: lt_collect04 TYPE REF TO data. + DATA: lt_collect05 TYPE REF TO data. + DATA: lt_collect06 TYPE REF TO data. + DATA: lt_collect07 TYPE REF TO data. + DATA: lt_collect08 TYPE REF TO data. + DATA: lt_collect09 TYPE REF TO data. + +* data table name + DATA: l_tabname TYPE kkblo_tabname. + +* local object + DATA: lo_grid TYPE REF TO lcl_gui_alv_grid. + +* data table get from ALV + DATA: lt_alv TYPE REF TO data. + +* total / subtotal data + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + +* table before append subtotal lines + FIELD-SYMBOLS: TYPE STANDARD TABLE. + +* data for session 2: sort, filter and calculate total/subtotal +* ------------------------------------------ + +* table to save index of subotal / total line in excel tanle +* this ideal to control index of subtotal / total line later +* for ex, when get subtotal / total line to format + TYPES: BEGIN OF st_subtot_indexs, + index TYPE i, + END OF st_subtot_indexs. + DATA: lt_subtot_indexs TYPE TABLE OF st_subtot_indexs. + DATA: wa_subtot_indexs LIKE LINE OF lt_subtot_indexs. + +* data table after append subtotal + DATA: lt_excel TYPE REF TO data. + + DATA: l_tabix TYPE i. + DATA: l_save_index TYPE i. + +* dyn subtotal table name + DATA: l_collect TYPE string. + +* subtotal range, to format subtotal (and total) + DATA: subranges TYPE soi_range_list. + DATA: subrangeitem TYPE soi_range_item. + DATA: l_sub_index TYPE i. + + +* table after append subtotal lines + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE any. + +* dyn subtotal tables + FIELD-SYMBOLS: TYPE STANDARD TABLE. + FIELD-SYMBOLS: TYPE any. + + FIELD-SYMBOLS: LIKE LINE OF lt_filter_idx_kkblo. + FIELD-SYMBOLS: LIKE LINE OF lt_fieldcat_kkblo. + FIELD-SYMBOLS: LIKE LINE OF lt_grouplevels_kkblo. + FIELD-SYMBOLS: TYPE any. + +* Data for session 3: map data to semantic table +* ------------------------------------------ + + TYPES: BEGIN OF st_column_index, + fieldname TYPE kkblo_fieldname, + tabname TYPE kkblo_tabname, + col LIKE sy-index, + END OF st_column_index. + +* columns index + DATA: lt_column_index TYPE TABLE OF st_column_index. + DATA: wa_column_index LIKE LINE OF lt_column_index. + +* table of dependent field ( currency and quantity unit field) + DATA: lt_fieldcat_depf TYPE kkblo_t_fieldcat. + DATA: wa_fieldcat_depf TYPE kkblo_fieldcat. + +* XXL interface: +* -XXL: contain exporting columns characteristic + DATA: lt_sema TYPE TABLE OF gxxlt_s INITIAL SIZE 0. + DATA: wa_sema LIKE LINE OF lt_sema. + +* -XXL interface: header + DATA: lt_hkey TYPE TABLE OF gxxlt_h INITIAL SIZE 0. + DATA: wa_hkey LIKE LINE OF lt_hkey. + +* -XXL interface: header keys + DATA: lt_vkey TYPE TABLE OF gxxlt_v INITIAL SIZE 0. + DATA: wa_vkey LIKE LINE OF lt_vkey. + +* Number of H Keys: number of key columns + DATA: l_n_hrz_keys TYPE i. +* Number of data columns in the list object: non-key columns no + DATA: l_n_att_cols TYPE i. +* Number of V Keys: number of header row + DATA: l_n_vrt_keys TYPE i. + +* curency to format amount + DATA: lt_tcurx TYPE TABLE OF tcurx. + DATA: wa_tcurx LIKE LINE OF lt_tcurx. + DATA: l_def TYPE flag. " currency / quantity flag + DATA: wa_t006 TYPE t006. " decimal place of unit + + DATA: l_num TYPE i. " table columns number + DATA: l_typ TYPE c. " table type + DATA: wa TYPE REF TO data. + DATA: l_int TYPE i. + DATA: l_counter TYPE i. + + FIELD-SYMBOLS: TYPE any. + FIELD-SYMBOLS: TYPE any. + +* Data for session 4: write to excel +* ------------------------------------------ + + DATA: sema_type TYPE c. + + DATA l_error TYPE REF TO c_oi_proxy_error. + DATA count TYPE i. + DATA datac TYPE i. + DATA datareal TYPE i. " exporting column number + DATA vkeycount TYPE i. + DATA all TYPE i. + DATA mit TYPE i VALUE 1. " index of recent row? + DATA li_col_pos TYPE i VALUE 1. " column position + DATA li_col_num TYPE i. " table columns number + FIELD-SYMBOLS: TYPE any. + FIELD-SYMBOLS: TYPE any. + + DATA td TYPE sydes_desc. + + DATA: typ. + DATA: ranges TYPE soi_range_list. + DATA: rangeitem TYPE soi_range_item. + DATA: contents TYPE soi_generic_table. + DATA: contentsitem TYPE soi_generic_item. + DATA: semaitem TYPE gxxlt_s. + DATA: hkeyitem TYPE gxxlt_h. + DATA: vkeyitem TYPE gxxlt_v. + DATA: li_commentary_rows TYPE i. "row number of title lines + 1 + DATA: lo_error_w TYPE REF TO i_oi_error. + DATA: l_retcode TYPE soi_ret_string. + DATA: no_flush TYPE c VALUE 'X'. + DATA: li_head_top TYPE i. "header rows position + +* Data for session 5: Save and clode document +* ------------------------------------------ + + DATA: li_document_size TYPE i. + DATA: ls_path TYPE rlgrap-filename. + +*--------------------------------------------------------------------* +* SESSION 0: DOI CONSTRUCTOR +*--------------------------------------------------------------------* + +* check active windown + + CALL FUNCTION 'GUI_HAS_ACTIVEX' + IMPORTING + return = l_has_activex. + + IF l_has_activex IS INITIAL. + RAISE miss_guide. + ENDIF. + +* Get Container Object of Screen + + CALL METHOD c_oi_container_control_creator=>get_container_control + IMPORTING + control = lo_control + retcode = lc_retcode. + + error_doi( ). + +* Initialize Container control + + CALL METHOD lo_control->init_control + EXPORTING + parent = cl_gui_container=>default_screen + r3_application_name = '' + inplace_enabled = 'X' + no_flush = 'X' + register_on_close_event = 'X' + register_on_custom_event = 'X' + IMPORTING + error = lo_error + retcode = lc_retcode. + + error_doi( ). + +* Get Proxy Document: +* check exist of document proxy, if exist -> close first + + IF NOT lo_proxy IS INITIAL. + close_document( ). + ENDIF. + + IF i_xls IS NOT INITIAL. +* xls format, doctype = soi_doctype_excel97_sheet + l_doctype_excel_sheet = 'Excel.Sheet.8'. + ELSE. +* xlsx format, doctype = soi_doctype_excel_sheet + l_doctype_excel_sheet = 'Excel.Sheet'. + ENDIF. + + CALL METHOD lo_control->get_document_proxy + EXPORTING + document_type = l_doctype_excel_sheet + register_container = 'X' + IMPORTING + document_proxy = lo_proxy + error = lo_error + retcode = lc_retcode. + + error_doi( ). + + IF i_document_url IS INITIAL. + +* create new excel document + + CALL METHOD lo_proxy->create_document + EXPORTING + create_view_data = 'X' + open_inplace = 'X' + no_flush = 'X' + IMPORTING + error = lo_error + retcode = lc_retcode. + + error_doi( ). + + ELSE. + +* Read excel template for i_DOCUMENT_URL +* this excel template can be store in local or server + + CALL METHOD lo_proxy->open_document + EXPORTING + document_url = i_document_url + open_inplace = 'X' + no_flush = 'X' + IMPORTING + error = lo_error + retcode = lc_retcode. + + error_doi( ). + + ENDIF. + +* Check Spreadsheet Interface of Document Proxy + + CALL METHOD lo_proxy->has_spreadsheet_interface + IMPORTING + is_available = li_has + error = lo_error + retcode = lc_retcode. + + error_doi( ). + +* create Spreadsheet object + + CHECK li_has IS NOT INITIAL. + + CALL METHOD lo_proxy->get_spreadsheet_interface + IMPORTING + sheet_interface = lo_spreadsheet + error = lo_error + retcode = lc_retcode. + + error_doi( ). + +*--------------------------------------------------------------------* +* SESSION 1: GET LVC DATA FROM ALV OBJECT +*--------------------------------------------------------------------* + +* data table + + CREATE OBJECT lo_grid + EXPORTING + i_parent = cl_gui_container=>screen0. + + CALL METHOD lo_grid->get_alv_attributes + EXPORTING + io_grid = io_alv + IMPORTING + et_table = lt_alv. + + ASSIGN lt_alv->* TO . + +* fieldcat + + CALL METHOD io_alv->get_frontend_fieldcatalog + IMPORTING + et_fieldcatalog = lt_fieldcat_lvc. + +* table name + + LOOP AT lt_fieldcat_lvc INTO wa_fieldcat_lvc + WHERE NOT tabname IS INITIAL. + l_tabname = wa_fieldcat_lvc-tabname. + EXIT. + ENDLOOP. + + IF sy-subrc NE 0. + l_tabname = '1'. + ENDIF. + CLEAR: wa_fieldcat_lvc. + +* sort table + + CALL METHOD io_alv->get_sort_criteria + IMPORTING + et_sort = lt_sort_lvc. + + +* filter index + + CALL METHOD io_alv->get_filtered_entries + IMPORTING + et_filtered_entries = lt_filter_idx_lvc. + +* group level + subtotal + + CALL METHOD io_alv->get_subtotals + IMPORTING + ep_collect00 = lt_collect00 + ep_collect01 = lt_collect01 + ep_collect02 = lt_collect02 + ep_collect03 = lt_collect03 + ep_collect04 = lt_collect04 + ep_collect05 = lt_collect05 + ep_collect06 = lt_collect06 + ep_collect07 = lt_collect07 + ep_collect08 = lt_collect08 + ep_collect09 = lt_collect09 + et_grouplevels = lt_grouplevels_lvc. + + ASSIGN lt_collect00->* TO . + ASSIGN lt_collect01->* TO . + ASSIGN lt_collect02->* TO . + ASSIGN lt_collect03->* TO . + ASSIGN lt_collect04->* TO . + ASSIGN lt_collect05->* TO . + ASSIGN lt_collect06->* TO . + ASSIGN lt_collect07->* TO . + ASSIGN lt_collect08->* TO . + ASSIGN lt_collect09->* TO . + +* transfer to KKBLO struct + + CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO' + EXPORTING + it_fieldcat_lvc = lt_fieldcat_lvc + it_sort_lvc = lt_sort_lvc + it_filter_index_lvc = lt_filter_idx_lvc + it_grouplevels_lvc = lt_grouplevels_lvc + IMPORTING + et_fieldcat_kkblo = lt_fieldcat_kkblo + et_sort_kkblo = lt_sort_kkblo + et_filtered_entries_kkblo = lt_filter_idx_kkblo + et_grouplevels_kkblo = lt_grouplevels_kkblo + TABLES + it_data = + EXCEPTIONS + it_data_missing = 1 + it_fieldcat_lvc_missing = 2 + OTHERS = 3. + IF sy-subrc <> 0. + RAISE ex_transfer_kkblo_error. + ENDIF. + + CLEAR: + wa_fieldcat_lvc, + lt_fieldcat_lvc, + lt_sort_lvc, + lt_filter_idx_lvc, + lt_grouplevels_lvc. + + CLEAR: + lo_grid. + + +*--------------------------------------------------------------------* +* SESSION 2: SORT, FILTER AND CALCULATE TOTAL / SUBTOTAL +*--------------------------------------------------------------------* + +* append subtotal & total line + + CREATE DATA lt_excel LIKE . + ASSIGN lt_excel->* TO . + + LOOP AT ASSIGNING . + l_save_index = sy-tabix. + +* filter base on filter index table + + READ TABLE lt_filter_idx_kkblo ASSIGNING + WITH KEY index = l_save_index + BINARY SEARCH. + IF sy-subrc NE 0. + APPEND TO . + ENDIF. + +* append subtotal lines + + READ TABLE lt_grouplevels_kkblo ASSIGNING + WITH KEY index_to = l_save_index + BINARY SEARCH. + IF sy-subrc = 0. + l_tabix = sy-tabix. + DO. + IF -subtot EQ 'X' AND + -hide_level IS INITIAL AND + -cindex_from NE 0. + +* dynamic append subtotal line to excel table base on grouplevel table +* ex -level = 1 +* then = '' + + l_collect = -level. + CONDENSE l_collect. + CONCATENATE '' +* '->*' + INTO l_collect. + + ASSIGN (l_collect) TO . + +* incase there're more than 1 total line of group, at the same level +* for example: subtotal of multi currency + + LOOP AT ASSIGNING . + IF sy-tabix BETWEEN -cindex_from + AND -cindex_to. + + + APPEND TO . + +* save subtotal lines index + + wa_subtot_indexs-index = sy-tabix. + APPEND wa_subtot_indexs TO lt_subtot_indexs. + +* append sub total ranges table for format later + + ADD 1 TO l_sub_index. + subrangeitem-name = l_sub_index. + CONDENSE subrangeitem-name. + CONCATENATE 'SUBTOT' + subrangeitem-name + INTO subrangeitem-name. + + subrangeitem-rows = wa_subtot_indexs-index. + subrangeitem-columns = 1. " start col + APPEND subrangeitem TO subranges. + CLEAR: subrangeitem. + + ENDIF. + ENDLOOP. + UNASSIGN: . + UNASSIGN: . + CLEAR: l_collect. + ENDIF. + +* check next subtotal level of group + + UNASSIGN: . + ADD 1 TO l_tabix. + + READ TABLE lt_grouplevels_kkblo ASSIGNING + INDEX l_tabix. + IF sy-subrc NE 0 + OR -index_to NE l_save_index. + EXIT. + ENDIF. + + UNASSIGN: + , + . + + ENDDO. + ENDIF. + + CLEAR: + l_tabix, + l_save_index. + + UNASSIGN: + , + . + + ENDLOOP. + +* free local data + + UNASSIGN: + , + , + , + . + +* append grand total line + + IF IS ASSIGNED. + ASSIGN TO . + IF IS NOT INITIAL. + LOOP AT ASSIGNING . + + APPEND TO . + +* save total line index + + wa_subtot_indexs-index = sy-tabix. + APPEND wa_subtot_indexs TO lt_subtot_indexs. + +* append grand total range (to format) + + ADD 1 TO l_sub_index. + subrangeitem-name = l_sub_index. + CONDENSE subrangeitem-name. + CONCATENATE 'TOTAL' + subrangeitem-name + INTO subrangeitem-name. + + subrangeitem-rows = wa_subtot_indexs-index. + subrangeitem-columns = 1. " start col + APPEND subrangeitem TO subranges. + ENDLOOP. + ENDIF. + ENDIF. + + CLEAR: + subrangeitem, + lt_sort_kkblo, + , + , + , + , + , + , + , + , + , + . + + UNASSIGN: + , + , + , + , + , + , + , + , + , + , + , + . + +*--------------------------------------------------------------------* +* SESSION 3: MAP DATA TO SEMANTIC TABLE +*--------------------------------------------------------------------* + +* get dependent field field: currency and quantity + + CREATE DATA wa LIKE LINE OF . + ASSIGN wa->* TO . + + DESCRIBE FIELD TYPE l_typ COMPONENTS l_num. + + DO l_num TIMES. + l_save_index = sy-index. + ASSIGN COMPONENT l_save_index OF STRUCTURE + TO . + IF sy-subrc NE 0. + MESSAGE e801(yecb) WITH 'FATAL ERROR' RAISING fatal_error. + ENDIF. + + LOOP AT lt_fieldcat_kkblo ASSIGNING + WHERE tabname = l_tabname. + ASSIGN COMPONENT -fieldname + OF STRUCTURE TO . + + DESCRIBE DISTANCE BETWEEN AND + INTO l_int IN BYTE MODE. + +* append column index +* this columns index is of table, not fieldcat + + IF l_int = 0. + wa_column_index-fieldname = -fieldname. + wa_column_index-tabname = -tabname. + wa_column_index-col = l_save_index. + APPEND wa_column_index TO lt_column_index. + ENDIF. + +* append dependent fields (currency and quantity unit) + + IF -cfieldname IS NOT INITIAL. + CLEAR wa_fieldcat_depf. + wa_fieldcat_depf-fieldname = -cfieldname. + wa_fieldcat_depf-tabname = -ctabname. + COLLECT wa_fieldcat_depf INTO lt_fieldcat_depf. + ENDIF. + + IF -qfieldname IS NOT INITIAL. + CLEAR wa_fieldcat_depf. + wa_fieldcat_depf-fieldname = -qfieldname. + wa_fieldcat_depf-tabname = -qtabname. + COLLECT wa_fieldcat_depf INTO lt_fieldcat_depf. + ENDIF. + +* rewrite field data type + + IF -inttype = 'X' + AND -datatype(3) = 'INT'. + -inttype = 'I'. + ENDIF. + + ENDLOOP. + + CLEAR: l_save_index. + UNASSIGN: . + + ENDDO. + +* build semantic tables + + l_n_hrz_keys = 1. + +* Get keyfigures + + LOOP AT lt_fieldcat_kkblo ASSIGNING + WHERE tabname = l_tabname + AND tech NE 'X' + AND no_out NE 'X'. + + CLEAR wa_sema. + CLEAR wa_hkey. + +* Units belong to keyfigures -> display as str + + READ TABLE lt_fieldcat_depf INTO wa_fieldcat_depf WITH KEY + fieldname = -fieldname + tabname = -tabname. + + IF sy-subrc = 0. + wa_sema-col_typ = 'STR'. + wa_sema-col_ops = 'DFT'. + +* Keyfigures + + ELSE. + CASE -datatype. + WHEN 'QUAN'. + wa_sema-col_typ = 'N03'. + + IF -no_sum NE 'X'. + wa_sema-col_ops = 'ADD'. + ELSE. + wa_sema-col_ops = 'NOP'. " no dependent field + ENDIF. + + WHEN 'DATS'. + wa_sema-col_typ = 'DAT'. + wa_sema-col_ops = 'NOP'. + + WHEN 'CHAR' OR 'UNIT' OR 'CUKY'. " Added fieldformats UNIT and CUKY - dd. 26-10-2012 Wouter Heuvelmans + wa_sema-col_typ = 'STR'. + wa_sema-col_ops = 'DFT'. " dependent field + +* incase numeric, ex '00120' -> display as '12' + + WHEN 'NUMC'. + wa_sema-col_typ = 'STR'. + wa_sema-col_ops = 'DFT'. + + WHEN OTHERS. + wa_sema-col_typ = 'NUM'. + + IF -no_sum NE 'X'. + wa_sema-col_ops = 'ADD'. + ELSE. + wa_sema-col_ops = 'NOP'. + ENDIF. + ENDCASE. + ENDIF. + + l_counter = l_counter + 1. + l_n_att_cols = l_n_att_cols + 1. + + wa_sema-col_no = l_counter. + + READ TABLE lt_column_index INTO wa_column_index WITH KEY + fieldname = -fieldname + tabname = -tabname. + + IF sy-subrc = 0. + wa_sema-col_src = wa_column_index-col. + ELSE. + RAISE fatal_error. + ENDIF. + +* columns index of ref currency field in table + + IF NOT -cfieldname IS INITIAL. + READ TABLE lt_column_index INTO wa_column_index WITH KEY + fieldname = -cfieldname + tabname = -ctabname. + + IF sy-subrc = 0. + wa_sema-col_cur = wa_column_index-col. + ENDIF. + +* quantities fields +* treat as currency when display on excel + + ELSEIF NOT -qfieldname IS INITIAL. + READ TABLE lt_column_index INTO wa_column_index WITH KEY + fieldname = -qfieldname + tabname = -qtabname. + IF sy-subrc = 0. + wa_sema-col_cur = wa_column_index-col. + ENDIF. + + ENDIF. + +* Treat of fixed currency in the fieldcatalog for column + + DATA: l_num_help(2) TYPE n. + + IF NOT -currency IS INITIAL. + + SELECT * FROM tcurx INTO TABLE lt_tcurx. + SORT lt_tcurx. + READ TABLE lt_tcurx INTO wa_tcurx + WITH KEY currkey = -currency. + IF sy-subrc = 0. + l_num_help = wa_tcurx-currdec. + CONCATENATE 'N' l_num_help INTO wa_sema-col_typ. + wa_sema-col_cur = sy-tabix * ( -1 ). + ENDIF. + + ENDIF. + + wa_hkey-col_no = l_n_att_cols. + wa_hkey-row_no = l_n_hrz_keys. + wa_hkey-col_name = -reptext. + APPEND wa_hkey TO lt_hkey. + APPEND wa_sema TO lt_sema. + + ENDLOOP. + +* free local data + + CLEAR: + lt_column_index, + wa_column_index, + lt_fieldcat_depf, + wa_fieldcat_depf, + lt_tcurx, + wa_tcurx, + l_num, + l_typ, + wa, + l_int, + l_counter. + + UNASSIGN: + , + , + , + . + +*--------------------------------------------------------------------* +* SESSION 4: WRITE TO EXCEL +*--------------------------------------------------------------------* + + CLEAR wa_tcurx. + CLEAR lt_tcurx. + +* if spreadsheet dun have proxy yet + + IF li_has IS INITIAL. + l_retcode = c_oi_errors=>ret_interface_not_supported. + CALL METHOD c_oi_errors=>create_error_for_retcode + EXPORTING + retcode = l_retcode + no_flush = no_flush + IMPORTING + error = lo_error_w. + RETURN. + ENDIF. + + CREATE OBJECT l_error + EXPORTING + object_name = 'OLE_DOCUMENT_PROXY' + method_name = 'get_ranges_names'. + + CALL METHOD c_oi_errors=>add_error + EXPORTING + error = l_error. + + + DESCRIBE TABLE lt_sema LINES datareal. + DESCRIBE TABLE LINES datac. + DESCRIBE TABLE lt_vkey LINES vkeycount. + + IF datac = 0. + RAISE inv_data_range. + ENDIF. + + + IF vkeycount NE l_n_vrt_keys. + RAISE dim_mismatch_vkey. + ENDIF. + + all = l_n_vrt_keys + l_n_att_cols. + + IF datareal NE all. + RAISE dim_mismatch_sema. + ENDIF. + + DATA: decimal TYPE c. + +* get decimal separator format ('.', ',', ...) in Office config + + CALL METHOD lo_proxy->get_application_property + EXPORTING + property_name = 'INTERNATIONAL' + subproperty_name = 'DECIMAL_SEPARATOR' + CHANGING + retvalue = decimal. + + DATA date_format TYPE usr01-datfm. + SELECT SINGLE datfm FROM usr01 INTO date_format WHERE bname = sy-uname. + + DATA: comma_elim(4) TYPE c. + FIELD-SYMBOLS TYPE any. + DATA search_item(4) VALUE ' #'. + + CONCATENATE ',' decimal '.' decimal INTO comma_elim. + + DATA help TYPE i. " table (with subtotal) line number + + help = datac. + + DATA: rowmax TYPE i VALUE 1. " header row number + DATA: columnmax TYPE i VALUE 0. " header columns number + + LOOP AT lt_hkey INTO hkeyitem. + IF hkeyitem-col_no > columnmax. + columnmax = hkeyitem-col_no. + ENDIF. + + IF hkeyitem-row_no > rowmax. + rowmax = hkeyitem-row_no. + ENDIF. + ENDLOOP. + + DATA: hkeycolumns TYPE i. " header columns no + + hkeycolumns = columnmax. + + IF hkeycolumns < l_n_att_cols. + hkeycolumns = l_n_att_cols. + ENDIF. + + columnmax = 0. + + LOOP AT lt_vkey INTO vkeyitem. + IF vkeyitem-col_no > columnmax. + columnmax = vkeyitem-col_no. + ENDIF. + ENDLOOP. + + DATA overflow TYPE i VALUE 1. + DATA testname(10) TYPE c. + DATA temp2 TYPE i. " 1st item row position in excel + DATA realmit TYPE i VALUE 1. + DATA realoverflow TYPE i VALUE 1. " row index in content + + CALL METHOD lo_spreadsheet->screen_update + EXPORTING + updating = ''. + + CALL METHOD lo_spreadsheet->load_lib. + + DATA: str(40) TYPE c. " range names of columns range (w/o col header) + DATA: rows TYPE i. " row postion of 1st item line in ecxel + +* calculate row position of data table + + DESCRIBE TABLE it_listheader LINES li_commentary_rows. + +* if grid had title, add 1 empy line between title and table + + IF li_commentary_rows NE 0. + ADD 1 TO li_commentary_rows. + ENDIF. + +* add top position of block data + + li_commentary_rows = li_commentary_rows + i_top - 1. + +* write header (commentary rows) + + DATA: li_commentary_row_index TYPE i VALUE 1. + DATA: li_content_index TYPE i VALUE 1. + DATA: ls_index(10) TYPE c. + DATA ls_commentary_range(40) TYPE c VALUE 'TITLE'. + DATA: li_font_bold TYPE i. + DATA: li_font_italic TYPE i. + DATA: li_font_size TYPE i. + + LOOP AT it_listheader INTO wa_listheader. + li_commentary_row_index = i_top + li_content_index - 1. + ls_index = li_content_index. + CONDENSE ls_index. + CONCATENATE ls_commentary_range(5) ls_index + INTO ls_commentary_range. + CONDENSE ls_commentary_range. + +* insert title range + + CALL METHOD lo_spreadsheet->insert_range_dim + EXPORTING + name = ls_commentary_range + top = li_commentary_row_index + left = i_left + rows = 1 + columns = 1 + no_flush = no_flush. + +* format range + + CASE wa_listheader-typ. + WHEN 'H'. "title + li_font_size = 16. + li_font_bold = 1. + li_font_italic = -1. + WHEN 'S'. "subtile + li_font_size = -1. + li_font_bold = 1. + li_font_italic = -1. + WHEN OTHERS. "'A' comment + li_font_size = -1. + li_font_bold = -1. + li_font_italic = 1. + ENDCASE. + + CALL METHOD lo_spreadsheet->set_font + EXPORTING + rangename = ls_commentary_range + family = '' + size = li_font_size + bold = li_font_bold + italic = li_font_italic + align = 0 + no_flush = no_flush. + +* title: range content + + rangeitem-name = ls_commentary_range. + rangeitem-columns = 1. + rangeitem-rows = 1. + APPEND rangeitem TO ranges. + + contentsitem-row = li_content_index. + contentsitem-column = 1. + CONCATENATE wa_listheader-key + wa_listheader-info + INTO contentsitem-value + SEPARATED BY space. + CONDENSE contentsitem-value. + APPEND contentsitem TO contents. + + ADD 1 TO li_content_index. + + CLEAR: + rangeitem, + contentsitem, + ls_index. + + ENDLOOP. + +* set range data title + + CALL METHOD lo_spreadsheet->set_ranges_data + EXPORTING + ranges = ranges + contents = contents + no_flush = no_flush. + + CLEAR: ranges, contents. + + rows = rowmax + li_commentary_rows + 1. + + all = date_format. + all = all + 3. + + LOOP AT lt_sema INTO semaitem. + IF semaitem-col_typ = 'DAT' OR semaitem-col_typ = 'MON' OR + semaitem-col_typ = 'N00' OR semaitem-col_typ = 'N01' OR + semaitem-col_typ = 'N02' OR + semaitem-col_typ = 'N03' OR semaitem-col_typ = 'PCT' OR + semaitem-col_typ = 'STR' OR semaitem-col_typ = 'NUM'. + CLEAR str. + str = semaitem-col_no. + CONDENSE str. + CONCATENATE 'DATA' str INTO str. + mit = semaitem-col_no. + li_col_pos = semaitem-col_no + i_left - 1. + +* range from data1 to data(n), for each columns of table + + CALL METHOD lo_spreadsheet->insert_range_dim + EXPORTING + name = str + top = rows + left = li_col_pos + rows = help + columns = 1 + no_flush = no_flush. + + DATA dec TYPE i VALUE -1. + DATA typeinfo TYPE sydes_typeinfo. + LOOP AT ASSIGNING . + ASSIGN COMPONENT semaitem-col_no OF STRUCTURE TO . + DESCRIBE FIELD INTO td. + READ TABLE td-types INDEX 1 INTO typeinfo. + IF typeinfo-type = 'P'. + dec = typeinfo-decimals. + ELSEIF typeinfo-type = 'I'. + dec = 0. + ENDIF. + + DESCRIBE FIELD TYPE typ COMPONENTS count. + mit = 1. + DO count TIMES. + IF mit = semaitem-col_src. + ASSIGN COMPONENT sy-index OF STRUCTURE TO . + DESCRIBE FIELD INTO td. + READ TABLE td-types INDEX 1 INTO typeinfo. + IF typeinfo-type = 'P'. + dec = typeinfo-decimals. + ENDIF. + EXIT. + ENDIF. + mit = mit + 1. + ENDDO. + EXIT. + ENDLOOP. + +* format for each columns of table (w/o columns headers) + + IF semaitem-col_typ = 'DAT'. + IF semaitem-col_no > vkeycount. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = all + no_flush = no_flush. + ELSE. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 0 + no_flush = no_flush. + ENDIF. + ELSEIF semaitem-col_typ = 'STR'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 0 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'MON'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 10 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'N00'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = 0 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'N01'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = 1 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'N02'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = 2 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'N03'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = 3 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'N04'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = 4 + no_flush = no_flush. + ELSEIF semaitem-col_typ = 'NUM'. + IF dec EQ -1. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = 2 + no_flush = no_flush. + ELSE. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 1 + decimals = dec + no_flush = no_flush. + ENDIF. + ELSEIF semaitem-col_typ = 'PCT'. + CALL METHOD lo_spreadsheet->set_format + EXPORTING + rangename = str + currency = '' + typ = 3 + decimals = 0 + no_flush = no_flush. + ENDIF. + + ENDIF. + ENDLOOP. + +* get item contents for set_range_data method +* get currency cell also + + mit = 1. + + DATA: currcells TYPE soi_cell_table. + DATA: curritem TYPE soi_cell_item. + + curritem-rows = 1. + curritem-columns = 1. + curritem-front = -1. + curritem-back = -1. + curritem-font = ''. + curritem-size = -1. + curritem-bold = -1. + curritem-italic = -1. + curritem-align = -1. + curritem-frametyp = -1. + curritem-framecolor = -1. + curritem-currency = ''. + curritem-number = 1. + curritem-input = -1. + + DATA: const TYPE i. + +* Change for Correction request +* Initial 10000 lines are missing in Excel Export +* if there are only 2 columns in exported List object. + + IF datareal GT 2. + const = 20000 / datareal. + ELSE. + const = 20000 / ( datareal + 2 ). + ENDIF. + + DATA: lines TYPE i. + DATA: innerlines TYPE i. + DATA: counter TYPE i. + DATA: curritem2 LIKE curritem. + DATA: curritem3 LIKE curritem. + DATA: length TYPE i. + DATA: found. + +* append content table (for method set_range_content) + + LOOP AT ASSIGNING . + +* save line index to compare with lt_subtot_indexs, +* to discover line is a subtotal / totale line or not +* ex use to set 'dun display zero in subtotal / total line' + + l_save_index = sy-tabix. + + DO datareal TIMES. + READ TABLE lt_sema INTO semaitem WITH KEY col_no = sy-index. + IF semaitem-col_src NE 0. + ASSIGN COMPONENT semaitem-col_src + OF STRUCTURE TO . + ELSE. + ASSIGN COMPONENT sy-index + OF STRUCTURE TO . + ENDIF. + + contentsitem-row = realoverflow. + + IF sy-subrc = 0. + search_item(3) = semaitem-col_ops. + SEARCH 'ADD#CNT#MIN#MAX#AVG#NOP#DFT#' + FOR search_item. + IF sy-subrc NE 0. + RAISE error_in_sema. + ENDIF. + search_item(3) = semaitem-col_typ. + SEARCH 'NUM#N00#N01#N02#N03#N04#PCT#DAT#MON#STR#' + FOR search_item. + IF sy-subrc NE 0. + RAISE error_in_sema. + ENDIF. + contentsitem-column = sy-index. + IF semaitem-col_typ EQ 'DAT' OR semaitem-col_typ EQ 'MON'. + IF semaitem-col_no > vkeycount. + + " Hinweis 512418 + " EXCEL bezieht Datumsangaben + " auf den 31.12.1899, behandelt + " aber 1900 als ein Schaltjahr + " d.h. ab 1.3.1900 korrekt + " 1.3.1900 als Zahl = 61 + + DATA: genesis TYPE d VALUE '18991230'. + DATA: number_of_days TYPE p. +* change for date in char format & sema_type = X + DATA: temp_date TYPE d. + + IF NOT IS INITIAL AND NOT CO ' ' AND NOT + CO '0'. +* change for date in char format & sema_type = X starts + IF sema_type = 'X'. + DESCRIBE FIELD TYPE typ. + IF typ = 'C'. + temp_date = . + number_of_days = temp_date - genesis. + ELSE. + number_of_days = - genesis. + ENDIF. + ELSE. + number_of_days = - genesis. + ENDIF. +* change for date in char format & sema_type = X ends + IF number_of_days < 61. + number_of_days = number_of_days - 1. + ENDIF. + + SET COUNTRY 'DE'. + WRITE number_of_days TO contentsitem-value + NO-GROUPING + LEFT-JUSTIFIED. + SET COUNTRY space. + TRANSLATE contentsitem-value USING comma_elim. + ELSE. + CLEAR contentsitem-value. + ENDIF. + ELSE. + contentsitem-value = . + ENDIF. + ELSEIF semaitem-col_typ EQ 'NUM' OR + semaitem-col_typ EQ 'N00' OR + semaitem-col_typ EQ 'N01' OR + semaitem-col_typ EQ 'N02' OR + semaitem-col_typ EQ 'N03' OR + semaitem-col_typ EQ 'N04' OR + semaitem-col_typ EQ 'PCT'. + SET COUNTRY 'DE'. + DESCRIBE FIELD TYPE typ. + + IF semaitem-col_cur IS INITIAL. + IF typ NE 'F'. + WRITE TO contentsitem-value NO-GROUPING + NO-SIGN DECIMALS 14. + ELSE. + WRITE TO contentsitem-value NO-GROUPING + NO-SIGN. + ENDIF. + ELSE. +* Treat of fixed curreny for column >>Y9CK007319 + IF semaitem-col_cur < 0. + semaitem-col_cur = semaitem-col_cur * ( -1 ). + SELECT * FROM tcurx INTO TABLE lt_tcurx. + SORT lt_tcurx. + READ TABLE lt_tcurx INTO + wa_tcurx INDEX semaitem-col_cur. + IF sy-subrc = 0. + IF typ NE 'F'. + WRITE TO contentsitem-value NO-GROUPING + CURRENCY wa_tcurx-currkey NO-SIGN DECIMALS 14. + ELSE. + WRITE TO contentsitem-value NO-GROUPING + CURRENCY wa_tcurx-currkey NO-SIGN. + ENDIF. + ENDIF. + ELSE. + ASSIGN COMPONENT semaitem-col_cur + OF STRUCTURE TO . +* mit = index of recent row + curritem-top = rowmax + mit + li_commentary_rows. + + li_col_pos = sy-index + i_left - 1. + curritem-left = li_col_pos. + +* if filed is quantity field (qfieldname ne space) +* or amount field (cfieldname ne space), then format decimal place +* corresponding with config + + CLEAR: l_def. + READ TABLE lt_fieldcat_kkblo ASSIGNING + WITH KEY tabname = l_tabname + tech = space + no_out = space + col_pos = semaitem-col_no. + IF sy-subrc = 0. + IF -cfieldname IS NOT INITIAL. + l_def = 'C'. + ELSE."if -qfieldname is not initial. + l_def = 'Q'. + ENDIF. + ENDIF. + +* if field is amount field +* exporting of amount field base on currency decimal table: TCURX + IF l_def = 'C'. "field is amount field + SELECT SINGLE * FROM tcurx INTO wa_tcurx + WHERE currkey = . +* if amount ref to un-know currency -> default decimal = 2 + IF sy-subrc EQ 0. + curritem-decimals = wa_tcurx-currdec. + ELSE. + curritem-decimals = 2. + ENDIF. + + APPEND curritem TO currcells. + IF typ NE 'F'. + WRITE TO contentsitem-value + CURRENCY + NO-SIGN NO-GROUPING. + ELSE. + WRITE TO contentsitem-value + DECIMALS 14 CURRENCY + NO-SIGN NO-GROUPING. + ENDIF. + +* if field is quantity field +* exporting of quantity field base on quantity decimal table: T006 + + ELSE."if l_def = 'Q'. " field is quantity field + CLEAR: wa_t006. + SELECT SINGLE * FROM t006 INTO wa_t006 + WHERE msehi = . +* if quantity ref to un-know unit-> default decimal = 2 + IF sy-subrc EQ 0. + curritem-decimals = wa_t006-decan. + ELSE. + curritem-decimals = 2. + ENDIF. + APPEND curritem TO currcells. + + WRITE TO contentsitem-value + UNIT + NO-SIGN NO-GROUPING. + CONDENSE contentsitem-value. + + ENDIF. + + ENDIF. "Y9CK007319 + ENDIF. + CONDENSE contentsitem-value. + +* add function fieldcat-no zero display + + LOOP AT lt_fieldcat_kkblo ASSIGNING + WHERE tabname = l_tabname + AND tech NE 'X' + AND no_out NE 'X'. + IF -col_pos = semaitem-col_no. + IF -no_zero = 'X'. + IF = '0'. + CLEAR: contentsitem-value. + ENDIF. + +* dun display zero in total/subtotal line too + + ELSE. + CLEAR: wa_subtot_indexs. + READ TABLE lt_subtot_indexs INTO wa_subtot_indexs + WITH KEY index = l_save_index. + IF sy-subrc = 0 AND = '0'. + CLEAR: contentsitem-value. + ENDIF. + ENDIF. + ENDIF. + ENDLOOP. + UNASSIGN: . + + IF LT 0. + SEARCH contentsitem-value FOR 'E'. + IF sy-fdpos EQ 0. + +* use prefix notation for signed numbers + + TRANSLATE contentsitem-value USING '- '. + CONDENSE contentsitem-value NO-GAPS. + CONCATENATE '-' contentsitem-value + INTO contentsitem-value. + ELSE. + CONCATENATE '-' contentsitem-value + INTO contentsitem-value. + ENDIF. + ENDIF. + SET COUNTRY space. +* Hier wird nur die korrekte Kommaseparatierung gemacht, wenn die +* Zeichen einer +* Zahl enthalten sind. Das ist für Timestamps, die auch ":" enthalten. +* Für die +* darf keine Kommaseparierung stattfinden. +* Changing for correction request - Y6BK041073 + IF contentsitem-value CO '0123456789.,-+E '. + TRANSLATE contentsitem-value USING comma_elim. + ENDIF. + ELSE. + CLEAR contentsitem-value. + +* if type is not numeric -> dun display with zero + IF CO '0123456789.,-+E '. + WRITE TO contentsitem-value NO-ZERO. + + SHIFT contentsitem-value LEFT DELETING LEADING space. + ELSE. + WRITE TO contentsitem-value. + ENDIF. + + ENDIF. + APPEND contentsitem TO contents. + ENDIF. + ENDDO. + + realmit = realmit + 1. + realoverflow = realoverflow + 1. + + mit = mit + 1. +* overflow = current row index in content table + overflow = overflow + 1. + ENDLOOP. + + UNASSIGN: . + +* set item range for set_range_data method + + testname = mit / const. + CONDENSE testname. + + CONCATENATE 'TEST' testname INTO testname. + + realoverflow = realoverflow - 1. + realmit = realmit - 1. + help = realoverflow. + + rangeitem-name = testname. + rangeitem-columns = datareal. + rangeitem-rows = help. + APPEND rangeitem TO ranges. + +* insert item range dim + + temp2 = rowmax + 1 + li_commentary_rows + realmit - realoverflow. + +* items data + + CALL METHOD lo_spreadsheet->insert_range_dim + EXPORTING + name = testname + top = temp2 + left = i_left + rows = help + columns = datareal + no_flush = no_flush. + +* get columns header contents for set_range_data method +* export columns header only if no columns header option = space + + DATA: rowcount TYPE i. + DATA: columncount TYPE i. + + IF i_columns_header = 'X'. + +* append columns header to contents: hkey + + rowcount = 1. + DO rowmax TIMES. + columncount = 1. + DO hkeycolumns TIMES. + LOOP AT lt_hkey INTO hkeyitem WHERE col_no = columncount + AND row_no = rowcount. + ENDLOOP. + IF sy-subrc = 0. + str = hkeyitem-col_name. + contentsitem-value = hkeyitem-col_name. + ELSE. + contentsitem-value = str. + ENDIF. + contentsitem-column = columncount. + contentsitem-row = rowcount. + APPEND contentsitem TO contents. + columncount = columncount + 1. + ENDDO. + rowcount = rowcount + 1. + ENDDO. + +* incase columns header in multiline + + DATA: rowmaxtemp TYPE i. + IF rowmax > 1. + rowmaxtemp = rowmax - 1. + rowcount = 1. + DO rowmaxtemp TIMES. + columncount = 1. + DO columnmax TIMES. + contentsitem-column = columncount. + contentsitem-row = rowcount. + contentsitem-value = ''. + APPEND contentsitem TO contents. + columncount = columncount + 1. + ENDDO. + rowcount = rowcount + 1. + ENDDO. + ENDIF. + +* append columns header to contents: vkey + + columncount = 1. + DO columnmax TIMES. + LOOP AT lt_vkey INTO vkeyitem WHERE col_no = columncount. + ENDLOOP. + contentsitem-value = vkeyitem-col_name. + contentsitem-row = rowmax. + contentsitem-column = columncount. + APPEND contentsitem TO contents. + columncount = columncount + 1. + ENDDO. +*--------------------------------------------------------------------* +* set header range for method set_range_data +* insert header keys range dim + + li_head_top = li_commentary_rows + 1. + li_col_pos = i_left. + +* insert range headers + + IF hkeycolumns NE 0. + rangeitem-name = 'TESTHKEY'. + rangeitem-rows = rowmax. + rangeitem-columns = hkeycolumns. + APPEND rangeitem TO ranges. + CLEAR: rangeitem. + + CALL METHOD lo_spreadsheet->insert_range_dim + EXPORTING + name = 'TESTHKEY' + top = li_head_top + left = li_col_pos + rows = rowmax + columns = hkeycolumns + no_flush = no_flush. + ENDIF. + ENDIF. + +* format for columns header + total + subtotal +* ------------------------------------------ + + help = rowmax + realmit. " table + header lines + + DATA: lt_format TYPE soi_format_table. + DATA: wa_format LIKE LINE OF lt_format. + DATA: wa_format_temp LIKE LINE OF lt_format. + + FIELD-SYMBOLS: TYPE any. + FIELD-SYMBOLS: TYPE any. + +* columns header format + + wa_format-front = -1. + wa_format-back = 15. "grey + wa_format-font = space. + wa_format-size = -1. + wa_format-bold = 1. + wa_format-align = 0. + wa_format-frametyp = -1. + wa_format-framecolor = -1. + +* get column header format from input record +* -> map input format + + IF i_columns_header = 'X'. + wa_format-name = 'TESTHKEY'. + IF i_format_col_header IS NOT INITIAL. + DESCRIBE FIELD i_format_col_header TYPE l_typ COMPONENTS + li_col_num. + DO li_col_num TIMES. + IF sy-index NE 1. " dun map range name + ASSIGN COMPONENT sy-index OF STRUCTURE i_format_col_header + TO . + IF IS NOT INITIAL. + ASSIGN COMPONENT sy-index OF STRUCTURE wa_format TO . + = . + UNASSIGN: . + ENDIF. + UNASSIGN: . + ENDIF. + ENDDO. + + CLEAR: li_col_num. + ENDIF. + + APPEND wa_format TO lt_format. + ENDIF. + +* Zusammenfassen der Spalten mit gleicher Nachkommastellenzahl +* collect vertical cells (col) with the same number of decimal places +* to increase perfomance in currency cell format + + DESCRIBE TABLE currcells LINES lines. + lines = lines - 1. + DO lines TIMES. + DESCRIBE TABLE currcells LINES innerlines. + innerlines = innerlines - 1. + SORT currcells BY left top. + CLEAR found. + DO innerlines TIMES. + READ TABLE currcells INDEX sy-index INTO curritem. + counter = sy-index + 1. + READ TABLE currcells INDEX counter INTO curritem2. + IF curritem-left EQ curritem2-left. + length = curritem-top + curritem-rows. + IF length EQ curritem2-top AND curritem-decimals EQ curritem2-decimals. + curritem3 = curritem. + curritem3-rows = curritem3-rows + curritem2-rows. + curritem-left = -1. + MODIFY currcells INDEX sy-index FROM curritem. + curritem2-left = -1. + MODIFY currcells INDEX counter FROM curritem2. + APPEND curritem3 TO currcells. + found = 'X'. + ENDIF. + ENDIF. + ENDDO. + IF found IS INITIAL. + EXIT. + ENDIF. + DELETE currcells WHERE left = -1. + ENDDO. + +* Zusammenfassen der Zeilen mit gleicher Nachkommastellenzahl +* collect horizontal cells (row) with the same number of decimal places +* to increase perfomance in currency cell format + + DESCRIBE TABLE currcells LINES lines. + lines = lines - 1. + DO lines TIMES. + DESCRIBE TABLE currcells LINES innerlines. + innerlines = innerlines - 1. + SORT currcells BY top left. + CLEAR found. + DO innerlines TIMES. + READ TABLE currcells INDEX sy-index INTO curritem. + counter = sy-index + 1. + READ TABLE currcells INDEX counter INTO curritem2. + IF curritem-top EQ curritem2-top AND curritem-rows EQ + curritem2-rows. + length = curritem-left + curritem-columns. + IF length EQ curritem2-left AND curritem-decimals EQ curritem2-decimals. + curritem3 = curritem. + curritem3-columns = curritem3-columns + curritem2-columns. + curritem-left = -1. + MODIFY currcells INDEX sy-index FROM curritem. + curritem2-left = -1. + MODIFY currcells INDEX counter FROM curritem2. + APPEND curritem3 TO currcells. + found = 'X'. + ENDIF. + ENDIF. + ENDDO. + IF found IS INITIAL. + EXIT. + ENDIF. + DELETE currcells WHERE left = -1. + ENDDO. +* Ende der Zusammenfassung + + +* item data: format for currency cell, corresponding with currency + + CALL METHOD lo_spreadsheet->cell_format + EXPORTING + cells = currcells + no_flush = no_flush. + +* item data: write item table content + + CALL METHOD lo_spreadsheet->set_ranges_data + EXPORTING + ranges = ranges + contents = contents + no_flush = no_flush. + +* whole table range to format all table + + IF i_columns_header = 'X'. + li_head_top = li_commentary_rows + 1. + ELSE. + li_head_top = li_commentary_rows + 2. + help = help - 1. + ENDIF. + + CALL METHOD lo_spreadsheet->insert_range_dim + EXPORTING + name = 'WHOLE_TABLE' + top = li_head_top + left = i_left + rows = help + columns = datareal + no_flush = no_flush. + +* columns width auto fix +* this parameter = space in case use with exist template + + IF i_columns_autofit = 'X'. + CALL METHOD lo_spreadsheet->fit_widest + EXPORTING + name = 'WHOLE_TABLE' + no_flush = no_flush. + ENDIF. + +* frame +* The parameter has 8 bits +*0 Left margin +*1 Top marginT +*2 Bottom margin +*3 Right margin +*4 Horizontal line +*5 Vertical line +*6 Thinness +*7 Thickness +* here 127 = 1111111 6-5-4-3-2-1 mean Thin-ver-hor-right-bot-top-left + +* ( final DOI method call, set no_flush = space +* equal to call method CL_GUI_CFW=>FLUSH ) + + CALL METHOD lo_spreadsheet->set_frame + EXPORTING + rangename = 'WHOLE_TABLE' + typ = 127 + color = 1 + no_flush = space + IMPORTING + error = lo_error + retcode = lc_retcode. + + error_doi( ). + +* reformat subtotal / total line after format wholw table + + LOOP AT subranges INTO subrangeitem. + l_sub_index = subrangeitem-rows + li_commentary_rows + rowmax. + + CALL METHOD lo_spreadsheet->insert_range_dim + EXPORTING + name = subrangeitem-name + left = i_left + top = l_sub_index + rows = 1 + columns = datareal + no_flush = no_flush. + + wa_format-name = subrangeitem-name. + +* default format: +* - clolor: subtotal = light yellow, subtotal = yellow +* - frame: box + + IF subrangeitem-name(3) = 'SUB'. + wa_format-back = 36. "subtotal line + wa_format_temp = i_format_subtotal. + ELSE. + wa_format-back = 27. "total line + wa_format_temp = i_format_total. + ENDIF. + wa_format-frametyp = 79. + wa_format-framecolor = 1. + wa_format-number = -1. + wa_format-align = -1. + +* get subtoal + total format from intput parameter +* overwrite default format + + IF wa_format_temp IS NOT INITIAL. + DESCRIBE FIELD wa_format_temp TYPE l_typ COMPONENTS li_col_num. + DO li_col_num TIMES. + IF sy-index NE 1. " dun map range name + ASSIGN COMPONENT sy-index OF STRUCTURE wa_format_temp + TO . + IF IS NOT INITIAL. + ASSIGN COMPONENT sy-index OF STRUCTURE wa_format TO . + = . + UNASSIGN: . + ENDIF. + UNASSIGN: . + ENDIF. + ENDDO. + + CLEAR: li_col_num. + ENDIF. + + APPEND wa_format TO lt_format. + CLEAR: wa_format-name. + CLEAR: l_sub_index. + CLEAR: wa_format_temp. + + ENDLOOP. + + IF lt_format[] IS NOT INITIAL. + CALL METHOD lo_spreadsheet->set_ranges_format + EXPORTING + formattable = lt_format + no_flush = no_flush. + CLEAR lt_format. + ENDIF. +*--------------------------------------------------------------------* + CALL METHOD lo_spreadsheet->screen_update + EXPORTING + updating = 'X'. + + CALL METHOD c_oi_errors=>flush_errors. + + lo_error_w = l_error. + lc_retcode = lo_error_w->error_code. + + CLEAR: + lt_sema, + wa_sema, + lt_hkey, + wa_hkey, + lt_vkey, + wa_vkey, + l_n_hrz_keys, + l_n_att_cols, + l_n_vrt_keys, + count, + datac, + datareal, + vkeycount, + all, + mit, + li_col_pos, + li_col_num, + ranges, + rangeitem, + contents, + contentsitem, + semaitem, + hkeyitem, + vkeyitem, + li_commentary_rows, + l_retcode, + li_head_top, + . + + CLEAR: + lo_error_w. + + UNASSIGN: + , + , + . + +*--------------------------------------------------------------------* +* SESSION 5: SAVE AND CLOSE FILE +*--------------------------------------------------------------------* + +* ex of save path: 'FILE://C:\temp\test.xlsx' + CONCATENATE 'FILE://' i_save_path + INTO ls_path. + + CALL METHOD lo_proxy->save_document_to_url + EXPORTING + no_flush = 'X' + url = ls_path + IMPORTING + error = lo_error + retcode = lc_retcode + CHANGING + document_size = li_document_size. + + error_doi( ). + +* if save successfully -> raise successful message + MESSAGE i400(yecb). + + CLEAR: + ls_path, + li_document_size. + + close_document( ). + ENDMETHOD. "BIND_ALV_OLE2 + + + METHOD close_document. + + DATA: l_is_closed TYPE i. + + CLEAR: l_is_closed. + IF lo_proxy IS NOT INITIAL. + +* check proxy detroyed adi + + CALL METHOD lo_proxy->is_destroyed + IMPORTING + ret_value = l_is_closed. + +* if dun detroyed yet: close -> release proxy + + IF l_is_closed IS INITIAL. + CALL METHOD lo_proxy->close_document + IMPORTING + error = lo_error + retcode = lc_retcode. + ENDIF. + + CALL METHOD lo_proxy->release_document + IMPORTING + error = lo_error + retcode = lc_retcode. + + ELSE. + lc_retcode = c_oi_errors=>ret_document_not_open. + ENDIF. + +* Detroy control container + + IF lo_control IS NOT INITIAL. + CALL METHOD lo_control->destroy_control. + ENDIF. + + CLEAR: + lo_spreadsheet, + lo_proxy, + lo_control. + + ENDMETHOD. + + + METHOD error_doi. + + IF lc_retcode NE c_oi_errors=>ret_ok. + close_document( ). + CALL METHOD lo_error->raise_message + EXPORTING + type = 'E'. + CLEAR: lo_error. + ENDIF. + + ENDMETHOD. + + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_ole.clas.locals_def.abap b/src/abap2xlsx/ycl_ecb_ole.clas.locals_def.abap new file mode 100644 index 0000000..8a58c35 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_ole.clas.locals_def.abap @@ -0,0 +1,46 @@ +*"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + +*--------------------------------------------------------------------* +* CLASS c_oi_proxy_error +*--------------------------------------------------------------------* +* use for method bind_ALV +*--------------------------------------------------------------------* +CLASS c_oi_proxy_error DEFINITION. + PUBLIC SECTION. + INTERFACES: i_oi_error. + DATA: error_nr TYPE i. + DATA: error_string TYPE sy-msgv1. + + METHODS: constructor IMPORTING object_name TYPE c + method_name TYPE c. + PRIVATE SECTION. + CONSTANTS: + ret_call_not_flushed TYPE i VALUE -999999. + + DATA: message_id TYPE sy-msgid, + message_nr TYPE sy-msgno, + param1 TYPE sy-msgv1, + param2 TYPE sy-msgv2, + param3 TYPE sy-msgv3, + param4 TYPE sy-msgv4. +ENDCLASS. "c_oi_proxy_error DEFINITION + +*--------------------------------------------------------------------* +* CLASS lcl_gui_alv_grid +*--------------------------------------------------------------------* +* to get protected attribute and method of cl_gui_alv_grid +* use for method bind_ALV +*--------------------------------------------------------------------* +CLASS lcl_gui_alv_grid DEFINITION INHERITING FROM cl_gui_alv_grid. + + PUBLIC SECTION. +* get ALV grid data + METHODS: get_alv_attributes + IMPORTING + io_grid TYPE REF TO cl_gui_alv_grid " ALV grid + EXPORTING + et_table TYPE REF TO data. " dta table + +ENDCLASS. "lcl_gui_alv_grid DEFINITION diff --git a/src/abap2xlsx/ycl_ecb_ole.clas.locals_imp.abap b/src/abap2xlsx/ycl_ecb_ole.clas.locals_imp.abap new file mode 100644 index 0000000..8ba7f56 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_ole.clas.locals_imp.abap @@ -0,0 +1,105 @@ +*"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + +*&---------------------------------------------------------------------* +*& Class (Implementation) C_OI_PROXY_ERROR +*&---------------------------------------------------------------------* +CLASS c_oi_proxy_error IMPLEMENTATION. + METHOD constructor. +* IMPORTING object_name TYPE c +* method_name TYPE c. + error_nr = ret_call_not_flushed. + me->i_oi_error~error_code = c_oi_errors=>ret_call_not_flushed. + me->i_oi_error~is_flushed = ' '. + me->i_oi_error~has_failed = 'X'. + me->i_oi_error~has_succeeded = ' '. + me->message_id = 'SOFFICEINTEGRATION'. + me->message_nr = '899'. + me->param1 = object_name. + me->param2 = method_name. + ENDMETHOD. "constructor + + METHOD i_oi_error~flush_error. + IF error_nr EQ 0. + me->i_oi_error~error_code = c_oi_errors=>ret_ok. + me->i_oi_error~is_flushed = 'X'. + me->i_oi_error~has_failed = ' '. + me->i_oi_error~has_succeeded = 'X'. + me->message_id = ''. + me->message_nr = '000'. + CALL METHOD c_oi_errors=>translate_proxy_error_code + EXPORTING + errorcode = error_nr + IMPORTING + retcode = me->i_oi_error~error_code. + ELSEIF error_nr EQ ret_call_not_flushed. + "call still not flushed + CALL METHOD c_oi_errors=>translate_proxy_error_code + EXPORTING + errorcode = error_nr + errorstring = me->param2 "method name + objectname = me->param1 + IMPORTING + retcode = me->i_oi_error~error_code. + ELSE. + me->i_oi_error~is_flushed = 'X'. + me->i_oi_error~has_succeeded = ' '. + me->i_oi_error~has_failed = 'X'. + CALL METHOD c_oi_errors=>translate_proxy_error_code + EXPORTING + errorcode = error_nr + errorstring = error_string + IMPORTING + retcode = me->i_oi_error~error_code. + CALL METHOD c_oi_errors=>get_message + IMPORTING + message_id = me->message_id + message_number = me->message_nr + param1 = me->param1 + param2 = me->param2 + param3 = me->param3 + param4 = me->param4. + ENDIF. + ENDMETHOD. "i_oi_error~flush_error + + METHOD i_oi_error~raise_message. +* IMPORTING type TYPE c. +* EXCEPTIONS message_raised flush_failed. + IF me->i_oi_error~has_succeeded IS INITIAL. + IF NOT me->i_oi_error~is_flushed IS INITIAL. + MESSAGE ID message_id TYPE type + NUMBER message_nr WITH param1 param2 param3 param4 + RAISING message_raised. + ELSE. + RAISE flush_failed. + ENDIF. + ENDIF. + ENDMETHOD. "i_oi_error~raise_message + + METHOD i_oi_error~get_message. +* EXPORTING message_id TYPE c +* message_number TYPE c +* param1 TYPE c +* param2 TYPE c +* param3 TYPE c +* param4 TYPE c. + param1 = me->param1. param2 = me->param2. + param3 = me->param3. param4 = me->param4. + + message_id = me->message_id. + message_number = me->message_nr. + ENDMETHOD. "i_oi_error~get_message +ENDCLASS. "C_OI_PROXY_ERROR + +*&---------------------------------------------------------------------* +*& Class (Implementation) CL_GRID_ACCESSION +*&---------------------------------------------------------------------* +CLASS lcl_gui_alv_grid IMPLEMENTATION. + + METHOD get_alv_attributes. + CREATE DATA et_table LIKE io_grid->mt_outtab. + et_table = io_grid->mt_outtab. + ENDMETHOD. "get_data + +ENDCLASS. "CL_GRID_ACCESSION diff --git a/src/abap2xlsx/ycl_ecb_ole.clas.xml b/src/abap2xlsx/ycl_ecb_ole.clas.xml new file mode 100644 index 0000000..5bf0fe9 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_ole.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_OLE + E + OLE processing (including DOI) + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_range.clas.abap b/src/abap2xlsx/ycl_ecb_range.clas.abap new file mode 100644 index 0000000..9321e91 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_range.clas.abap @@ -0,0 +1,83 @@ +CLASS ycl_ecb_range DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! + PUBLIC SECTION. + + CONSTANTS gcv_print_title_name TYPE string VALUE '_xlnm.Print_Titles'. "#EC NOTEXT + DATA name TYPE yecb_range_name . + DATA guid TYPE yecb_range_guid . + + METHODS get_guid + RETURNING + VALUE(ep_guid) TYPE yecb_range_guid . + METHODS set_value + IMPORTING + !ip_sheet_name TYPE yecb_sheet_title + !ip_start_row TYPE yecb_cell_row + !ip_start_column TYPE yecb_cell_column_alpha + !ip_stop_row TYPE yecb_cell_row + !ip_stop_column TYPE yecb_cell_column_alpha . + METHODS get_value + RETURNING + VALUE(ep_value) TYPE yecb_range_value . + METHODS set_range_value + IMPORTING + !ip_value TYPE yecb_range_value . +*"* protected components of class ZABAP_EXCEL_WORKSHEET +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_RANGE +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA value TYPE yecb_range_value . +ENDCLASS. + + + +CLASS ycl_ecb_range IMPLEMENTATION. + + + METHOD get_guid. + + ep_guid = me->guid. + + ENDMETHOD. + + + METHOD get_value. + + ep_value = me->value. + + ENDMETHOD. + + + METHOD set_range_value. + me->value = ip_value. + ENDMETHOD. + + + METHOD set_value. + DATA: lv_start_row_c TYPE c LENGTH 7, + lv_stop_row_c TYPE c LENGTH 7, + lv_value TYPE string. + lv_stop_row_c = ip_stop_row. + SHIFT lv_stop_row_c RIGHT DELETING TRAILING space. + SHIFT lv_stop_row_c LEFT DELETING LEADING space. + lv_start_row_c = ip_start_row. + SHIFT lv_start_row_c RIGHT DELETING TRAILING space. + SHIFT lv_start_row_c LEFT DELETING LEADING space. + lv_value = ip_sheet_name. + me->value = ycl_ecb_common=>escape_string( ip_value = lv_value ). + + IF ip_stop_column IS INITIAL AND ip_stop_row IS INITIAL. + CONCATENATE me->value '!$' ip_start_column '$' lv_start_row_c INTO me->value. + ELSE. + CONCATENATE me->value '!$' ip_start_column '$' lv_start_row_c ':$' ip_stop_column '$' lv_stop_row_c INTO me->value. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_range.clas.xml b/src/abap2xlsx/ycl_ecb_range.clas.xml new file mode 100644 index 0000000..bd1c2d1 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_range.clas.xml @@ -0,0 +1,78 @@ + + + + + + YCL_ECB_RANGE + E + Excel range + 1 + X + X + X + + + + GET_GUID + E + Get Guid + + + GET_GUID + I + Get Guid + + + GET_VALUE + E + Get value + + + GET_VALUE + I + Get value + + + GUID + E + GUID for the OLTP System (RAW16) + + + GUID + I + GUID for the OLTP System (RAW16) + + + NAME + E + Range Name + + + NAME + I + Range Name + + + SET_VALUE + E + Set Range value + + + SET_VALUE + I + Set Range value + + + VALUE + E + Cell Value + + + VALUE + I + Cell Value + + + + + diff --git a/src/abap2xlsx/ycl_ecb_ranges.clas.abap b/src/abap2xlsx/ycl_ecb_ranges.clas.abap new file mode 100644 index 0000000..e5c0f2e --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_ranges.clas.abap @@ -0,0 +1,88 @@ +CLASS ycl_ecb_ranges DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_RANGES +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS add + IMPORTING + !ip_range TYPE REF TO ycl_ecb_range . + METHODS clear . + METHODS constructor . + METHODS get + IMPORTING + !ip_index TYPE i + RETURNING + VALUE(eo_range) TYPE REF TO ycl_ecb_range . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !ip_range TYPE REF TO ycl_ecb_range . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA ranges TYPE REF TO ycl_ecb_collection . +ENDCLASS. + + + +CLASS ycl_ecb_ranges IMPLEMENTATION. + + + METHOD add. + ranges->add( ip_range ). + ENDMETHOD. + + + METHOD clear. + ranges->clear( ). + ENDMETHOD. + + + METHOD constructor. + + + CREATE OBJECT ranges. + + ENDMETHOD. + + + METHOD get. + eo_range ?= ranges->get( ip_index ). + ENDMETHOD. + + + METHOD get_iterator. + eo_iterator ?= ranges->get_iterator( ). + ENDMETHOD. + + + METHOD is_empty. + is_empty = ranges->is_empty( ). + ENDMETHOD. + + + METHOD remove. + ranges->remove( ip_range ). + ENDMETHOD. + + + METHOD size. + ep_size = ranges->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_ranges.clas.xml b/src/abap2xlsx/ycl_ecb_ranges.clas.xml new file mode 100644 index 0000000..96b7b32 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_ranges.clas.xml @@ -0,0 +1,98 @@ + + + + + + YCL_ECB_RANGES + E + Ranges collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + ADD + I + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CLEAR + I + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + GET + E + Gets Element + + + GET + I + Gets Element + + + GET_ITERATOR + E + Returns an iterator + + + GET_ITERATOR + I + Returns an iterator + + + IS_EMPTY + E + Checks whether elements are contained + + + IS_EMPTY + I + Checks whether elements are contained + + + REMOVE + E + Deletes an Element from the Collection + + + REMOVE + I + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + SIZE + I + Specifies number of contained elements + + + + + diff --git a/src/abap2xlsx/ycl_ecb_reader_2007.clas.abap b/src/abap2xlsx/ycl_ecb_reader_2007.clas.abap new file mode 100644 index 0000000..3fad62d --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_2007.clas.abap @@ -0,0 +1,4275 @@ +CLASS ycl_ecb_reader_2007 DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_READER_2007 +*"* do not include other source files here!!! + + INTERFACES yif_ecb_reader . + + CLASS-METHODS fill_struct_from_attributes + IMPORTING + !ip_element TYPE REF TO if_ixml_element + CHANGING + !cp_structure TYPE any . + PROTECTED SECTION. + + TYPES: +*"* protected components of class ZCL_EXCEL_READER_2007 +*"* do not include other source files here!!! + BEGIN OF t_relationship, + id TYPE string, + type TYPE string, + target TYPE string, + targetmode TYPE string, + worksheet TYPE REF TO ycl_ecb_worksheet, + sheetid TYPE string, "ins #235 - repeat rows/cols - needed to identify correct sheet + localsheetid TYPE string, + END OF t_relationship . + TYPES: + BEGIN OF t_fileversion, + appname TYPE string, + lastedited TYPE string, + lowestedited TYPE string, + rupbuild TYPE string, + codename TYPE string, + END OF t_fileversion . + TYPES: + BEGIN OF t_sheet, + name TYPE string, + sheetid TYPE string, + id TYPE string, + state TYPE string, + END OF t_sheet . + TYPES: + BEGIN OF t_workbookpr, + codename TYPE string, + defaultthemeversion TYPE string, + END OF t_workbookpr . + TYPES: + BEGIN OF t_sheetpr, + codename TYPE string, + END OF t_sheetpr . + TYPES: + BEGIN OF t_range, + name TYPE string, + hidden TYPE string, "inserted with issue #235 because Autofilters didn't passthrough + localsheetid TYPE string, " issue #163 + END OF t_range . + TYPES: + t_fills TYPE STANDARD TABLE OF REF TO ycl_ecb_style_fill WITH NON-UNIQUE DEFAULT KEY . + TYPES: + t_borders TYPE STANDARD TABLE OF REF TO ycl_ecb_style_borders WITH NON-UNIQUE DEFAULT KEY . + TYPES: + t_fonts TYPE STANDARD TABLE OF REF TO ycl_ecb_style_font WITH NON-UNIQUE DEFAULT KEY . + TYPES: + t_style_refs TYPE STANDARD TABLE OF REF TO ycl_ecb_style WITH NON-UNIQUE DEFAULT KEY . + TYPES: + BEGIN OF t_color, + indexed TYPE string, + rgb TYPE string, + theme TYPE string, + tint TYPE string, + END OF t_color . + TYPES: + BEGIN OF t_rel_drawing, + id TYPE string, + content TYPE xstring, + file_ext TYPE string, + content_xml TYPE REF TO if_ixml_document, + END OF t_rel_drawing . + TYPES: + t_rel_drawings TYPE STANDARD TABLE OF t_rel_drawing WITH NON-UNIQUE DEFAULT KEY . + TYPES: + BEGIN OF gts_external_hyperlink, + id TYPE string, + target TYPE string, + END OF gts_external_hyperlink . + TYPES: + gtt_external_hyperlinks TYPE HASHED TABLE OF gts_external_hyperlink WITH UNIQUE KEY id . + TYPES: + BEGIN OF ty_ref_formulae, + sheet TYPE REF TO ycl_ecb_worksheet, + row TYPE i, + column TYPE i, + si TYPE i, + ref TYPE string, + formula TYPE string, + END OF ty_ref_formulae . + TYPES: + tyt_ref_formulae TYPE HASHED TABLE OF ty_ref_formulae WITH UNIQUE KEY sheet row column . + TYPES: + BEGIN OF t_shared_string, + value TYPE string, + rtf TYPE yecb_t_rtf, + END OF t_shared_string . + TYPES: + t_shared_strings TYPE STANDARD TABLE OF t_shared_string WITH DEFAULT KEY . + + DATA shared_strings TYPE t_shared_strings . + DATA styles TYPE t_style_refs . + DATA mt_ref_formulae TYPE tyt_ref_formulae . + DATA mt_dxf_styles TYPE yecb_t_styles_cond_mapping . + + METHODS fill_row_outlines + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS get_from_zip_archive + IMPORTING + !i_filename TYPE string + RETURNING + VALUE(r_content) TYPE xstring + RAISING + ycx_ecb . + METHODS get_ixml_from_zip_archive + IMPORTING + !i_filename TYPE string + !is_normalizing TYPE abap_bool DEFAULT 'X' + RETURNING + VALUE(r_ixml) TYPE REF TO if_ixml_document + RAISING + ycx_ecb . + METHODS load_drawing_anchor + IMPORTING + !io_anchor_element TYPE REF TO if_ixml_element + !io_worksheet TYPE REF TO ycl_ecb_worksheet + !it_related_drawings TYPE t_rel_drawings . + METHODS load_shared_strings + IMPORTING + !ip_path TYPE string + RAISING + ycx_ecb . + METHODS load_styles + IMPORTING + !ip_path TYPE string + !ip_excel TYPE REF TO ycl_ecb + RAISING + ycx_ecb . + METHODS load_dxf_styles + IMPORTING + !iv_path TYPE string + !io_excel TYPE REF TO ycl_ecb + RAISING + ycx_ecb . + METHODS load_style_borders + IMPORTING + !ip_xml TYPE REF TO if_ixml_document + RETURNING + VALUE(ep_borders) TYPE t_borders . + METHODS load_style_fills + IMPORTING + !ip_xml TYPE REF TO if_ixml_document + RETURNING + VALUE(ep_fills) TYPE t_fills . + METHODS load_style_font + IMPORTING + !io_xml_element TYPE REF TO if_ixml_element + RETURNING + VALUE(ro_font) TYPE REF TO ycl_ecb_style_font . + METHODS load_style_fonts + IMPORTING + !ip_xml TYPE REF TO if_ixml_document + RETURNING + VALUE(ep_fonts) TYPE t_fonts . + METHODS load_style_num_formats + IMPORTING + !ip_xml TYPE REF TO if_ixml_document + RETURNING + VALUE(ep_num_formats) TYPE ycl_ecb_style_number_format=>t_num_formats . + METHODS load_workbook + IMPORTING + !iv_workbook_full_filename TYPE string + !io_excel TYPE REF TO ycl_ecb + RAISING + ycx_ecb . + METHODS load_worksheet + IMPORTING + !ip_path TYPE string + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS load_worksheet_cond_format + IMPORTING + !io_ixml_worksheet TYPE REF TO if_ixml_document + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS load_worksheet_cond_format_aa + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond. + METHODS load_worksheet_cond_format_ci + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS load_worksheet_cond_format_cs + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS load_worksheet_cond_format_ex + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS load_worksheet_cond_format_is + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS load_worksheet_cond_format_db + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS load_worksheet_cond_format_t10 + IMPORTING + !io_ixml_rule TYPE REF TO if_ixml_element + !io_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS load_worksheet_drawing + IMPORTING + !ip_path TYPE string + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS load_comments + IMPORTING + ip_path TYPE string + io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS load_worksheet_hyperlinks + IMPORTING + !io_ixml_worksheet TYPE REF TO if_ixml_document + !io_worksheet TYPE REF TO ycl_ecb_worksheet + !it_external_hyperlinks TYPE gtt_external_hyperlinks + RAISING + ycx_ecb . + METHODS load_worksheet_ignored_errors + IMPORTING + !io_ixml_worksheet TYPE REF TO if_ixml_document + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS load_worksheet_pagebreaks + IMPORTING + !io_ixml_worksheet TYPE REF TO if_ixml_document + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + METHODS load_worksheet_autofilter + IMPORTING + io_ixml_worksheet TYPE REF TO if_ixml_document + io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb. + METHODS load_worksheet_pagemargins + IMPORTING + !io_ixml_worksheet TYPE REF TO if_ixml_document + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + ycx_ecb . + CLASS-METHODS resolve_path + IMPORTING + !ip_path TYPE string + RETURNING + VALUE(rp_result) TYPE string . + METHODS resolve_referenced_formulae . + METHODS unescape_string_value + IMPORTING + i_value TYPE string + RETURNING + VALUE(result) TYPE string. + METHODS get_dxf_style_guid + IMPORTING + !io_ixml_dxf TYPE REF TO if_ixml_element + !io_excel TYPE REF TO ycl_ecb + RETURNING + VALUE(rv_style_guid) TYPE yecb_cell_style . + METHODS load_theme + IMPORTING + iv_path TYPE string + !ip_excel TYPE REF TO ycl_ecb + RAISING + ycx_ecb . + + CONSTANTS: BEGIN OF namespace, + x14ac TYPE string VALUE 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac', + vba_project TYPE string VALUE 'http://schemas.microsoft.com/office/2006/relationships/vbaProject', "#EC NEEDED for future incorporation of XLSM-reader + c TYPE string VALUE 'http://schemas.openxmlformats.org/drawingml/2006/chart', + a TYPE string VALUE 'http://schemas.openxmlformats.org/drawingml/2006/main', + xdr TYPE string VALUE 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing', + mc TYPE string VALUE 'http://schemas.openxmlformats.org/markup-compatibility/2006', + r TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', + chart TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', + drawing TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', + hyperlink TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', + image TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', + office_document TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + printer_settings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings', + shared_strings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + styles TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + theme TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + worksheet TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + relationships TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships', + core_properties TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + main TYPE string VALUE 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', + END OF namespace. + + PRIVATE SECTION. + + DATA zip TYPE REF TO lcl_zip_archive . + DATA: gid TYPE i. + + METHODS create_zip_archive + IMPORTING + !i_xlsx_binary TYPE xstring + !i_use_alternate_zip TYPE seoclsname OPTIONAL + RETURNING + VALUE(e_zip) TYPE REF TO lcl_zip_archive + RAISING + ycx_ecb . + METHODS read_from_applserver + IMPORTING + !i_filename TYPE csequence + RETURNING + VALUE(r_excel_data) TYPE xstring + RAISING + ycx_ecb. + METHODS read_from_local_file + IMPORTING + !i_filename TYPE csequence + RETURNING + VALUE(r_excel_data) TYPE xstring + RAISING + ycx_ecb . +ENDCLASS. + + + +CLASS ycl_ecb_reader_2007 IMPLEMENTATION. + + + METHOD create_zip_archive. + CASE i_use_alternate_zip. + WHEN space. + e_zip = lcl_abap_zip_archive=>create( i_xlsx_binary ). + WHEN OTHERS. + e_zip = lcl_alternate_zip_archive=>create( i_data = i_xlsx_binary + i_alternate_zip_class = i_use_alternate_zip ). + ENDCASE. + ENDMETHOD. + + + METHOD fill_row_outlines. + + TYPES: BEGIN OF lts_row_data, + row TYPE i, + outline_level TYPE i, + END OF lts_row_data, + ltt_row_data TYPE SORTED TABLE OF lts_row_data WITH UNIQUE KEY row. + + DATA: lt_row_data TYPE ltt_row_data, + ls_row_data LIKE LINE OF lt_row_data, + lt_collapse_rows TYPE HASHED TABLE OF i WITH UNIQUE KEY table_line, + + lv_collapsed TYPE abap_bool, + + lv_outline_level TYPE i, + lv_next_consecutive_row TYPE i, + lt_outline_rows TYPE ycl_ecb_worksheet=>mty_ts_outlines_row, + ls_outline_row LIKE LINE OF lt_outline_rows, + lo_row TYPE REF TO ycl_ecb_row, + lo_row_iterator TYPE REF TO ycl_ecb_collection_iterator, + lv_row_offset TYPE i, + lv_row_collapse_flag TYPE i. + + + FIELD-SYMBOLS: LIKE LINE OF lt_row_data. + +* First collect information about outlines ( outline leven and collapsed state ) + lo_row_iterator = io_worksheet->get_rows_iterator( ). + WHILE lo_row_iterator->has_next( ) = abap_true. + lo_row ?= lo_row_iterator->get_next( ). + ls_row_data-row = lo_row->get_row_index( ). + ls_row_data-outline_level = lo_row->get_outline_level( ). + IF ls_row_data-outline_level IS NOT INITIAL. + INSERT ls_row_data INTO TABLE lt_row_data. + ENDIF. + + lv_collapsed = lo_row->get_collapsed( ). + IF lv_collapsed = abap_true. + INSERT lo_row->get_row_index( ) INTO TABLE lt_collapse_rows. + ENDIF. + ENDWHILE. + +* Now parse this information - we need consecutive rows - any gap will create a new outline + DO 7 TIMES. " max number of outlines allowed + lv_outline_level = sy-index. + CLEAR lv_next_consecutive_row. + CLEAR ls_outline_row. + LOOP AT lt_row_data ASSIGNING WHERE outline_level >= lv_outline_level. + + IF lv_next_consecutive_row <> -row " A gap --> close all open outlines + AND lv_next_consecutive_row IS NOT INITIAL. " First time in loop. + INSERT ls_outline_row INTO TABLE lt_outline_rows. + CLEAR: ls_outline_row. + ENDIF. + + IF ls_outline_row-row_from IS INITIAL. + ls_outline_row-row_from = -row. + ENDIF. + ls_outline_row-row_to = -row. + + lv_next_consecutive_row = -row + 1. + + ENDLOOP. + IF ls_outline_row-row_from IS NOT INITIAL. + INSERT ls_outline_row INTO TABLE lt_outline_rows. + ENDIF. + ENDDO. + +* lt_outline_rows holds all outline information +* we now need to determine whether the outline is collapsed or not + LOOP AT lt_outline_rows INTO ls_outline_row. + + IF io_worksheet->yif_ecb_sheet_properties~summarybelow = yif_ecb_sheet_properties=>c_below_off. + lv_row_collapse_flag = ls_outline_row-row_from - 1. + ELSE. + lv_row_collapse_flag = ls_outline_row-row_to + 1. + ENDIF. + READ TABLE lt_collapse_rows TRANSPORTING NO FIELDS WITH TABLE KEY table_line = lv_row_collapse_flag. + IF sy-subrc = 0. + ls_outline_row-collapsed = abap_true. + ENDIF. + io_worksheet->set_row_outline( iv_row_from = ls_outline_row-row_from + iv_row_to = ls_outline_row-row_to + iv_collapsed = ls_outline_row-collapsed ). + + ENDLOOP. + +* Finally purge outline information ( collapsed state, outline leve) from row_dimensions, since we want to keep these in the outline-table + lo_row_iterator = io_worksheet->get_rows_iterator( ). + WHILE lo_row_iterator->has_next( ) = abap_true. + lo_row ?= lo_row_iterator->get_next( ). + + lo_row->set_outline_level( 0 ). + lo_row->set_collapsed( abap_false ). + + ENDWHILE. + + ENDMETHOD. + + + METHOD fill_struct_from_attributes. +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-07 +* - ... +* changes: renaming variables to naming conventions +* aligning code +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* + + DATA: lv_name TYPE string, + lo_attributes TYPE REF TO if_ixml_named_node_map, + lo_attribute TYPE REF TO if_ixml_attribute, + lo_iterator TYPE REF TO if_ixml_node_iterator. + + FIELD-SYMBOLS: TYPE any. + +*--------------------------------------------------------------------* +* The values of named attributes of a tag are being read and moved into corresponding +* fields of given structure +* Behaves like move-corresonding tag to structure + +* Example: +* +* Here the attributes are Target, Type and Id. Thus if the passed +* structure has fieldnames Id and Target these would be filled with +* "rId3" and "docProps/app.xml" respectively +*--------------------------------------------------------------------* + CLEAR cp_structure. + + lo_attributes = ip_element->get_attributes( ). + lo_iterator = lo_attributes->create_iterator( ). + lo_attribute ?= lo_iterator->get_next( ). + WHILE lo_attribute IS BOUND. + + lv_name = lo_attribute->get_name( ). + TRANSLATE lv_name TO UPPER CASE. + ASSIGN COMPONENT lv_name OF STRUCTURE cp_structure TO . + IF sy-subrc = 0. + = lo_attribute->get_value( ). + ENDIF. + lo_attribute ?= lo_iterator->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD get_dxf_style_guid. + DATA: lo_ixml_dxf_children TYPE REF TO if_ixml_node_list, + lo_ixml_iterator_dxf_children TYPE REF TO if_ixml_node_iterator, + lo_ixml_dxf_child TYPE REF TO if_ixml_element, + + lv_dxf_child_type TYPE string, + + lo_ixml_element TYPE REF TO if_ixml_element, + lo_ixml_element2 TYPE REF TO if_ixml_element, + lv_val TYPE string. + + DATA: ls_cstyle TYPE yecb_s_cstyle_complete, + ls_cstylex TYPE yecb_s_cstylex_complete. + + + + lo_ixml_dxf_children = io_ixml_dxf->get_children( ). + lo_ixml_iterator_dxf_children = lo_ixml_dxf_children->create_iterator( ). + lo_ixml_dxf_child ?= lo_ixml_iterator_dxf_children->get_next( ). + WHILE lo_ixml_dxf_child IS BOUND. + + lv_dxf_child_type = lo_ixml_dxf_child->get_name( ). + CASE lv_dxf_child_type. + + WHEN 'font'. +*--------------------------------------------------------------------* +* italic +*--------------------------------------------------------------------* + lo_ixml_element = lo_ixml_dxf_child->find_from_name_ns( name = 'i' uri = namespace-main ). + IF lo_ixml_element IS BOUND. + CLEAR lv_val. + lv_val = lo_ixml_element->get_attribute_ns( 'val' ). + IF lv_val <> '0'. + ls_cstyle-font-italic = 'X'. + ls_cstylex-font-italic = 'X'. + ENDIF. + + ENDIF. +*--------------------------------------------------------------------* +* bold +*--------------------------------------------------------------------* + lo_ixml_element = lo_ixml_dxf_child->find_from_name_ns( name = 'b' uri = namespace-main ). + IF lo_ixml_element IS BOUND. + CLEAR lv_val. + lv_val = lo_ixml_element->get_attribute_ns( 'val' ). + IF lv_val <> '0'. + ls_cstyle-font-bold = 'X'. + ls_cstylex-font-bold = 'X'. + ENDIF. + + ENDIF. +*--------------------------------------------------------------------* +* strikethrough +*--------------------------------------------------------------------* + lo_ixml_element = lo_ixml_dxf_child->find_from_name_ns( name = 'strike' uri = namespace-main ). + IF lo_ixml_element IS BOUND. + CLEAR lv_val. + lv_val = lo_ixml_element->get_attribute_ns( 'val' ). + IF lv_val <> '0'. + ls_cstyle-font-strikethrough = 'X'. + ls_cstylex-font-strikethrough = 'X'. + ENDIF. + + ENDIF. +*--------------------------------------------------------------------* +* color +*--------------------------------------------------------------------* + lo_ixml_element = lo_ixml_dxf_child->find_from_name_ns( name = 'color' uri = namespace-main ). + IF lo_ixml_element IS BOUND. + CLEAR lv_val. + lv_val = lo_ixml_element->get_attribute_ns( 'rgb' ). + ls_cstyle-font-color-rgb = lv_val. + ls_cstylex-font-color-rgb = 'X'. + ENDIF. + + WHEN 'fill'. + lo_ixml_element = lo_ixml_dxf_child->find_from_name_ns( name = 'patternFill' uri = namespace-main ). + IF lo_ixml_element IS BOUND. + lo_ixml_element2 = lo_ixml_dxf_child->find_from_name_ns( name = 'bgColor' uri = namespace-main ). + IF lo_ixml_element2 IS BOUND. + CLEAR lv_val. + lv_val = lo_ixml_element2->get_attribute_ns( 'rgb' ). + IF lv_val IS NOT INITIAL. + ls_cstyle-fill-filltype = ycl_ecb_style_fill=>c_fill_solid. + ls_cstyle-fill-bgcolor-rgb = lv_val. + ls_cstylex-fill-filltype = 'X'. + ls_cstylex-fill-bgcolor-rgb = 'X'. + ENDIF. + CLEAR lv_val. + lv_val = lo_ixml_element2->get_attribute_ns( 'theme' ). + IF lv_val IS NOT INITIAL. + ls_cstyle-fill-filltype = ycl_ecb_style_fill=>c_fill_solid. + ls_cstyle-fill-bgcolor-theme = lv_val. + ls_cstylex-fill-filltype = 'X'. + ls_cstylex-fill-bgcolor-theme = 'X'. + ENDIF. + CLEAR lv_val. + ENDIF. + ENDIF. + + ENDCASE. + + lo_ixml_dxf_child ?= lo_ixml_iterator_dxf_children->get_next( ). + + ENDWHILE. + + rv_style_guid = io_excel->get_static_cellstyle_guid( ip_cstyle_complete = ls_cstyle + ip_cstylex_complete = ls_cstylex ). + + + ENDMETHOD. + + + METHOD get_from_zip_archive. + + ASSERT zip IS BOUND. " zip object has to exist at this point + + r_content = zip->read( i_filename ). + + ENDMETHOD. + + + METHOD get_ixml_from_zip_archive. + + DATA: lv_content TYPE xstring, + lo_ixml TYPE REF TO if_ixml, + lo_streamfactory TYPE REF TO if_ixml_stream_factory, + lo_istream TYPE REF TO if_ixml_istream, + lo_parser TYPE REF TO if_ixml_parser. + +*--------------------------------------------------------------------* +* Load XML file from archive into an input stream, +* and parse that stream into an ixml object +*--------------------------------------------------------------------* + lv_content = me->get_from_zip_archive( i_filename ). + lo_ixml = cl_ixml=>create( ). + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_istream = lo_streamfactory->create_istream_xstring( lv_content ). + r_ixml = lo_ixml->create_document( ). + lo_parser = lo_ixml->create_parser( stream_factory = lo_streamfactory + istream = lo_istream + document = r_ixml ). + lo_parser->set_normalizing( is_normalizing ). + lo_parser->set_validating( mode = if_ixml_parser=>co_no_validation ). + lo_parser->parse( ). + + ENDMETHOD. + + + METHOD load_drawing_anchor. + + TYPES: BEGIN OF t_c_nv_pr, + name TYPE string, + id TYPE string, + END OF t_c_nv_pr. + + TYPES: BEGIN OF t_blip, + cstate TYPE string, + embed TYPE string, + END OF t_blip. + + TYPES: BEGIN OF t_chart, + id TYPE string, + END OF t_chart. + + TYPES: BEGIN OF t_ext, + cx TYPE string, + cy TYPE string, + END OF t_ext. + + CONSTANTS: lc_xml_attr_true TYPE string VALUE 'true', + lc_xml_attr_true_int TYPE string VALUE '1'. + CONSTANTS: lc_rel_chart TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', + lc_rel_image TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'. + + DATA: lo_drawing TYPE REF TO ycl_ecb_drawing, + node TYPE REF TO if_ixml_element, + node2 TYPE REF TO if_ixml_element, + node3 TYPE REF TO if_ixml_element, + node4 TYPE REF TO if_ixml_element, + + ls_upper TYPE yecb_drawing_location, + ls_lower TYPE yecb_drawing_location, + ls_size TYPE yecb_drawing_size, + ext TYPE t_ext, + lv_content TYPE xstring, + lv_relation_id TYPE string, + lv_title TYPE string, + + cnvpr TYPE t_c_nv_pr, + blip TYPE t_blip, + chart TYPE t_chart, + drawing_type TYPE yecb_drawing_type, + + rel_drawing TYPE t_rel_drawing. + + node ?= io_anchor_element->find_from_name_ns( name = 'from' uri = namespace-xdr ). + CHECK node IS NOT INITIAL. + node2 ?= node->find_from_name_ns( name = 'col' uri = namespace-xdr ). + ls_upper-col = node2->get_value( ). + node2 ?= node->find_from_name_ns( name = 'row' uri = namespace-xdr ). + ls_upper-row = node2->get_value( ). + node2 ?= node->find_from_name_ns( name = 'colOff' uri = namespace-xdr ). + ls_upper-col_offset = node2->get_value( ). + node2 ?= node->find_from_name_ns( name = 'rowOff' uri = namespace-xdr ). + ls_upper-row_offset = node2->get_value( ). + + node ?= io_anchor_element->find_from_name_ns( name = 'ext' uri = namespace-xdr ). + IF node IS INITIAL. + CLEAR ls_size. + ELSE. + me->fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = ext ). + ls_size-width = ext-cx. + ls_size-height = ext-cy. + TRY. + ls_size-width = ycl_ecb_drawing=>emu2pixel( ls_size-width ). + CATCH cx_root. + ENDTRY. + TRY. + ls_size-height = ycl_ecb_drawing=>emu2pixel( ls_size-height ). + CATCH cx_root. + ENDTRY. + ENDIF. + + node ?= io_anchor_element->find_from_name_ns( name = 'to' uri = namespace-xdr ). + IF node IS INITIAL. + CLEAR ls_lower. + ELSE. + node2 ?= node->find_from_name_ns( name = 'col' uri = namespace-xdr ). + ls_lower-col = node2->get_value( ). + node2 ?= node->find_from_name_ns( name = 'row' uri = namespace-xdr ). + ls_lower-row = node2->get_value( ). + node2 ?= node->find_from_name_ns( name = 'colOff' uri = namespace-xdr ). + ls_lower-col_offset = node2->get_value( ). + node2 ?= node->find_from_name_ns( name = 'rowOff' uri = namespace-xdr ). + ls_lower-row_offset = node2->get_value( ). + ENDIF. + + node ?= io_anchor_element->find_from_name_ns( name = 'pic' uri = namespace-xdr ). + IF node IS NOT INITIAL. + node2 ?= node->find_from_name_ns( name = 'nvPicPr' uri = namespace-xdr ). + CHECK node2 IS NOT INITIAL. + node3 ?= node2->find_from_name_ns( name = 'cNvPr' uri = namespace-xdr ). + CHECK node3 IS NOT INITIAL. + me->fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = cnvpr ). + lv_title = cnvpr-name. + + node2 ?= node->find_from_name_ns( name = 'blipFill' uri = namespace-xdr ). + CHECK node2 IS NOT INITIAL. + node3 ?= node2->find_from_name_ns( name = 'blip' uri = namespace-a ). + CHECK node3 IS NOT INITIAL. + me->fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = blip ). + lv_relation_id = blip-embed. + + drawing_type = ycl_ecb_drawing=>type_image. + ENDIF. + + node ?= io_anchor_element->find_from_name_ns( name = 'graphicFrame' uri = namespace-xdr ). + IF node IS NOT INITIAL. + node2 ?= node->find_from_name_ns( name = 'nvGraphicFramePr' uri = namespace-xdr ). + CHECK node2 IS NOT INITIAL. + node3 ?= node2->find_from_name_ns( name = 'cNvPr' uri = namespace-xdr ). + CHECK node3 IS NOT INITIAL. + me->fill_struct_from_attributes( EXPORTING ip_element = node3 CHANGING cp_structure = cnvpr ). + lv_title = cnvpr-name. + + node2 ?= node->find_from_name_ns( name = 'graphic' uri = namespace-a ). + CHECK node2 IS NOT INITIAL. + node3 ?= node2->find_from_name_ns( name = 'graphicData' uri = namespace-a ). + CHECK node3 IS NOT INITIAL. + node4 ?= node2->find_from_name_ns( name = 'chart' uri = namespace-c ). + CHECK node4 IS NOT INITIAL. + me->fill_struct_from_attributes( EXPORTING ip_element = node4 CHANGING cp_structure = chart ). + lv_relation_id = chart-id. + + drawing_type = ycl_ecb_drawing=>type_chart. + ENDIF. + + lo_drawing = io_worksheet->excel->add_new_drawing( + ip_type = drawing_type + ip_title = lv_title ). + io_worksheet->add_drawing( lo_drawing ). + + lo_drawing->set_position2( + EXPORTING + ip_from = ls_upper + ip_to = ls_lower ). + + READ TABLE it_related_drawings INTO rel_drawing + WITH KEY id = lv_relation_id. + + lo_drawing->set_media( + EXPORTING + ip_media = rel_drawing-content + ip_media_type = rel_drawing-file_ext + ip_width = ls_size-width + ip_height = ls_size-height ). + + IF drawing_type = ycl_ecb_drawing=>type_chart. +* Begin fix for Issue #551 + DATA: lo_tmp_node_2 TYPE REF TO if_ixml_element. + lo_tmp_node_2 ?= rel_drawing-content_xml->find_from_name_ns( name = 'pieChart' uri = namespace-c ). + IF lo_tmp_node_2 IS NOT INITIAL. + lo_drawing->graph_type = ycl_ecb_drawing=>c_graph_pie. + ELSE. + lo_tmp_node_2 ?= rel_drawing-content_xml->find_from_name_ns( name = 'barChart' uri = namespace-c ). + IF lo_tmp_node_2 IS NOT INITIAL. + lo_drawing->graph_type = ycl_ecb_drawing=>c_graph_bars. + ELSE. + lo_tmp_node_2 ?= rel_drawing-content_xml->find_from_name_ns( name = 'lineChart' uri = namespace-c ). + IF lo_tmp_node_2 IS NOT INITIAL. + lo_drawing->graph_type = ycl_ecb_drawing=>c_graph_line. + ENDIF. + ENDIF. + ENDIF. +* End fix for issue #551 + "-------------Added by Alessandro Iannacci - Should load chart attributes + lo_drawing->load_chart_attributes( rel_drawing-content_xml ). + ENDIF. + + ENDMETHOD. + + + METHOD load_dxf_styles. + + DATA: lo_styles_xml TYPE REF TO if_ixml_document, + lo_node_dxfs TYPE REF TO if_ixml_element, + + lo_nodes_dxf TYPE REF TO if_ixml_node_collection, + lo_iterator_dxf TYPE REF TO if_ixml_node_iterator, + lo_node_dxf TYPE REF TO if_ixml_element, + + lv_dxf_count TYPE i. + + FIELD-SYMBOLS: LIKE LINE OF mt_dxf_styles. + +*--------------------------------------------------------------------* +* Look for dxfs-node +*--------------------------------------------------------------------* + lo_styles_xml = me->get_ixml_from_zip_archive( iv_path ). + lo_node_dxfs = lo_styles_xml->find_from_name_ns( name = 'dxfs' uri = namespace-main ). + CHECK lo_node_dxfs IS BOUND. + + +*--------------------------------------------------------------------* +* loop through all dxf-nodes and create style for each +*--------------------------------------------------------------------* + lo_nodes_dxf ?= lo_node_dxfs->get_elements_by_tag_name_ns( name = 'dxf' uri = namespace-main ). + lo_iterator_dxf = lo_nodes_dxf->create_iterator( ). + lo_node_dxf ?= lo_iterator_dxf->get_next( ). + WHILE lo_node_dxf IS BOUND. + + APPEND INITIAL LINE TO mt_dxf_styles ASSIGNING . + -dxf = lv_dxf_count. " We start counting at 0 + ADD 1 TO lv_dxf_count. " prepare next entry + + -guid = get_dxf_style_guid( io_ixml_dxf = lo_node_dxf + io_excel = io_excel ). + lo_node_dxf ?= lo_iterator_dxf->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_shared_strings. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Support partial formatting of strings in cells +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-11 +* - ... +* changes: renaming variables to naming conventions +* renaming variables to indicate what they are used for +* aligning code +* adding comments to explain what we are trying to achieve +* rewriting code for better readibility +*--------------------------------------------------------------------* + + + + DATA: + lo_shared_strings_xml TYPE REF TO if_ixml_document, + lo_node_si TYPE REF TO if_ixml_element, + lo_node_si_child TYPE REF TO if_ixml_element, + lo_node_r_child_t TYPE REF TO if_ixml_element, + lo_node_r_child_rpr TYPE REF TO if_ixml_element, + lo_font TYPE REF TO ycl_ecb_style_font, + ls_rtf TYPE yecb_s_rtf, + lv_current_offset TYPE int2, + lv_tag_name TYPE string, + lv_node_value TYPE string. + + FIELD-SYMBOLS: LIKE LINE OF me->shared_strings. + +*--------------------------------------------------------------------* + +* §1 Parse shared strings file and get into internal table +* So far I have encountered 2 ways how a string can be represented in the shared strings file +* §1.1 - "simple" strings +* §1.2 - rich text formatted strings + +* Following is an example how this file could be set up; 2 strings in simple formatting, 3rd string rich textformatted + + +* +* +* +* This is a teststring 1 +* +* +* This is a teststring 2 +* +* +* +* T +* +* +* +* +* +* +* +* +* +* his is a +* +* +* +* +* +* +* +* +* +* teststring 3 +* +* +* +*--------------------------------------------------------------------* + + lo_shared_strings_xml = me->get_ixml_from_zip_archive( i_filename = ip_path + is_normalizing = space ). " NO!!! normalizing - otherwise leading blanks will be omitted and that is not really desired for the stringtable + lo_node_si ?= lo_shared_strings_xml->find_from_name_ns( name = 'si' uri = namespace-main ). + WHILE lo_node_si IS BOUND. + + APPEND INITIAL LINE TO me->shared_strings ASSIGNING . " Each -entry in the xml-file must lead to an entry in our stringtable + lo_node_si_child ?= lo_node_si->get_first_child( ). + IF lo_node_si_child IS BOUND. + lv_tag_name = lo_node_si_child->get_name( ). + IF lv_tag_name = 't'. +*--------------------------------------------------------------------* +* §1.1 - "simple" strings +* Example: see above +*--------------------------------------------------------------------* + -value = unescape_string_value( lo_node_si_child->get_value( ) ). + ELSE. +*--------------------------------------------------------------------* +* §1.2 - rich text formatted strings +* it is sufficient to strip the ... tag from each -tag and concatenate these +* as long as rich text formatting is not supported (2do§1) ignore all info about formatting +* Example: see above +*--------------------------------------------------------------------* + CLEAR: lv_current_offset. + WHILE lo_node_si_child IS BOUND. " actually these children of are -tags + CLEAR: ls_rtf. + + " extracting rich text formating data + lo_node_r_child_rpr ?= lo_node_si_child->find_from_name_ns( name = 'rPr' uri = namespace-main ). + IF lo_node_r_child_rpr IS BOUND. + lo_font = load_style_font( lo_node_r_child_rpr ). + ls_rtf-font = lo_font->get_structure( ). + ENDIF. + ls_rtf-offset = lv_current_offset. + " extract the ... part of each -tag + lo_node_r_child_t ?= lo_node_si_child->find_from_name_ns( name = 't' uri = namespace-main ). + IF lo_node_r_child_t IS BOUND. + lv_node_value = unescape_string_value( lo_node_r_child_t->get_value( ) ). + CONCATENATE -value lv_node_value INTO -value RESPECTING BLANKS. + ls_rtf-length = strlen( lv_node_value ). + ENDIF. + + lv_current_offset = strlen( -value ). + APPEND ls_rtf TO -rtf. + + lo_node_si_child ?= lo_node_si_child->get_next( ). + + ENDWHILE. + ENDIF. + ENDIF. + + lo_node_si ?= lo_node_si->get_next( ). + ENDWHILE. + + ENDMETHOD. + + + METHOD load_styles. + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (wip ) 2012-11-25 +* - ... +* changes: renaming variables and types to naming conventions +* aligning code +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* + TYPES: BEGIN OF lty_xf, + applyalignment TYPE string, + applyborder TYPE string, + applyfill TYPE string, + applyfont TYPE string, + applynumberformat TYPE string, + applyprotection TYPE string, + borderid TYPE string, + fillid TYPE string, + fontid TYPE string, + numfmtid TYPE string, + pivotbutton TYPE string, + quoteprefix TYPE string, + xfid TYPE string, + END OF lty_xf. + + TYPES: BEGIN OF lty_alignment, + horizontal TYPE string, + indent TYPE string, + justifylastline TYPE string, + readingorder TYPE string, + relativeindent TYPE string, + shrinktofit TYPE string, + textrotation TYPE string, + vertical TYPE string, + wraptext TYPE string, + END OF lty_alignment. + + TYPES: BEGIN OF lty_protection, + hidden TYPE string, + locked TYPE string, + END OF lty_protection. + + DATA: lo_styles_xml TYPE REF TO if_ixml_document, + lo_style TYPE REF TO ycl_ecb_style, + + lt_num_formats TYPE ycl_ecb_style_number_format=>t_num_formats, + lt_fills TYPE t_fills, + lt_borders TYPE t_borders, + lt_fonts TYPE t_fonts, + + ls_num_format TYPE ycl_ecb_style_number_format=>t_num_format, + ls_fill TYPE REF TO ycl_ecb_style_fill, + ls_cell_border TYPE REF TO ycl_ecb_style_borders, + ls_font TYPE REF TO ycl_ecb_style_font, + + lo_node_cellxfs TYPE REF TO if_ixml_element, + lo_node_cellxfs_xf TYPE REF TO if_ixml_element, + lo_node_cellxfs_xf_alignment TYPE REF TO if_ixml_element, + lo_node_cellxfs_xf_protection TYPE REF TO if_ixml_element, + + lo_nodes_xf TYPE REF TO if_ixml_node_collection, + lo_iterator_cellxfs TYPE REF TO if_ixml_node_iterator, + + ls_xf TYPE lty_xf, + ls_alignment TYPE lty_alignment, + ls_protection TYPE lty_protection, + lv_index TYPE i. + +*--------------------------------------------------------------------* +* To build a complete style that fully describes how a cell looks like +* we need the various parts +* §1 - Numberformat +* §2 - Fillstyle +* §3 - Borders +* §4 - Font +* §5 - Alignment +* §6 - Protection + +* Following is an example how this part of a file could be set up +* ... +* parts with various formatinformation - see §1,§2,§3,§4 +* ... +* +* +* +* +* +* +* +* +* ... +* +*--------------------------------------------------------------------* + + lo_styles_xml = me->get_ixml_from_zip_archive( ip_path ). + +*--------------------------------------------------------------------* +* The styles are build up from +* §1 number formats +* §2 fill styles +* §3 border styles +* §4 fonts +* These need to be read before we can try to build up a complete +* style that describes the look of a cell +*--------------------------------------------------------------------* + lt_num_formats = load_style_num_formats( lo_styles_xml ). " §1 + lt_fills = load_style_fills( lo_styles_xml ). " §2 + lt_borders = load_style_borders( lo_styles_xml ). " §3 + lt_fonts = load_style_fonts( lo_styles_xml ). " §4 + +*--------------------------------------------------------------------* +* Now everything is prepared to build a "full" style +*--------------------------------------------------------------------* + lo_node_cellxfs = lo_styles_xml->find_from_name_ns( name = 'cellXfs' uri = namespace-main ). + IF lo_node_cellxfs IS BOUND. + lo_nodes_xf = lo_node_cellxfs->get_elements_by_tag_name_ns( name = 'xf' uri = namespace-main ). + lo_iterator_cellxfs = lo_nodes_xf->create_iterator( ). + lo_node_cellxfs_xf ?= lo_iterator_cellxfs->get_next( ). + WHILE lo_node_cellxfs_xf IS BOUND. + + lo_style = ip_excel->add_new_style( ). + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_cellxfs_xf + CHANGING + cp_structure = ls_xf ). +*--------------------------------------------------------------------* +* §2 fill style +*--------------------------------------------------------------------* + IF ls_xf-applyfill = '1' AND ls_xf-fillid IS NOT INITIAL. + lv_index = ls_xf-fillid + 1. + READ TABLE lt_fills INTO ls_fill INDEX lv_index. + IF sy-subrc = 0. + lo_style->fill = ls_fill. + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* §1 number format +*--------------------------------------------------------------------* + IF ls_xf-numfmtid IS NOT INITIAL. + READ TABLE lt_num_formats INTO ls_num_format WITH TABLE KEY id = ls_xf-numfmtid. + IF sy-subrc = 0. + lo_style->number_format = ls_num_format-format. + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* §3 border style +*--------------------------------------------------------------------* + IF ls_xf-applyborder = '1' AND ls_xf-borderid IS NOT INITIAL. + lv_index = ls_xf-borderid + 1. + READ TABLE lt_borders INTO ls_cell_border INDEX lv_index. + IF sy-subrc = 0. + lo_style->borders = ls_cell_border. + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* §4 font +*--------------------------------------------------------------------* + IF ls_xf-applyfont = '1' AND ls_xf-fontid IS NOT INITIAL. + lv_index = ls_xf-fontid + 1. + READ TABLE lt_fonts INTO ls_font INDEX lv_index. + IF sy-subrc = 0. + lo_style->font = ls_font. + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* §5 - Alignment +*--------------------------------------------------------------------* + lo_node_cellxfs_xf_alignment ?= lo_node_cellxfs_xf->find_from_name_ns( name = 'alignment' uri = namespace-main ). + IF lo_node_cellxfs_xf_alignment IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_cellxfs_xf_alignment + CHANGING + cp_structure = ls_alignment ). + IF ls_alignment-horizontal IS NOT INITIAL. + lo_style->alignment->horizontal = ls_alignment-horizontal. + ENDIF. + + IF ls_alignment-vertical IS NOT INITIAL. + lo_style->alignment->vertical = ls_alignment-vertical. + ENDIF. + + IF ls_alignment-textrotation IS NOT INITIAL. + lo_style->alignment->textrotation = ls_alignment-textrotation. + ENDIF. + + IF ls_alignment-wraptext = '1' OR ls_alignment-wraptext = 'true'. + lo_style->alignment->wraptext = abap_true. + ENDIF. + + IF ls_alignment-shrinktofit = '1' OR ls_alignment-shrinktofit = 'true'. + lo_style->alignment->shrinktofit = abap_true. + ENDIF. + + IF ls_alignment-indent IS NOT INITIAL. + lo_style->alignment->indent = ls_alignment-indent. + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* §6 - Protection +*--------------------------------------------------------------------* + lo_node_cellxfs_xf_protection ?= lo_node_cellxfs_xf->find_from_name_ns( name = 'protection' uri = namespace-main ). + IF lo_node_cellxfs_xf_protection IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_cellxfs_xf_protection + CHANGING + cp_structure = ls_protection ). + IF ls_protection-locked = '1' OR ls_protection-locked = 'true'. + lo_style->protection->locked = ycl_ecb_style_protection=>c_protection_locked. + ELSE. + lo_style->protection->locked = ycl_ecb_style_protection=>c_protection_unlocked. + ENDIF. + + IF ls_protection-hidden = '1' OR ls_protection-hidden = 'true'. + lo_style->protection->hidden = ycl_ecb_style_protection=>c_protection_hidden. + ELSE. + lo_style->protection->hidden = ycl_ecb_style_protection=>c_protection_unhidden. + ENDIF. + + ENDIF. + + INSERT lo_style INTO TABLE me->styles. + + lo_node_cellxfs_xf ?= lo_iterator_cellxfs->get_next( ). + + ENDWHILE. + ENDIF. + + ENDMETHOD. + + + METHOD load_style_borders. + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-25 +* - ... +* changes: renaming variables and types to naming conventions +* aligning code +* renaming variables to indicate what they are used for +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* + DATA: lo_node_border TYPE REF TO if_ixml_element, + lo_node_bordertype TYPE REF TO if_ixml_element, + lo_node_bordercolor TYPE REF TO if_ixml_element, + lo_cell_border TYPE REF TO ycl_ecb_style_borders, + lo_border TYPE REF TO ycl_ecb_style_border, + ls_color TYPE t_color. + +*--------------------------------------------------------------------* +* We need a table of used borderformats to build up our styles +* §1 A cell has 4 outer borders and 2 diagonal "borders" +* These borders can be formatted separately but the diagonal borders +* are always being formatted the same +* We'll parse through the -tag for each of the bordertypes +* §2 and read the corresponding formatting information + +* Following is an example how this part of a file could be set up +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +*--------------------------------------------------------------------* + lo_node_border ?= ip_xml->find_from_name_ns( name = 'border' uri = namespace-main ). + WHILE lo_node_border IS BOUND. + + CREATE OBJECT lo_cell_border. + +*--------------------------------------------------------------------* +* Diagonal borderlines are formatted the equally. Determine what kind of diagonal borders are present if any +*--------------------------------------------------------------------* +* DiagonalNone = 0 +* DiagonalUp = 1 +* DiagonalDown = 2 +* DiagonalBoth = 3 +*--------------------------------------------------------------------* + IF lo_node_border->get_attribute( 'diagonalDown' ) IS NOT INITIAL. + ADD ycl_ecb_style_borders=>c_diagonal_down TO lo_cell_border->diagonal_mode. + ENDIF. + + IF lo_node_border->get_attribute( 'diagonalUp' ) IS NOT INITIAL. + ADD ycl_ecb_style_borders=>c_diagonal_up TO lo_cell_border->diagonal_mode. + ENDIF. + + lo_node_bordertype ?= lo_node_border->get_first_child( ). + WHILE lo_node_bordertype IS BOUND. +*--------------------------------------------------------------------* +* §1 Determine what kind of border we are talking about +*--------------------------------------------------------------------* +* Up, down, left, right, diagonal +*--------------------------------------------------------------------* + CREATE OBJECT lo_border. + + CASE lo_node_bordertype->get_name( ). + + WHEN 'left'. + lo_cell_border->left = lo_border. + + WHEN 'right'. + lo_cell_border->right = lo_border. + + WHEN 'top'. + lo_cell_border->top = lo_border. + + WHEN 'bottom'. + lo_cell_border->down = lo_border. + + WHEN 'diagonal'. + lo_cell_border->diagonal = lo_border. + + ENDCASE. + +*--------------------------------------------------------------------* +* §2 Read the border-formatting +*--------------------------------------------------------------------* + lo_border->border_style = lo_node_bordertype->get_attribute( 'style' ). + lo_node_bordercolor ?= lo_node_bordertype->find_from_name_ns( name = 'color' uri = namespace-main ). + IF lo_node_bordercolor IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_bordercolor + CHANGING + cp_structure = ls_color ). + + lo_border->border_color-rgb = ls_color-rgb. + IF ls_color-indexed IS NOT INITIAL. + lo_border->border_color-indexed = ls_color-indexed. + ENDIF. + + IF ls_color-theme IS NOT INITIAL. + lo_border->border_color-theme = ls_color-theme. + ENDIF. + lo_border->border_color-tint = ls_color-tint. + ENDIF. + + lo_node_bordertype ?= lo_node_bordertype->get_next( ). + + ENDWHILE. + + INSERT lo_cell_border INTO TABLE ep_borders. + + lo_node_border ?= lo_node_border->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_style_fills. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Support gradientFill +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-25 +* - ... +* changes: renaming variables and types to naming conventions +* aligning code +* commenting on problems/future enhancements/todos we already know of or should decide upon +* adding comments to explain what we are trying to achieve +* renaming variables to indicate what they are used for +*--------------------------------------------------------------------* + DATA: lv_value TYPE string, + lo_node_fill TYPE REF TO if_ixml_element, + lo_node_fill_child TYPE REF TO if_ixml_element, + lo_node_bgcolor TYPE REF TO if_ixml_element, + lo_node_fgcolor TYPE REF TO if_ixml_element, + lo_node_stop TYPE REF TO if_ixml_element, + lo_fill TYPE REF TO ycl_ecb_style_fill, + ls_color TYPE t_color. + +*--------------------------------------------------------------------* +* We need a table of used fillformats to build up our styles + +* Following is an example how this part of a file could be set up +* +* +* +* +* +* +* +* +* +*--------------------------------------------------------------------* + + lo_node_fill ?= ip_xml->find_from_name_ns( name = 'fill' uri = namespace-main ). + WHILE lo_node_fill IS BOUND. + + CREATE OBJECT lo_fill. + lo_node_fill_child ?= lo_node_fill->get_first_child( ). + lv_value = lo_node_fill_child->get_name( ). + CASE lv_value. + +*--------------------------------------------------------------------* +* Patternfill +*--------------------------------------------------------------------* + WHEN 'patternFill'. + lo_fill->filltype = lo_node_fill_child->get_attribute( 'patternType' ). +*--------------------------------------------------------------------* +* Patternfill - background color +*--------------------------------------------------------------------* + lo_node_bgcolor = lo_node_fill_child->find_from_name_ns( name = 'bgColor' uri = namespace-main ). + IF lo_node_bgcolor IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_bgcolor + CHANGING + cp_structure = ls_color ). + + lo_fill->bgcolor-rgb = ls_color-rgb. + IF ls_color-indexed IS NOT INITIAL. + lo_fill->bgcolor-indexed = ls_color-indexed. + ENDIF. + + IF ls_color-theme IS NOT INITIAL. + lo_fill->bgcolor-theme = ls_color-theme. + ENDIF. + lo_fill->bgcolor-tint = ls_color-tint. + ENDIF. + +*--------------------------------------------------------------------* +* Patternfill - foreground color +*--------------------------------------------------------------------* + lo_node_fgcolor = lo_node_fill->find_from_name_ns( name = 'fgColor' uri = namespace-main ). + IF lo_node_fgcolor IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_fgcolor + CHANGING + cp_structure = ls_color ). + + lo_fill->fgcolor-rgb = ls_color-rgb. + IF ls_color-indexed IS NOT INITIAL. + lo_fill->fgcolor-indexed = ls_color-indexed. + ENDIF. + + IF ls_color-theme IS NOT INITIAL. + lo_fill->fgcolor-theme = ls_color-theme. + ENDIF. + lo_fill->fgcolor-tint = ls_color-tint. + ENDIF. + + +*--------------------------------------------------------------------* +* gradientFill +*--------------------------------------------------------------------* + WHEN 'gradientFill'. + lo_fill->gradtype-type = lo_node_fill_child->get_attribute( 'type' ). + lo_fill->gradtype-top = lo_node_fill_child->get_attribute( 'top' ). + lo_fill->gradtype-left = lo_node_fill_child->get_attribute( 'left' ). + lo_fill->gradtype-right = lo_node_fill_child->get_attribute( 'right' ). + lo_fill->gradtype-bottom = lo_node_fill_child->get_attribute( 'bottom' ). + lo_fill->gradtype-degree = lo_node_fill_child->get_attribute( 'degree' ). + FREE lo_node_stop. + lo_node_stop ?= lo_node_fill_child->find_from_name_ns( name = 'stop' uri = namespace-main ). + WHILE lo_node_stop IS BOUND. + IF lo_fill->gradtype-position1 IS INITIAL. + lo_fill->gradtype-position1 = lo_node_stop->get_attribute( 'position' ). + lo_node_bgcolor = lo_node_stop->find_from_name_ns( name = 'color' uri = namespace-main ). + IF lo_node_bgcolor IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_bgcolor + CHANGING + cp_structure = ls_color ). + + lo_fill->bgcolor-rgb = ls_color-rgb. + IF ls_color-indexed IS NOT INITIAL. + lo_fill->bgcolor-indexed = ls_color-indexed. + ENDIF. + + IF ls_color-theme IS NOT INITIAL. + lo_fill->bgcolor-theme = ls_color-theme. + ENDIF. + lo_fill->bgcolor-tint = ls_color-tint. + ENDIF. + ELSEIF lo_fill->gradtype-position2 IS INITIAL. + lo_fill->gradtype-position2 = lo_node_stop->get_attribute( 'position' ). + lo_node_fgcolor = lo_node_stop->find_from_name_ns( name = 'color' uri = namespace-main ). + IF lo_node_fgcolor IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node_fgcolor + CHANGING + cp_structure = ls_color ). + + lo_fill->fgcolor-rgb = ls_color-rgb. + IF ls_color-indexed IS NOT INITIAL. + lo_fill->fgcolor-indexed = ls_color-indexed. + ENDIF. + + IF ls_color-theme IS NOT INITIAL. + lo_fill->fgcolor-theme = ls_color-theme. + ENDIF. + lo_fill->fgcolor-tint = ls_color-tint. + ENDIF. + ELSEIF lo_fill->gradtype-position3 IS INITIAL. + lo_fill->gradtype-position3 = lo_node_stop->get_attribute( 'position' ). + "BGColor is filled already with position 1 no need to check again + ENDIF. + + lo_node_stop ?= lo_node_stop->get_next( ). + ENDWHILE. + + WHEN OTHERS. + + ENDCASE. + + + INSERT lo_fill INTO TABLE ep_fills. + + lo_node_fill ?= lo_node_fill->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_style_font. + + DATA: lo_node_font TYPE REF TO if_ixml_element, + lo_node2 TYPE REF TO if_ixml_element, + lo_font TYPE REF TO ycl_ecb_style_font, + ls_color TYPE t_color. + + lo_node_font = io_xml_element. + + CREATE OBJECT lo_font. +*--------------------------------------------------------------------* +* Bold +*--------------------------------------------------------------------* + IF lo_node_font->find_from_name_ns( name = 'b' uri = namespace-main ) IS BOUND. + lo_font->bold = abap_true. + ENDIF. + +*--------------------------------------------------------------------* +* Italic +*--------------------------------------------------------------------* + IF lo_node_font->find_from_name_ns( name = 'i' uri = namespace-main ) IS BOUND. + lo_font->italic = abap_true. + ENDIF. + +*--------------------------------------------------------------------* +* Underline +*--------------------------------------------------------------------* + lo_node2 = lo_node_font->find_from_name_ns( name = 'u' uri = namespace-main ). + IF lo_node2 IS BOUND. + lo_font->underline = abap_true. + lo_font->underline_mode = lo_node2->get_attribute( 'val' ). + ENDIF. + +*--------------------------------------------------------------------* +* StrikeThrough +*--------------------------------------------------------------------* + IF lo_node_font->find_from_name_ns( name = 'strike' uri = namespace-main ) IS BOUND. + lo_font->strikethrough = abap_true. + ENDIF. + +*--------------------------------------------------------------------* +* Fontsize +*--------------------------------------------------------------------* + lo_node2 = lo_node_font->find_from_name_ns( name = 'sz' uri = namespace-main ). + IF lo_node2 IS BOUND. + lo_font->size = lo_node2->get_attribute( 'val' ). + ENDIF. + +*--------------------------------------------------------------------* +* Fontname +*--------------------------------------------------------------------* + lo_node2 = lo_node_font->find_from_name_ns( name = 'name' uri = namespace-main ). + IF lo_node2 IS BOUND. + lo_font->name = lo_node2->get_attribute( 'val' ). + ELSE. + lo_node2 = lo_node_font->find_from_name_ns( name = 'rFont' uri = namespace-main ). + IF lo_node2 IS BOUND. + lo_font->name = lo_node2->get_attribute( 'val' ). + ENDIF. + ENDIF. + +*--------------------------------------------------------------------* +* Fontfamily +*--------------------------------------------------------------------* + lo_node2 = lo_node_font->find_from_name_ns( name = 'family' uri = namespace-main ). + IF lo_node2 IS BOUND. + lo_font->family = lo_node2->get_attribute( 'val' ). + ENDIF. + +*--------------------------------------------------------------------* +* Fontscheme +*--------------------------------------------------------------------* + lo_node2 = lo_node_font->find_from_name_ns( name = 'scheme' uri = namespace-main ). + IF lo_node2 IS BOUND. + lo_font->scheme = lo_node2->get_attribute( 'val' ). + ELSE. + CLEAR lo_font->scheme. + ENDIF. + +*--------------------------------------------------------------------* +* Fontcolor +*--------------------------------------------------------------------* + lo_node2 = lo_node_font->find_from_name_ns( name = 'color' uri = namespace-main ). + IF lo_node2 IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_node2 + CHANGING + cp_structure = ls_color ). + lo_font->color-rgb = ls_color-rgb. + IF ls_color-indexed IS NOT INITIAL. + lo_font->color-indexed = ls_color-indexed. + ENDIF. + + IF ls_color-theme IS NOT INITIAL. + lo_font->color-theme = ls_color-theme. + ENDIF. + lo_font->color-tint = ls_color-tint. + ENDIF. + + ro_font = lo_font. + + ENDMETHOD. + + + METHOD load_style_fonts. + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-25 +* - ... +* changes: renaming variables and types to naming conventions +* aligning code +* removing unused variables +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* + DATA: lo_node_font TYPE REF TO if_ixml_element, + lo_font TYPE REF TO ycl_ecb_style_font. + +*--------------------------------------------------------------------* +* We need a table of used fonts to build up our styles + +* Following is an example how this part of a file could be set up +* +* +* +* +* +* +* +*--------------------------------------------------------------------* + lo_node_font ?= ip_xml->find_from_name_ns( name = 'font' uri = namespace-main ). + WHILE lo_node_font IS BOUND. + + lo_font = load_style_font( lo_node_font ). + INSERT lo_font INTO TABLE ep_fonts. + + lo_node_font ?= lo_node_font->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_style_num_formats. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Explain gaps in predefined formats +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-25 +* - ... +* changes: renaming variables and types to naming conventions +* adding comments to explain what we are trying to achieve +* aligning code +*--------------------------------------------------------------------* + DATA: lo_node_numfmt TYPE REF TO if_ixml_element, + ls_num_format TYPE ycl_ecb_style_number_format=>t_num_format. + +*--------------------------------------------------------------------* +* We need a table of used numberformats to build up our styles +* there are two kinds of numberformats +* §1 built-in numberformats +* §2 and those that have been explicitly added by the createor of the excel-file +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* §1 built-in numberformats +*--------------------------------------------------------------------* + ep_num_formats = ycl_ecb_style_number_format=>mt_built_in_num_formats. + +*--------------------------------------------------------------------* +* §2 Get non-internal numberformats that are found in the file explicitly + +* Following is an example how this part of a file could be set up +* +* +* +*--------------------------------------------------------------------* + lo_node_numfmt ?= ip_xml->find_from_name_ns( name = 'numFmt' uri = namespace-main ). + WHILE lo_node_numfmt IS BOUND. + + CLEAR ls_num_format. + + CREATE OBJECT ls_num_format-format. + ls_num_format-format->format_code = lo_node_numfmt->get_attribute( 'formatCode' ). + ls_num_format-id = lo_node_numfmt->get_attribute( 'numFmtId' ). + INSERT ls_num_format INTO TABLE ep_num_formats. + + lo_node_numfmt ?= lo_node_numfmt->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_theme. + DATA theme TYPE REF TO ycl_ecb_theme. + DATA: lo_theme_xml TYPE REF TO if_ixml_document. + CREATE OBJECT theme. + lo_theme_xml = me->get_ixml_from_zip_archive( iv_path ). + theme->read_theme( io_theme_xml = lo_theme_xml ). + ip_excel->set_theme( io_theme = theme ). + ENDMETHOD. + + + METHOD load_workbook. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Move macro-reading from zcl_excel_reader_xlsm to this class +* autodetect existance of macro/vba content +* Allow inputparameter to explicitly tell reader to ignore vba-content +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-10 +* - ... +* changes: renaming variables to naming conventions +* aligning code +* removing unused variables +* adding me-> where possible +* renaming variables to indicate what they are used for +* adding comments to explain what we are trying to achieve +* renaming i/o parameters: previous input-parameter ip_path holds a (full) filename and not a path --> rename to iv_workbook_full_filename +* ip_excel renamed while being at it --> rename to io_excel +*--------------------------------------------------------------------* +* issue #232 - Read worksheetstate hidden/veryHidden +* - Stefan Schmoecker, 2012-11-11 +*--------------------------------------------------------------------* +* issue#235 - repeat rows/columns +* - Stefan Schmoecker, 2012-12-02 +* changes: correction in named ranges to correctly attach +* sheetlocal names/ranges to the correct sheet +*--------------------------------------------------------------------* +* issue#284 - Copied formulae ignored when reading excelfile +* - Stefan Schmoecker, 2013-08-02 +* changes: initialize area to hold referenced formulaedata +* after all worksheets have been read resolve formuae +*--------------------------------------------------------------------* + + CONSTANTS: lcv_shared_strings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + lcv_worksheet TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', + lcv_styles TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + lcv_vba_project TYPE string VALUE 'http://schemas.microsoft.com/office/2006/relationships/vbaProject', "#EC NEEDED for future incorporation of XLSM-reader + lcv_theme TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', +*--------------------------------------------------------------------* +* #232: Read worksheetstate hidden/veryHidden - begin data declarations +*--------------------------------------------------------------------* + lcv_worksheet_state_hidden TYPE string VALUE 'hidden', + lcv_worksheet_state_veryhidden TYPE string VALUE 'veryHidden'. +*--------------------------------------------------------------------* +* #232: Read worksheetstate hidden/veryHidden - end data declarations +*--------------------------------------------------------------------* + + DATA: + lv_path TYPE string, + lv_filename TYPE chkfile, + lv_full_filename TYPE string, + + lo_rels_workbook TYPE REF TO if_ixml_document, + lt_worksheets TYPE STANDARD TABLE OF t_relationship WITH NON-UNIQUE DEFAULT KEY, + lo_workbook TYPE REF TO if_ixml_document, + lv_workbook_index TYPE i, + lv_worksheet_path TYPE string, + ls_sheet TYPE t_sheet, + + lo_node TYPE REF TO if_ixml_element, + ls_relationship TYPE t_relationship, + lo_worksheet TYPE REF TO ycl_ecb_worksheet, + lo_range TYPE REF TO ycl_ecb_range, + lv_worksheet_title TYPE yecb_sheet_title, + lv_tabix TYPE i, " #235 - repeat rows/cols. Needed to link defined name to correct worksheet + + ls_range TYPE t_range, + lv_range_value TYPE yecb_range_value, + lv_position_temp TYPE i, +*--------------------------------------------------------------------* +* #229: Set active worksheet - begin data declarations +*--------------------------------------------------------------------* + lv_active_sheet_string TYPE string, + lv_zexcel_active_worksheet TYPE yecb_active_worksheet, +*--------------------------------------------------------------------* +* issue#235 - repeat rows/columns - added autofilter support while changing this section + lo_autofilter TYPE REF TO ycl_ecb_autofilter, + ls_area TYPE yecb_s_autofilter_area, + lv_col_start_alpha TYPE yecb_cell_column_alpha, + lv_col_end_alpha TYPE yecb_cell_column_alpha, + lv_row_start TYPE yecb_cell_row, + lv_row_end TYPE yecb_cell_row, + lv_regex TYPE string, + lv_range_value_1 TYPE yecb_range_value, + lv_range_value_2 TYPE yecb_range_value. +*--------------------------------------------------------------------* +* #229: Set active worksheet - end data declarations +*--------------------------------------------------------------------* + FIELD-SYMBOLS: TYPE t_relationship. + + +*--------------------------------------------------------------------* + +* §1 Get the position of files related to this workbook +* Usually this will be /xl/workbook.xml +* Thus the workbookroot will be /xl/ +* The position of all related files will be given in file +* /_rels/.rels and their positions +* be be given relative to the workbookroot + +* Following is an example how this file could be set up + +* +* +* +* +* +* +* +* +* +* +* +* §2 Load data that is relevant to the complete workbook +* Currently supported is: +* §2.1 Shared strings - This holds all strings that are used in all worksheets +* §2.2 Styles - This holds all styles that are used in all worksheets +* §2.3 Worksheets - For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet +* §2.4 [Themes] - not supported +* §2.5 [VBA (Macro)] - supported in class zcl_excel_reader_xlsm but should be moved here and autodetect +* ... +* +* §3 Some information is held in the workbookfile as well +* §3.1 Names and order of of worksheets +* §3.2 Active worksheet +* §3.3 Defined names +* ... +* Following is an example how this file could be set up + +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +*--------------------------------------------------------------------* + + CLEAR me->mt_ref_formulae. " ins issue#284 + +*--------------------------------------------------------------------* +* §1 Get the position of files related to this workbook +* Entry into this method is with the filename of the workbook +*--------------------------------------------------------------------* + CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH' + EXPORTING + full_name = iv_workbook_full_filename + IMPORTING + stripped_name = lv_filename + file_path = lv_path. + + CONCATENATE lv_path '_rels/' lv_filename '.rels' + INTO lv_full_filename. + lo_rels_workbook = me->get_ixml_from_zip_archive( lv_full_filename ). + + lo_node ?= lo_rels_workbook->find_from_name_ns( name = 'Relationship' uri = namespace-relationships ). "#EC NOTEXT + WHILE lo_node IS BOUND. + + me->fill_struct_from_attributes( EXPORTING ip_element = lo_node CHANGING cp_structure = ls_relationship ). + + CASE ls_relationship-type. + +*--------------------------------------------------------------------* +* §2.1 Shared strings - This holds all strings that are used in all worksheets +*--------------------------------------------------------------------* + WHEN lcv_shared_strings. + CONCATENATE lv_path ls_relationship-target + INTO lv_full_filename. + me->load_shared_strings( lv_full_filename ). + +*--------------------------------------------------------------------* +* §2.3 Worksheets +* For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet +* Shared strings and styles have to be present before we can start with creating the worksheets +* thus we only store this information for use when parsing the workbookfile for sheetinformations +*--------------------------------------------------------------------* + WHEN lcv_worksheet. + APPEND ls_relationship TO lt_worksheets. + +*--------------------------------------------------------------------* +* §2.2 Styles - This holds the styles that are used in all worksheets +*--------------------------------------------------------------------* + WHEN lcv_styles. + CONCATENATE lv_path ls_relationship-target + INTO lv_full_filename. + me->load_styles( ip_path = lv_full_filename + ip_excel = io_excel ). + me->load_dxf_styles( iv_path = lv_full_filename + io_excel = io_excel ). + WHEN lcv_theme. + CONCATENATE lv_path ls_relationship-target + INTO lv_full_filename. + me->load_theme( + EXPORTING + iv_path = lv_full_filename + ip_excel = io_excel " Excel creator + ). + WHEN OTHERS. + + ENDCASE. + + lo_node ?= lo_node->get_next( ). + + ENDWHILE. + +*--------------------------------------------------------------------* +* §3 Some information held in the workbookfile +*--------------------------------------------------------------------* + lo_workbook = me->get_ixml_from_zip_archive( iv_workbook_full_filename ). + +*--------------------------------------------------------------------* +* §3.1 Names and order of of worksheets +*--------------------------------------------------------------------* + lo_node ?= lo_workbook->find_from_name_ns( name = 'sheet' uri = namespace-main ). + lv_workbook_index = 1. + WHILE lo_node IS BOUND. + + me->fill_struct_from_attributes( EXPORTING + ip_element = lo_node + CHANGING + cp_structure = ls_sheet ). +*--------------------------------------------------------------------* +* Create new worksheet in workbook with correct name +*--------------------------------------------------------------------* + lv_worksheet_title = ls_sheet-name. + IF lv_workbook_index = 1. " First sheet has been added automatically by creating io_excel + lo_worksheet = io_excel->get_active_worksheet( ). + lo_worksheet->set_title( lv_worksheet_title ). + ELSE. + lo_worksheet = io_excel->add_new_worksheet( lv_worksheet_title ). + ENDIF. +*--------------------------------------------------------------------* +* #232 - Read worksheetstate hidden/veryHidden - begin of coding +* Set status hidden if necessary +*--------------------------------------------------------------------* + CASE ls_sheet-state. + + WHEN lcv_worksheet_state_hidden. + lo_worksheet->yif_ecb_sheet_properties~hidden = yif_ecb_sheet_properties=>c_hidden. + + WHEN lcv_worksheet_state_veryhidden. + lo_worksheet->yif_ecb_sheet_properties~hidden = yif_ecb_sheet_properties=>c_veryhidden. + + ENDCASE. +*--------------------------------------------------------------------* +* #232 - Read worksheetstate hidden/veryHidden - end of coding +*--------------------------------------------------------------------* +*--------------------------------------------------------------------* +* Load worksheetdata +*--------------------------------------------------------------------* + READ TABLE lt_worksheets ASSIGNING WITH KEY id = ls_sheet-id. + IF sy-subrc = 0. + -sheetid = ls_sheet-sheetid. "ins #235 - repeat rows/cols - needed to identify correct sheet + -localsheetid = |{ lv_workbook_index - 1 }|. + CONCATENATE lv_path -target + INTO lv_worksheet_path. + me->load_worksheet( ip_path = lv_worksheet_path + io_worksheet = lo_worksheet ). + -worksheet = lo_worksheet. + ENDIF. + + lo_node ?= lo_node->get_next( ). + ADD 1 TO lv_workbook_index. + + ENDWHILE. + SORT lt_worksheets BY sheetid. " needed for localSheetid -referencing + +*--------------------------------------------------------------------* +* #284: Set active worksheet - Resolve referenced formulae to +* explicit formulae those cells +*--------------------------------------------------------------------* + me->resolve_referenced_formulae( ). + " ins issue#284 +*--------------------------------------------------------------------* +* #229: Set active worksheet - begin coding +* §3.2 Active worksheet +*--------------------------------------------------------------------* + lv_zexcel_active_worksheet = 1. " First sheet = active sheet if nothing else specified. + lo_node ?= lo_workbook->find_from_name_ns( name = 'workbookView' uri = namespace-main ). + IF lo_node IS BOUND. + lv_active_sheet_string = lo_node->get_attribute( 'activeTab' ). + TRY. + lv_zexcel_active_worksheet = lv_active_sheet_string + 1. " EXCEL numbers the sheets from 0 onwards --> index into worksheettable is increased by one + CATCH cx_sy_conversion_error. "#EC NO_HANDLER - error here --> just use the default 1st sheet + ENDTRY. + ENDIF. + io_excel->set_active_sheet_index( lv_zexcel_active_worksheet ). +*--------------------------------------------------------------------* +* #229: Set active worksheet - end coding +*--------------------------------------------------------------------* + + +*--------------------------------------------------------------------* +* §3.3 Defined names +* So far I have encountered these +* - named ranges - sheetlocal +* - named ranges - workbookglobal +* - autofilters - sheetlocal ( special range ) +* - repeat rows/cols - sheetlocal ( special range ) +* +*--------------------------------------------------------------------* + lo_node ?= lo_workbook->find_from_name_ns( name = 'definedName' uri = namespace-main ). + WHILE lo_node IS BOUND. + + CLEAR lo_range. "ins issue #235 - repeat rows/cols + me->fill_struct_from_attributes( EXPORTING + ip_element = lo_node + CHANGING + cp_structure = ls_range ). + lv_range_value = lo_node->get_value( ). + + IF ls_range-localsheetid IS NOT INITIAL. " issue #163+ +* READ TABLE lt_worksheets ASSIGNING WITH KEY id = ls_range-localsheetid. "del issue #235 - repeat rows/cols " issue #163+ +* lo_range = -worksheet->add_new_range( ). "del issue #235 - repeat rows/cols " issue #163+ +*--------------------------------------------------------------------* +* issue#235 - repeat rows/columns - begin +*--------------------------------------------------------------------* + READ TABLE lt_worksheets ASSIGNING WITH KEY localsheetid = ls_range-localsheetid. + IF sy-subrc = 0. + CASE ls_range-name. + +*--------------------------------------------------------------------* +* insert autofilters +*--------------------------------------------------------------------* + WHEN ycl_ecb_autofilters=>c_autofilter. + " begin Dennis Schaaf + TRY. + ycl_ecb_common=>convert_range2column_a_row( EXPORTING i_range = lv_range_value + IMPORTING e_column_start = lv_col_start_alpha + e_column_end = lv_col_end_alpha + e_row_start = ls_area-row_start + e_row_end = ls_area-row_end ). + ls_area-col_start = ycl_ecb_common=>convert_column2int( lv_col_start_alpha ). + ls_area-col_end = ycl_ecb_common=>convert_column2int( lv_col_end_alpha ). + lo_autofilter = io_excel->add_new_autofilter( io_sheet = -worksheet ) . + lo_autofilter->set_filter_area( is_area = ls_area ). + CATCH ycx_ecb. + " we expected a range but it was not usable, so just ignore it + ENDTRY. + " end Dennis Schaaf + +*--------------------------------------------------------------------* +* repeat print rows/columns +*--------------------------------------------------------------------* + WHEN yif_ecb_sheet_printsettings=>gcv_print_title_name. + lo_range = -worksheet->add_new_range( ). + lo_range->name = yif_ecb_sheet_printsettings=>gcv_print_title_name. +*--------------------------------------------------------------------* +* This might be a temporary solution. Maybe ranges get be reworked +* to support areas consisting of multiple rectangles +* But for now just split the range into row and columnpart +*--------------------------------------------------------------------* + CLEAR:lv_range_value_1, + lv_range_value_2. + IF lv_range_value IS INITIAL. +* Empty --> nothing to do + ELSE. + IF lv_range_value(1) = `'`. " Escaped + lv_regex = `^('[^']*')+![^,]*,`. + ELSE. + lv_regex = `^[^!]*![^,]*,`. + ENDIF. +* Split into two ranges if necessary + FIND REGEX lv_regex IN lv_range_value MATCH LENGTH lv_position_temp. + IF sy-subrc = 0 AND lv_position_temp > 0. + lv_range_value_2 = lv_range_value+lv_position_temp. + SUBTRACT 1 FROM lv_position_temp. + lv_range_value_1 = lv_range_value(lv_position_temp). + ELSE. + lv_range_value_1 = lv_range_value. + ENDIF. + ENDIF. +* 1st range + ycl_ecb_common=>convert_range2column_a_row( EXPORTING i_range = lv_range_value_1 + i_allow_1dim_range = abap_true + IMPORTING e_column_start = lv_col_start_alpha + e_column_end = lv_col_end_alpha + e_row_start = lv_row_start + e_row_end = lv_row_end ). + IF lv_col_start_alpha IS NOT INITIAL. + -worksheet->yif_ecb_sheet_printsettings~set_print_repeat_columns( iv_columns_from = lv_col_start_alpha + iv_columns_to = lv_col_end_alpha ). + ENDIF. + IF lv_row_start IS NOT INITIAL. + -worksheet->yif_ecb_sheet_printsettings~set_print_repeat_rows( iv_rows_from = lv_row_start + iv_rows_to = lv_row_end ). + ENDIF. + +* 2nd range + ycl_ecb_common=>convert_range2column_a_row( EXPORTING i_range = lv_range_value_2 + i_allow_1dim_range = abap_true + IMPORTING e_column_start = lv_col_start_alpha + e_column_end = lv_col_end_alpha + e_row_start = lv_row_start + e_row_end = lv_row_end ). + IF lv_col_start_alpha IS NOT INITIAL. + -worksheet->yif_ecb_sheet_printsettings~set_print_repeat_columns( iv_columns_from = lv_col_start_alpha + iv_columns_to = lv_col_end_alpha ). + ENDIF. + IF lv_row_start IS NOT INITIAL. + -worksheet->yif_ecb_sheet_printsettings~set_print_repeat_rows( iv_rows_from = lv_row_start + iv_rows_to = lv_row_end ). + ENDIF. + + WHEN OTHERS. + + ENDCASE. + ENDIF. +*--------------------------------------------------------------------* +* issue#235 - repeat rows/columns - end +*--------------------------------------------------------------------* + ELSE. " issue #163+ + lo_range = io_excel->add_new_range( ). " issue #163+ + ENDIF. " issue #163+ +* lo_range = ip_excel->add_new_range( ). " issue #163- + IF lo_range IS BOUND. "ins issue #235 - repeat rows/cols + lo_range->name = ls_range-name. + lo_range->set_range_value( lv_range_value ). + ENDIF. "ins issue #235 - repeat rows/cols + lo_node ?= lo_node->get_next( ). + + ENDWHILE. + + ENDMETHOD. + + + METHOD load_worksheet. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Header/footer +* +* Please don't just delete these ToDos if they are not +* needed but leave a comment that states this +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, +* - ... +* changes: renaming variables to naming conventions +* aligning code (started) +* add a list of open ToDos here +* adding comments to explain what we are trying to achieve (started) +*--------------------------------------------------------------------* +* issue #345 - Dump on small pagemargins +* Took the chance to modularize this very long method +* by extracting the code that needed correction into +* own method ( load_worksheet_pagemargins ) +*--------------------------------------------------------------------* + TYPES: BEGIN OF lty_cell, + r TYPE string, + t TYPE string, + s TYPE string, + END OF lty_cell. + + TYPES: BEGIN OF lty_column, + min TYPE string, + max TYPE string, + width TYPE f, + customwidth TYPE string, + style TYPE string, + bestfit TYPE string, + collapsed TYPE string, + hidden TYPE string, + outlinelevel TYPE string, + END OF lty_column. + + TYPES: BEGIN OF lty_sheetview, + showgridlines TYPE yecb_show_gridlines, + tabselected TYPE string, + zoomscalenormal TYPE string, + workbookviewid TYPE string, + showrowcolheaders TYPE string, + righttoleft TYPE string, + END OF lty_sheetview. + + TYPES: BEGIN OF lty_mergecell, + ref TYPE string, + END OF lty_mergecell. + + TYPES: BEGIN OF lty_row, + r TYPE string, + customheight TYPE string, + ht TYPE f, + spans TYPE string, + thickbot TYPE string, + customformat TYPE string, + thicktop TYPE string, + collapsed TYPE string, + hidden TYPE string, + outlinelevel TYPE string, + END OF lty_row. + + TYPES: BEGIN OF lty_page_setup, + id TYPE string, + orientation TYPE string, + scale TYPE string, + fittoheight TYPE string, + fittowidth TYPE string, + papersize TYPE string, + paperwidth TYPE string, + paperheight TYPE string, + END OF lty_page_setup. + + TYPES: BEGIN OF lty_sheetformatpr, + customheight TYPE string, + defaultrowheight TYPE string, + customwidth TYPE string, + defaultcolwidth TYPE string, + END OF lty_sheetformatpr. + + TYPES: BEGIN OF lty_headerfooter, + alignwithmargins TYPE string, + differentoddeven TYPE string, + END OF lty_headerfooter. + + TYPES: BEGIN OF lty_tabcolor, + rgb TYPE string, + theme TYPE string, + END OF lty_tabcolor. + + TYPES: BEGIN OF lty_datavalidation, + type TYPE yecb_data_val_type, + allowblank TYPE flag, + showinputmessage TYPE flag, + showerrormessage TYPE flag, + showdropdown TYPE flag, + operator TYPE yecb_data_val_operator, + formula1 TYPE yecb_validation_formula1, + formula2 TYPE yecb_validation_formula1, + sqref TYPE string, + cell_column TYPE yecb_cell_column_alpha, + cell_column_to TYPE yecb_cell_column_alpha, + cell_row TYPE yecb_cell_row, + cell_row_to TYPE yecb_cell_row, + error TYPE string, + errortitle TYPE string, + prompt TYPE string, + prompttitle TYPE string, + errorstyle TYPE yecb_data_val_error_style, + END OF lty_datavalidation. + + + + CONSTANTS: lc_xml_attr_true TYPE string VALUE 'true', + lc_xml_attr_true_int TYPE string VALUE '1', + lc_rel_drawing TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', + lc_rel_hyperlink TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', + lc_rel_comments TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', + lc_rel_printer TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings'. + + DATA: lo_ixml_worksheet TYPE REF TO if_ixml_document, + lo_ixml_cells TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml_iterator2 TYPE REF TO if_ixml_node_iterator, + lo_ixml_row_elem TYPE REF TO if_ixml_element, + lo_ixml_cell_elem TYPE REF TO if_ixml_element, + ls_cell TYPE lty_cell, + lv_index TYPE i, + lv_index_temp TYPE i, + lo_ixml_value_elem TYPE REF TO if_ixml_element, + lo_ixml_formula_elem TYPE REF TO if_ixml_element, + lv_cell_value TYPE yecb_cell_value, + lv_cell_formula TYPE yecb_cell_formula, + lv_cell_column TYPE yecb_cell_column_alpha, + lv_cell_row TYPE yecb_cell_row, + lo_excel_style TYPE REF TO ycl_ecb_style, + lv_style_guid TYPE yecb_cell_style, + + lo_ixml_imension_elem TYPE REF TO if_ixml_element, "#+234 + lv_dimension_range TYPE string, "#+234 + + lo_ixml_sheetview_elem TYPE REF TO if_ixml_element, + ls_sheetview TYPE lty_sheetview, + lo_ixml_pane_elem TYPE REF TO if_ixml_element, + ls_excel_pane TYPE yecb_pane, + lv_pane_cell_row TYPE yecb_cell_row, + lv_pane_cell_col_a TYPE yecb_cell_column_alpha, + lv_pane_cell_col TYPE yecb_cell_column, + + lo_ixml_mergecells TYPE REF TO if_ixml_node_collection, + lo_ixml_mergecell_elem TYPE REF TO if_ixml_element, + ls_mergecell TYPE lty_mergecell, + lv_merge_column_start TYPE yecb_cell_column_alpha, + lv_merge_column_end TYPE yecb_cell_column_alpha, + lv_merge_row_start TYPE yecb_cell_row, + lv_merge_row_end TYPE yecb_cell_row, + + lo_ixml_sheetformatpr_elem TYPE REF TO if_ixml_element, + ls_sheetformatpr TYPE lty_sheetformatpr, + lv_height TYPE f, + + lo_ixml_headerfooter_elem TYPE REF TO if_ixml_element, + ls_headerfooter TYPE lty_headerfooter, + ls_odd_header TYPE yecb_s_worksheet_head_foot, + ls_odd_footer TYPE yecb_s_worksheet_head_foot, + ls_even_header TYPE yecb_s_worksheet_head_foot, + ls_even_footer TYPE yecb_s_worksheet_head_foot, + lo_ixml_hf_value_elem TYPE REF TO if_ixml_element, + + lo_ixml_pagesetup_elem TYPE REF TO if_ixml_element, + lo_ixml_sheetpr TYPE REF TO if_ixml_element, + lv_fit_to_page TYPE string, + ls_pagesetup TYPE lty_page_setup, + + lo_ixml_columns TYPE REF TO if_ixml_node_collection, + lo_ixml_column_elem TYPE REF TO if_ixml_element, + ls_column TYPE lty_column, + lv_column_alpha TYPE yecb_cell_column_alpha, + lo_column TYPE REF TO ycl_ecb_column, + lv_outline_level TYPE int4, + + lo_ixml_tabcolor TYPE REF TO if_ixml_element, + ls_tabcolor TYPE lty_tabcolor, + ls_excel_s_tabcolor TYPE yecb_s_tabcolor, + + lo_ixml_rows TYPE REF TO if_ixml_node_collection, + ls_row TYPE lty_row, + lv_max_col TYPE i, "for use with SPANS element +* lv_min_col TYPE i, "for use with SPANS element " not in use currently + lv_max_col_s TYPE char10, "for use with SPANS element + lv_min_col_s TYPE char10, "for use with SPANS element + lo_row TYPE REF TO ycl_ecb_row, +*--- End of current code aligning ------------------------------------------------------------------- + + lv_path TYPE string, + lo_ixml_node TYPE REF TO if_ixml_element, + ls_relationship TYPE t_relationship, + lo_ixml_rels_worksheet TYPE REF TO if_ixml_document, + lv_rels_worksheet_path TYPE string, + lv_stripped_name TYPE chkfile, + lv_dirname TYPE string, + + lt_external_hyperlinks TYPE gtt_external_hyperlinks, + ls_external_hyperlink LIKE LINE OF lt_external_hyperlinks, + + lo_ixml_datavalidations TYPE REF TO if_ixml_node_collection, + lo_ixml_datavalidation_elem TYPE REF TO if_ixml_element, + ls_datavalidation TYPE lty_datavalidation, + lo_data_validation TYPE REF TO ycl_ecb_data_validation, + lv_datavalidation_range TYPE string, + lt_datavalidation_range TYPE TABLE OF string, + lt_rtf TYPE yecb_t_rtf, + ex TYPE REF TO cx_root. + + FIELD-SYMBOLS: + TYPE t_shared_string. + +*--------------------------------------------------------------------* +* §2 We need to read the the file "\\_rels\.rels" because it tells +* us where in this folder structure the data for the workbook +* is located in the xlsx zip-archive +* +* The xlsx Zip-archive has generally the following folder structure: +* | +* |--> _rels +* |--> doc_Props +* |--> xl | +* |--> _rels +* |--> theme +* |--> worksheets +*--------------------------------------------------------------------* + + " Read Workbook Relationships + CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH' + EXPORTING + full_name = ip_path + IMPORTING + stripped_name = lv_stripped_name + file_path = lv_dirname. + CONCATENATE lv_dirname '_rels/' lv_stripped_name '.rels' + INTO lv_rels_worksheet_path. + TRY. " +#222 _rels/xxx.rels might not be present. If not found there can be no drawings --> just ignore this section + lo_ixml_rels_worksheet = me->get_ixml_from_zip_archive( lv_rels_worksheet_path ). + lo_ixml_node ?= lo_ixml_rels_worksheet->find_from_name_ns( name = 'Relationship' uri = namespace-relationships ). + CATCH ycx_ecb. "#EC NO_HANDLER +#222 + " +#222 No errorhandling necessary - node will be unbound if error occurs + ENDTRY. " +#222 + WHILE lo_ixml_node IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_node + CHANGING + cp_structure = ls_relationship ). + CONCATENATE lv_dirname ls_relationship-target INTO lv_path. + lv_path = resolve_path( lv_path ). + + CASE ls_relationship-type. + WHEN lc_rel_drawing. + " Read Drawings +* Issue # 339 Not all drawings are in the path mentioned below. +* Some Excel elements like textfields (which we don't support ) have a drawing-part in the relationsships +* but no "xl/drawings/_rels/drawing____.xml.rels" part. +* Since we don't support these there is no need to read them. Catching exceptions thrown +* in the "load_worksheet_drawing" shouldn't lead to an abortion of the reading + TRY. + me->load_worksheet_drawing( ip_path = lv_path + io_worksheet = io_worksheet ). + CATCH ycx_ecb. "--> then ignore it + ENDTRY. + + WHEN lc_rel_printer. + " Read Printer settings + + WHEN lc_rel_hyperlink. + MOVE-CORRESPONDING ls_relationship TO ls_external_hyperlink. + INSERT ls_external_hyperlink INTO TABLE lt_external_hyperlinks. + + WHEN lc_rel_comments. + TRY. + me->load_comments( ip_path = lv_path + io_worksheet = io_worksheet ). + CATCH ycx_ecb. + ENDTRY. + + WHEN OTHERS. + ENDCASE. + + lo_ixml_node ?= lo_ixml_node->get_next( ). + ENDWHILE. + + + lo_ixml_worksheet = me->get_ixml_from_zip_archive( ip_path ). + + + lo_ixml_tabcolor ?= lo_ixml_worksheet->find_from_name_ns( name = 'tabColor' uri = namespace-main ). + IF lo_ixml_tabcolor IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_tabcolor + CHANGING + cp_structure = ls_tabcolor ). +* Theme not supported yet + IF ls_tabcolor-rgb IS NOT INITIAL. + ls_excel_s_tabcolor-rgb = ls_tabcolor-rgb. + io_worksheet->set_tabcolor( ls_excel_s_tabcolor ). + ENDIF. + ENDIF. + + lo_ixml_rows = lo_ixml_worksheet->get_elements_by_tag_name_ns( name = 'row' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_rows->create_iterator( ). + lo_ixml_row_elem ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml_row_elem IS BOUND. + + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_row_elem + CHANGING + cp_structure = ls_row ). + SPLIT ls_row-spans AT ':' INTO lv_min_col_s lv_max_col_s. + lv_index = lv_max_col_s. + IF lv_index > lv_max_col. + lv_max_col = lv_index. + ENDIF. + lv_cell_row = ls_row-r. + lo_row = io_worksheet->get_row( lv_cell_row ). + IF ls_row-customheight = '1'. + lo_row->set_row_height( ip_row_height = ls_row-ht ip_custom_height = abap_true ). + ELSEIF ls_row-ht > 0. + lo_row->set_row_height( ip_row_height = ls_row-ht ip_custom_height = abap_false ). + ENDIF. + + IF ls_row-collapsed = lc_xml_attr_true + OR ls_row-collapsed = lc_xml_attr_true_int. + lo_row->set_collapsed( abap_true ). + ENDIF. + + IF ls_row-hidden = lc_xml_attr_true + OR ls_row-hidden = lc_xml_attr_true_int. + lo_row->set_visible( abap_false ). + ENDIF. + + IF ls_row-outlinelevel > ''. +* outline_level = condense( row-outlineLevel ). "For basis 7.02 and higher + CONDENSE ls_row-outlinelevel. + lv_outline_level = ls_row-outlinelevel. + IF lv_outline_level > 0. + lo_row->set_outline_level( lv_outline_level ). + ENDIF. + ENDIF. + + lo_ixml_cells = lo_ixml_row_elem->get_elements_by_tag_name_ns( name = 'c' uri = namespace-main ). + lo_ixml_iterator2 = lo_ixml_cells->create_iterator( ). + lo_ixml_cell_elem ?= lo_ixml_iterator2->get_next( ). + WHILE lo_ixml_cell_elem IS BOUND. + CLEAR: lv_cell_value, + lv_cell_formula, + lv_style_guid. + + fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_cell_elem CHANGING cp_structure = ls_cell ). + + lo_ixml_value_elem = lo_ixml_cell_elem->find_from_name_ns( name = 'v' uri = namespace-main ). + + CASE ls_cell-t. + WHEN 's'. " String values are stored as index in shared string table + IF lo_ixml_value_elem IS BOUND. + lv_index = lo_ixml_value_elem->get_value( ) + 1. + READ TABLE shared_strings ASSIGNING INDEX lv_index. + IF sy-subrc = 0. + lv_cell_value = -value. + lt_rtf = -rtf. + ENDIF. + ENDIF. + WHEN 'inlineStr'. " inlineStr values are kept in special node + lo_ixml_value_elem = lo_ixml_cell_elem->find_from_name_ns( name = 'is' uri = namespace-main ). + IF lo_ixml_value_elem IS BOUND. + lv_cell_value = lo_ixml_value_elem->get_value( ). + ENDIF. + WHEN OTHERS. "other types are stored directly + IF lo_ixml_value_elem IS BOUND. + lv_cell_value = lo_ixml_value_elem->get_value( ). + ENDIF. + ENDCASE. + + CLEAR lv_style_guid. + "read style based on index + IF ls_cell-s IS NOT INITIAL. + lv_index = ls_cell-s + 1. + READ TABLE styles INTO lo_excel_style INDEX lv_index. + IF sy-subrc = 0. + lv_style_guid = lo_excel_style->get_guid( ). + ENDIF. + ENDIF. + + lo_ixml_formula_elem = lo_ixml_cell_elem->find_from_name_ns( name = 'f' uri = namespace-main ). + IF lo_ixml_formula_elem IS BOUND. + lv_cell_formula = lo_ixml_formula_elem->get_value( ). +*--------------------------------------------------------------------* +* Begin of insertion issue#284 - Copied formulae not +*--------------------------------------------------------------------* + DATA: BEGIN OF ls_formula_attributes, + ref TYPE string, + si TYPE i, + t TYPE string, + END OF ls_formula_attributes, + ls_ref_formula TYPE ty_ref_formulae. + + fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_formula_elem CHANGING cp_structure = ls_formula_attributes ). + IF ls_formula_attributes-t = 'shared'. + ycl_ecb_common=>convert_columnrow2column_a_row( EXPORTING + i_columnrow = ls_cell-r + IMPORTING + e_column = lv_cell_column + e_row = lv_cell_row ). + + TRY. + CLEAR ls_ref_formula. + ls_ref_formula-sheet = io_worksheet. + ls_ref_formula-row = lv_cell_row. + ls_ref_formula-column = ycl_ecb_common=>convert_column2int( lv_cell_column ). + ls_ref_formula-si = ls_formula_attributes-si. + ls_ref_formula-ref = ls_formula_attributes-ref. + ls_ref_formula-formula = lv_cell_formula. + INSERT ls_ref_formula INTO TABLE me->mt_ref_formulae. + CATCH cx_root INTO ex. + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + previous = ex. + ENDTRY. + ENDIF. +*--------------------------------------------------------------------* +* End of insertion issue#284 - Copied formulae not +*--------------------------------------------------------------------* + ENDIF. + + IF lv_cell_value IS NOT INITIAL + OR lv_cell_formula IS NOT INITIAL + OR lv_style_guid IS NOT INITIAL. + ycl_ecb_common=>convert_columnrow2column_a_row( EXPORTING + i_columnrow = ls_cell-r + IMPORTING + e_column = lv_cell_column + e_row = lv_cell_row ). + io_worksheet->set_cell( ip_column = lv_cell_column " cell_elem Column + ip_row = lv_cell_row " cell_elem row_elem + ip_value = lv_cell_value " cell_elem Value + ip_formula = lv_cell_formula + ip_data_type = ls_cell-t + ip_style = lv_style_guid + it_rtf = lt_rtf ). + ENDIF. + lo_ixml_cell_elem ?= lo_ixml_iterator2->get_next( ). + ENDWHILE. + lo_ixml_row_elem ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + +*--------------------------------------------------------------------* +*#234 - column width not read correctly - begin of coding +* reason - libre office doesn't use SPAN in row - definitions +*--------------------------------------------------------------------* + IF lv_max_col = 0. + lo_ixml_imension_elem = lo_ixml_worksheet->find_from_name_ns( name = 'dimension' uri = namespace-main ). + IF lo_ixml_imension_elem IS BOUND. + lv_dimension_range = lo_ixml_imension_elem->get_attribute( 'ref' ). + IF lv_dimension_range CS ':'. + REPLACE REGEX '\D+\d+:(\D+)\d+' IN lv_dimension_range WITH '$1'. " Get max column + ELSE. + REPLACE REGEX '(\D+)\d+' IN lv_dimension_range WITH '$1'. " Get max column + ENDIF. + lv_max_col = ycl_ecb_common=>convert_column2int( lv_dimension_range ). + ENDIF. + ENDIF. +*--------------------------------------------------------------------* +*#234 - column width not read correctly - end of coding +*--------------------------------------------------------------------* + + "Get the customized column width + lo_ixml_columns = lo_ixml_worksheet->get_elements_by_tag_name_ns( name = 'col' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_columns->create_iterator( ). + lo_ixml_column_elem ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml_column_elem IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_column_elem + CHANGING + cp_structure = ls_column ). + lo_ixml_column_elem ?= lo_ixml_iterator->get_next( ). + IF ls_column-customwidth = lc_xml_attr_true + OR ls_column-customwidth = lc_xml_attr_true_int + OR ls_column-bestfit = lc_xml_attr_true + OR ls_column-bestfit = lc_xml_attr_true_int + OR ls_column-collapsed = lc_xml_attr_true + OR ls_column-collapsed = lc_xml_attr_true_int + OR ls_column-hidden = lc_xml_attr_true + OR ls_column-hidden = lc_xml_attr_true_int + OR ls_column-outlinelevel > '' + OR ls_column-style > ''. + lv_index = ls_column-min. + WHILE lv_index <= ls_column-max AND lv_index <= lv_max_col. + + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( lv_index ). + lo_column = io_worksheet->get_column( lv_column_alpha ). + + IF ls_column-customwidth = lc_xml_attr_true + OR ls_column-customwidth = lc_xml_attr_true_int + OR ls_column-width IS NOT INITIAL. "+#234 + lo_column->set_width( ls_column-width ). + ENDIF. + + IF ls_column-bestfit = lc_xml_attr_true + OR ls_column-bestfit = lc_xml_attr_true_int. + lo_column->set_auto_size( abap_true ). + ENDIF. + + IF ls_column-collapsed = lc_xml_attr_true + OR ls_column-collapsed = lc_xml_attr_true_int. + lo_column->set_collapsed( abap_true ). + ENDIF. + + IF ls_column-hidden = lc_xml_attr_true + OR ls_column-hidden = lc_xml_attr_true_int. + lo_column->set_visible( abap_false ). + ENDIF. + + IF ls_column-outlinelevel > ''. + CONDENSE ls_column-outlinelevel. + lv_outline_level = ls_column-outlinelevel. + IF lv_outline_level > 0. + lo_column->set_outline_level( lv_outline_level ). + ENDIF. + ENDIF. + + IF ls_column-style > ''. + lv_index_temp = ls_column-style + 1. + READ TABLE styles INTO lo_excel_style INDEX lv_index_temp. + DATA: dummy_zexcel_cell_style TYPE yecb_cell_style. + dummy_zexcel_cell_style = lo_excel_style->get_guid( ). + lo_column->set_column_style_by_guid( dummy_zexcel_cell_style ). + ENDIF. + + ADD 1 TO lv_index. + ENDWHILE. + ENDIF. + +* issue #367 - hide columns from + IF ls_column-max = ycl_ecb_common=>c_excel_sheet_max_col. " Max = very right column + IF ls_column-hidden = 1 " all hidden + AND ls_column-min > 0. + io_worksheet->yif_ecb_sheet_properties~hide_columns_from = ycl_ecb_common=>convert_column2alpha( ls_column-min ). + ELSEIF ls_column-style > ''. + lv_index_temp = ls_column-style + 1. + READ TABLE styles INTO lo_excel_style INDEX lv_index_temp. + dummy_zexcel_cell_style = lo_excel_style->get_guid( ). +* Set style for remaining columns + io_worksheet->yif_ecb_sheet_properties~set_style( dummy_zexcel_cell_style ). + ENDIF. + ENDIF. + + + ENDWHILE. + + "Now we need to get information from the sheetView node + lo_ixml_sheetview_elem = lo_ixml_worksheet->find_from_name_ns( name = 'sheetView' uri = namespace-main ). + fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_sheetview_elem CHANGING cp_structure = ls_sheetview ). + IF ls_sheetview-showgridlines IS INITIAL OR + ls_sheetview-showgridlines = lc_xml_attr_true OR + ls_sheetview-showgridlines = lc_xml_attr_true_int. + "If the attribute is not specified or set to true, we will show grid lines + ls_sheetview-showgridlines = abap_true. + ELSE. + ls_sheetview-showgridlines = abap_false. + ENDIF. + io_worksheet->set_show_gridlines( ls_sheetview-showgridlines ). + IF ls_sheetview-righttoleft = lc_xml_attr_true + OR ls_sheetview-righttoleft = lc_xml_attr_true_int. + io_worksheet->yif_ecb_sheet_properties~set_right_to_left( abap_true ). + ENDIF. + + + "Add merge cell information + lo_ixml_mergecells = lo_ixml_worksheet->get_elements_by_tag_name_ns( name = 'mergeCell' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_mergecells->create_iterator( ). + lo_ixml_mergecell_elem ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml_mergecell_elem IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_mergecell_elem + CHANGING + cp_structure = ls_mergecell ). + ycl_ecb_common=>convert_range2column_a_row( EXPORTING + i_range = ls_mergecell-ref + IMPORTING + e_column_start = lv_merge_column_start + e_column_end = lv_merge_column_end + e_row_start = lv_merge_row_start + e_row_end = lv_merge_row_end ). + lo_ixml_mergecell_elem ?= lo_ixml_iterator->get_next( ). + io_worksheet->set_merge( EXPORTING + ip_column_start = lv_merge_column_start + ip_column_end = lv_merge_column_end + ip_row = lv_merge_row_start + ip_row_to = lv_merge_row_end ). + ENDWHILE. + + " read sheet format properties + lo_ixml_sheetformatpr_elem = lo_ixml_worksheet->find_from_name_ns( name = 'sheetFormatPr' uri = namespace-main ). + IF lo_ixml_sheetformatpr_elem IS NOT INITIAL. + fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_sheetformatpr_elem CHANGING cp_structure = ls_sheetformatpr ). + IF ls_sheetformatpr-customheight = '1'. + lv_height = ls_sheetformatpr-defaultrowheight. + lo_row = io_worksheet->get_default_row( ). + lo_row->set_row_height( lv_height ). + ENDIF. + + " TODO... column + ENDIF. + + " Read in page margins + me->load_worksheet_pagemargins( EXPORTING + io_ixml_worksheet = lo_ixml_worksheet + io_worksheet = io_worksheet ). + +* FitToPage + lo_ixml_sheetpr ?= lo_ixml_worksheet->find_from_name_ns( name = 'pageSetUpPr' uri = namespace-main ). + IF lo_ixml_sheetpr IS BOUND. + + lv_fit_to_page = lo_ixml_sheetpr->get_attribute_ns( 'fitToPage' ). + IF lv_fit_to_page IS NOT INITIAL. + io_worksheet->sheet_setup->fit_to_page = 'X'. + ENDIF. + ENDIF. + " Read in page setup + lo_ixml_pagesetup_elem = lo_ixml_worksheet->find_from_name_ns( name = 'pageSetup' uri = namespace-main ). + IF lo_ixml_pagesetup_elem IS NOT INITIAL. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_pagesetup_elem + CHANGING + cp_structure = ls_pagesetup ). + io_worksheet->sheet_setup->orientation = ls_pagesetup-orientation. + io_worksheet->sheet_setup->scale = ls_pagesetup-scale. + io_worksheet->sheet_setup->paper_size = ls_pagesetup-papersize. + io_worksheet->sheet_setup->paper_height = ls_pagesetup-paperheight. + io_worksheet->sheet_setup->paper_width = ls_pagesetup-paperwidth. + IF io_worksheet->sheet_setup->fit_to_page = 'X'. + IF ls_pagesetup-fittowidth IS NOT INITIAL. + io_worksheet->sheet_setup->fit_to_width = ls_pagesetup-fittowidth. + ELSE. + io_worksheet->sheet_setup->fit_to_width = 1. " Default if not given - Excel doesn't write this to xml + ENDIF. + IF ls_pagesetup-fittoheight IS NOT INITIAL. + io_worksheet->sheet_setup->fit_to_height = ls_pagesetup-fittoheight. + ELSE. + io_worksheet->sheet_setup->fit_to_height = 1. " Default if not given - Excel doesn't write this to xml + ENDIF. + ENDIF. + ENDIF. + + + + " Read header footer + lo_ixml_headerfooter_elem = lo_ixml_worksheet->find_from_name_ns( name = 'headerFooter' uri = namespace-main ). + IF lo_ixml_headerfooter_elem IS NOT INITIAL. + fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_headerfooter_elem CHANGING cp_structure = ls_headerfooter ). + io_worksheet->sheet_setup->diff_oddeven_headerfooter = ls_headerfooter-differentoddeven. + + lo_ixml_hf_value_elem = lo_ixml_headerfooter_elem->find_from_name_ns( name = 'oddFooter' uri = namespace-main ). + IF lo_ixml_hf_value_elem IS NOT INITIAL. + ls_odd_footer-left_value = lo_ixml_hf_value_elem->get_value( ). + ENDIF. + + lo_ixml_hf_value_elem = lo_ixml_headerfooter_elem->find_from_name_ns( name = 'oddHeader' uri = namespace-main ). + IF lo_ixml_hf_value_elem IS NOT INITIAL. + ls_odd_header-left_value = lo_ixml_hf_value_elem->get_value( ). + ENDIF. + + lo_ixml_hf_value_elem = lo_ixml_headerfooter_elem->find_from_name_ns( name = 'evenFooter' uri = namespace-main ). + IF lo_ixml_hf_value_elem IS NOT INITIAL. + ls_even_footer-left_value = lo_ixml_hf_value_elem->get_value( ). + ENDIF. + + lo_ixml_hf_value_elem = lo_ixml_headerfooter_elem->find_from_name_ns( name = 'evenHeader' uri = namespace-main ). + IF lo_ixml_hf_value_elem IS NOT INITIAL. + ls_even_header-left_value = lo_ixml_hf_value_elem->get_value( ). + ENDIF. + +* 2do§1 Header/footer + " TODO.. get the rest. + + io_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_odd_header + ip_odd_footer = ls_odd_footer + ip_even_header = ls_even_header + ip_even_footer = ls_even_footer ). + + ENDIF. + + " Start fix 194 Read attributes HIDDEN, OUTLINELEVEL, COLLAPSED in ZCL_EXCEL_READER_2007 + " Read pane + lo_ixml_pane_elem = lo_ixml_sheetview_elem->find_from_name_ns( name = 'pane' uri = namespace-main ). + IF lo_ixml_pane_elem IS BOUND. + fill_struct_from_attributes( EXPORTING ip_element = lo_ixml_pane_elem CHANGING cp_structure = ls_excel_pane ). + " Issue #194 + " Replace REGEX with method from the common class + ycl_ecb_common=>convert_columnrow2column_a_row( EXPORTING + i_columnrow = ls_excel_pane-topleftcell + IMPORTING + e_column = lv_pane_cell_col_a " Cell Column + e_row = lv_pane_cell_row ). " Natural number + lv_pane_cell_col = ycl_ecb_common=>convert_column2int( lv_pane_cell_col_a ). + SUBTRACT 1 FROM: lv_pane_cell_col, + lv_pane_cell_row. + IF lv_pane_cell_col > 0 + AND lv_pane_cell_row > 0. + io_worksheet->freeze_panes( ip_num_rows = lv_pane_cell_row + ip_num_columns = lv_pane_cell_col ). + ELSEIF lv_pane_cell_row > 0. + io_worksheet->freeze_panes( ip_num_rows = lv_pane_cell_row ). + ELSE. + io_worksheet->freeze_panes( ip_num_columns = lv_pane_cell_col ). + ENDIF. + ENDIF. + " End fix 194 Read attributes HIDDEN, OUTLINELEVEL, COLLAPSED in ZCL_EXCEL_READER_2007 + + " Start fix 276 Read data validations + lo_ixml_datavalidations = lo_ixml_worksheet->get_elements_by_tag_name_ns( name = 'dataValidation' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_datavalidations->create_iterator( ). + lo_ixml_datavalidation_elem ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml_datavalidation_elem IS BOUND. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_datavalidation_elem + CHANGING + cp_structure = ls_datavalidation ). + CLEAR lo_ixml_formula_elem. + lo_ixml_formula_elem = lo_ixml_datavalidation_elem->find_from_name_ns( name = 'formula1' uri = namespace-main ). + IF lo_ixml_formula_elem IS BOUND. + ls_datavalidation-formula1 = lo_ixml_formula_elem->get_value( ). + ENDIF. + CLEAR lo_ixml_formula_elem. + lo_ixml_formula_elem = lo_ixml_datavalidation_elem->find_from_name_ns( name = 'formula2' uri = namespace-main ). + IF lo_ixml_formula_elem IS BOUND. + ls_datavalidation-formula2 = lo_ixml_formula_elem->get_value( ). + ENDIF. + SPLIT ls_datavalidation-sqref AT space INTO TABLE lt_datavalidation_range. + LOOP AT lt_datavalidation_range INTO lv_datavalidation_range. + ycl_ecb_common=>convert_range2column_a_row( EXPORTING + i_range = lv_datavalidation_range + IMPORTING + e_column_start = ls_datavalidation-cell_column + e_column_end = ls_datavalidation-cell_column_to + e_row_start = ls_datavalidation-cell_row + e_row_end = ls_datavalidation-cell_row_to ). + lo_data_validation = io_worksheet->add_new_data_validation( ). + lo_data_validation->type = ls_datavalidation-type. + lo_data_validation->allowblank = ls_datavalidation-allowblank. + IF ls_datavalidation-showinputmessage IS INITIAL. + lo_data_validation->showinputmessage = abap_false. + ELSE. + lo_data_validation->showinputmessage = abap_true. + ENDIF. + IF ls_datavalidation-showerrormessage IS INITIAL. + lo_data_validation->showerrormessage = abap_false. + ELSE. + lo_data_validation->showerrormessage = abap_true. + ENDIF. + IF ls_datavalidation-showdropdown IS INITIAL. + lo_data_validation->showdropdown = abap_false. + ELSE. + lo_data_validation->showdropdown = abap_true. + ENDIF. + lo_data_validation->operator = ls_datavalidation-operator. + lo_data_validation->formula1 = ls_datavalidation-formula1. + lo_data_validation->formula2 = ls_datavalidation-formula2. + lo_data_validation->prompttitle = ls_datavalidation-prompttitle. + lo_data_validation->prompt = ls_datavalidation-prompt. + lo_data_validation->errortitle = ls_datavalidation-errortitle. + lo_data_validation->error = ls_datavalidation-error. + lo_data_validation->errorstyle = ls_datavalidation-errorstyle. + lo_data_validation->cell_row = ls_datavalidation-cell_row. + lo_data_validation->cell_row_to = ls_datavalidation-cell_row_to. + lo_data_validation->cell_column = ls_datavalidation-cell_column. + lo_data_validation->cell_column_to = ls_datavalidation-cell_column_to. + ENDLOOP. + lo_ixml_datavalidation_elem ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + " End fix 276 Read data validations + + " Read hyperlinks + TRY. + me->load_worksheet_hyperlinks( io_ixml_worksheet = lo_ixml_worksheet + io_worksheet = io_worksheet + it_external_hyperlinks = lt_external_hyperlinks ). + CATCH ycx_ecb. " Ignore Hyperlink reading errors - pass everything we were able to identify + ENDTRY. + + TRY. + me->fill_row_outlines( io_worksheet = io_worksheet ). + CATCH ycx_ecb. " Ignore Hyperlink reading errors - pass everything we were able to identify + ENDTRY. + + " Issue #366 - conditional formatting + TRY. + me->load_worksheet_cond_format( io_ixml_worksheet = lo_ixml_worksheet + io_worksheet = io_worksheet ). + CATCH ycx_ecb. " Ignore Hyperlink reading errors - pass everything we were able to identify + ENDTRY. + + " Issue #377 - pagebreaks + TRY. + me->load_worksheet_pagebreaks( io_ixml_worksheet = lo_ixml_worksheet + io_worksheet = io_worksheet ). + CATCH ycx_ecb. " Ignore pagebreak reading errors - pass everything we were able to identify + ENDTRY. + + TRY. + me->load_worksheet_autofilter( io_ixml_worksheet = lo_ixml_worksheet + io_worksheet = io_worksheet ). + CATCH ycx_ecb. " Ignore autofilter reading errors - pass everything we were able to identify + ENDTRY. + + TRY. + me->load_worksheet_ignored_errors( io_ixml_worksheet = lo_ixml_worksheet + io_worksheet = io_worksheet ). + CATCH ycx_ecb. " Ignore "ignoredErrors" reading errors - pass everything we were able to identify + ENDTRY. + + ENDMETHOD. + + + METHOD load_worksheet_autofilter. + + TYPES: BEGIN OF lty_autofilter, + ref TYPE string, + END OF lty_autofilter. + + DATA: lo_ixml_autofilter_elem TYPE REF TO if_ixml_element, + lv_ref TYPE string, + lo_ixml_filter_column_coll TYPE REF TO if_ixml_node_collection, + lo_ixml_filter_column_iter TYPE REF TO if_ixml_node_iterator, + lo_ixml_filter_column TYPE REF TO if_ixml_element, + lv_col_id TYPE i, + lv_column TYPE yecb_cell_column, + lo_ixml_filters_coll TYPE REF TO if_ixml_node_collection, + lo_ixml_filters_iter TYPE REF TO if_ixml_node_iterator, + lo_ixml_filters TYPE REF TO if_ixml_element, + lo_ixml_filter_coll TYPE REF TO if_ixml_node_collection, + lo_ixml_filter_iter TYPE REF TO if_ixml_node_iterator, + lo_ixml_filter TYPE REF TO if_ixml_element, + lv_val TYPE string, + lo_autofilters TYPE REF TO ycl_ecb_autofilters, + lo_autofilter TYPE REF TO ycl_ecb_autofilter. + + lo_autofilters = io_worksheet->excel->get_autofilters_reference( ). + + lo_ixml_autofilter_elem = io_ixml_worksheet->find_from_name_ns( name = 'autoFilter' uri = namespace-main ). + IF lo_ixml_autofilter_elem IS BOUND. + lv_ref = lo_ixml_autofilter_elem->get_attribute_ns( 'ref' ). + + lo_ixml_filter_column_coll = lo_ixml_autofilter_elem->get_elements_by_tag_name_ns( name = 'filterColumn' uri = namespace-main ). + lo_ixml_filter_column_iter = lo_ixml_filter_column_coll->create_iterator( ). + lo_ixml_filter_column ?= lo_ixml_filter_column_iter->get_next( ). + WHILE lo_ixml_filter_column IS BOUND. + lv_col_id = lo_ixml_filter_column->get_attribute_ns( 'colId' ). + lv_column = lv_col_id + 1. + + lo_ixml_filters_coll = lo_ixml_filter_column->get_elements_by_tag_name_ns( name = 'filters' uri = namespace-main ). + lo_ixml_filters_iter = lo_ixml_filters_coll->create_iterator( ). + lo_ixml_filters ?= lo_ixml_filters_iter->get_next( ). + WHILE lo_ixml_filters IS BOUND. + + lo_ixml_filter_coll = lo_ixml_filter_column->get_elements_by_tag_name_ns( name = 'filter' uri = namespace-main ). + lo_ixml_filter_iter = lo_ixml_filter_coll->create_iterator( ). + lo_ixml_filter ?= lo_ixml_filter_iter->get_next( ). + WHILE lo_ixml_filter IS BOUND. + lv_val = lo_ixml_filter->get_attribute_ns( 'val' ). + + lo_autofilter = lo_autofilters->get( io_worksheet = io_worksheet ). + IF lo_autofilter IS NOT BOUND. + lo_autofilter = lo_autofilters->add( io_sheet = io_worksheet ). + ENDIF. + lo_autofilter->set_value( + i_column = lv_column + i_value = lv_val ). + + lo_ixml_filter ?= lo_ixml_filter_iter->get_next( ). + ENDWHILE. + + lo_ixml_filters ?= lo_ixml_filters_iter->get_next( ). + ENDWHILE. + + lo_ixml_filter_column ?= lo_ixml_filter_column_iter->get_next( ). + ENDWHILE. + ENDIF. + + ENDMETHOD. + + + METHOD load_worksheet_cond_format. + + DATA: lo_ixml_cond_formats TYPE REF TO if_ixml_node_collection, + lo_ixml_cond_format TYPE REF TO if_ixml_element, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml_rules TYPE REF TO if_ixml_node_collection, + lo_ixml_rule TYPE REF TO if_ixml_element, + lo_ixml_iterator2 TYPE REF TO if_ixml_node_iterator, + lo_style_cond TYPE REF TO ycl_ecb_style_cond, + lo_style_cond2 TYPE REF TO ycl_ecb_style_cond. + + + DATA: lv_area TYPE string, + lt_areas TYPE STANDARD TABLE OF string WITH NON-UNIQUE DEFAULT KEY, + lv_area_start_row TYPE yecb_cell_row, + lv_area_end_row TYPE yecb_cell_row, + lv_area_start_col TYPE yecb_cell_column_alpha, + lv_area_end_col TYPE yecb_cell_column_alpha, + lv_rule TYPE yecb_condition_rule. + + + lo_ixml_cond_formats = io_ixml_worksheet->get_elements_by_tag_name_ns( name = 'conditionalFormatting' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_cond_formats->create_iterator( ). + lo_ixml_cond_format ?= lo_ixml_iterator->get_next( ). + + WHILE lo_ixml_cond_format IS BOUND. + + CLEAR: lv_area, + lo_ixml_rule, + lo_style_cond. + +*--------------------------------------------------------------------* +* Get type of rule +*--------------------------------------------------------------------* + lo_ixml_rules = lo_ixml_cond_format->get_elements_by_tag_name_ns( name = 'cfRule' uri = namespace-main ). + lo_ixml_iterator2 = lo_ixml_rules->create_iterator( ). + lo_ixml_rule ?= lo_ixml_iterator2->get_next( ). + + WHILE lo_ixml_rule IS BOUND. + lv_rule = lo_ixml_rule->get_attribute_ns( 'type' ). + CLEAR lo_style_cond. + +*--------------------------------------------------------------------* +* Depending on ruletype get additional information +*--------------------------------------------------------------------* + CASE lv_rule. + + WHEN ycl_ecb_style_cond=>c_rule_cellis. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_ci( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + + WHEN ycl_ecb_style_cond=>c_rule_databar. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_db( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + + WHEN ycl_ecb_style_cond=>c_rule_expression. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_ex( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + + WHEN ycl_ecb_style_cond=>c_rule_iconset. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_is( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + + WHEN ycl_ecb_style_cond=>c_rule_colorscale. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_cs( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + + WHEN ycl_ecb_style_cond=>c_rule_top10. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_t10( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + + WHEN ycl_ecb_style_cond=>c_rule_above_average. + lo_style_cond = io_worksheet->add_new_style_cond( '' ). + load_worksheet_cond_format_aa( io_ixml_rule = lo_ixml_rule + io_style_cond = lo_style_cond ). + WHEN OTHERS. + ENDCASE. + + IF lo_style_cond IS BOUND. + lo_style_cond->rule = lv_rule. + lo_style_cond->priority = lo_ixml_rule->get_attribute_ns( 'priority' ). +*--------------------------------------------------------------------* +* Set area to which conditional formatting belongs +*--------------------------------------------------------------------* + lv_area = lo_ixml_cond_format->get_attribute_ns( 'sqref' ). + SPLIT lv_area AT space INTO TABLE lt_areas. + DELETE lt_areas WHERE table_line IS INITIAL. + LOOP AT lt_areas INTO lv_area. + + ycl_ecb_common=>convert_range2column_a_row( EXPORTING i_range = lv_area + IMPORTING e_column_start = lv_area_start_col + e_column_end = lv_area_end_col + e_row_start = lv_area_start_row + e_row_end = lv_area_end_row ). + lo_style_cond->add_range( ip_start_column = lv_area_start_col + ip_stop_column = lv_area_end_col + ip_start_row = lv_area_start_row + ip_stop_row = lv_area_end_row ). + ENDLOOP. + + ENDIF. + lo_ixml_rule ?= lo_ixml_iterator2->get_next( ). + ENDWHILE. + + + lo_ixml_cond_format ?= lo_ixml_iterator->get_next( ). + + ENDWHILE. + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_aa. + DATA: lv_dxf_style_index TYPE i, + val TYPE string. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_dxf_styles. + +*--------------------------------------------------------------------* +* above or below average +*--------------------------------------------------------------------* + val = io_ixml_rule->get_attribute_ns( 'aboveAverage' ). + IF val = '0'. " 0 = below average + io_style_cond->mode_above_average-above_average = space. + ELSE. + io_style_cond->mode_above_average-above_average = 'X'. " Not present or <> 0 --> we use above average + ENDIF. + +*--------------------------------------------------------------------* +* Equal average also? +*--------------------------------------------------------------------* + CLEAR val. + val = io_ixml_rule->get_attribute_ns( 'equalAverage' ). + IF val = '1'. " 0 = below average + io_style_cond->mode_above_average-equal_average = 'X'. + ELSE. + io_style_cond->mode_above_average-equal_average = ' '. " Not present or <> 1 --> we use not equal average + ENDIF. + +*--------------------------------------------------------------------* +* Standard deviation instead of value ( 2nd stddev, 3rd stdev ) +*--------------------------------------------------------------------* + CLEAR val. + val = io_ixml_rule->get_attribute_ns( 'stdDev' ). + CASE val. + WHEN 1 + OR 2 + OR 3. " These seem to be supported by excel - don't try anything more + io_style_cond->mode_above_average-standard_deviation = val. + ENDCASE. + +*--------------------------------------------------------------------* +* Cell formatting for top10 +*--------------------------------------------------------------------* + lv_dxf_style_index = io_ixml_rule->get_attribute_ns( 'dxfId' ). + READ TABLE me->mt_dxf_styles ASSIGNING WITH KEY dxf = lv_dxf_style_index. + IF sy-subrc = 0. + io_style_cond->mode_above_average-cell_style = -guid. + ENDIF. + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_ci. + DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml TYPE REF TO if_ixml_element, + lv_dxf_style_index TYPE i, + lo_excel_style LIKE LINE OF me->styles. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_dxf_styles. + + io_style_cond->mode_cellis-operator = io_ixml_rule->get_attribute_ns( 'operator' ). + lv_dxf_style_index = io_ixml_rule->get_attribute_ns( 'dxfId' ). + READ TABLE me->mt_dxf_styles ASSIGNING WITH KEY dxf = lv_dxf_style_index. + IF sy-subrc = 0. + io_style_cond->mode_cellis-cell_style = -guid. + ENDIF. + + lo_ixml_nodes ?= io_ixml_rule->get_elements_by_tag_name_ns( name = 'formula' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_nodes->create_iterator( ). + lo_ixml ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml IS BOUND. + + CASE sy-index. + WHEN 1. + io_style_cond->mode_cellis-formula = lo_ixml->get_value( ). + + WHEN 2. + io_style_cond->mode_cellis-formula2 = lo_ixml->get_value( ). + + WHEN OTHERS. + EXIT. + ENDCASE. + + lo_ixml ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_cs. + DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml TYPE REF TO if_ixml_element. + + + lo_ixml_nodes ?= io_ixml_rule->get_elements_by_tag_name_ns( name = 'cfvo' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_nodes->create_iterator( ). + lo_ixml ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml IS BOUND. + + CASE sy-index. + WHEN 1. + io_style_cond->mode_colorscale-cfvo1_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_colorscale-cfvo1_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 2. + io_style_cond->mode_colorscale-cfvo2_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_colorscale-cfvo2_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 3. + io_style_cond->mode_colorscale-cfvo3_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_colorscale-cfvo2_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN OTHERS. + EXIT. + ENDCASE. + + lo_ixml ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + + lo_ixml_nodes ?= io_ixml_rule->get_elements_by_tag_name_ns( name = 'color' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_nodes->create_iterator( ). + lo_ixml ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml IS BOUND. + + CASE sy-index. + WHEN 1. + io_style_cond->mode_colorscale-colorrgb1 = lo_ixml->get_attribute_ns( 'rgb' ). + + WHEN 2. + io_style_cond->mode_colorscale-colorrgb2 = lo_ixml->get_attribute_ns( 'rgb' ). + + WHEN 3. + io_style_cond->mode_colorscale-colorrgb3 = lo_ixml->get_attribute_ns( 'rgb' ). + + WHEN OTHERS. + EXIT. + ENDCASE. + + lo_ixml ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_db. + DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml TYPE REF TO if_ixml_element. + + lo_ixml ?= io_ixml_rule->find_from_name_ns( name = 'color' uri = namespace-main ). + IF lo_ixml IS BOUND. + io_style_cond->mode_databar-colorrgb = lo_ixml->get_attribute_ns( 'rgb' ). + ENDIF. + + lo_ixml_nodes ?= io_ixml_rule->get_elements_by_tag_name_ns( name = 'cfvo' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_nodes->create_iterator( ). + lo_ixml ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml IS BOUND. + + CASE sy-index. + WHEN 1. + io_style_cond->mode_databar-cfvo1_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_databar-cfvo1_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 2. + io_style_cond->mode_databar-cfvo2_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_databar-cfvo2_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN OTHERS. + EXIT. + ENDCASE. + + lo_ixml ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_ex. + DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml TYPE REF TO if_ixml_element, + lv_dxf_style_index TYPE i, + lo_excel_style LIKE LINE OF me->styles. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_dxf_styles. + + lv_dxf_style_index = io_ixml_rule->get_attribute_ns( 'dxfId' ). + READ TABLE me->mt_dxf_styles ASSIGNING WITH KEY dxf = lv_dxf_style_index. + IF sy-subrc = 0. + io_style_cond->mode_expression-cell_style = -guid. + ENDIF. + + lo_ixml_nodes ?= io_ixml_rule->get_elements_by_tag_name_ns( name = 'formula' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_nodes->create_iterator( ). + lo_ixml ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml IS BOUND. + + CASE sy-index. + WHEN 1. + io_style_cond->mode_expression-formula = lo_ixml->get_value( ). + + + WHEN OTHERS. + EXIT. + ENDCASE. + + lo_ixml ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_is. + DATA: lo_ixml_nodes TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml TYPE REF TO if_ixml_element, + lo_ixml_rule_iconset TYPE REF TO if_ixml_element. + + lo_ixml_rule_iconset ?= io_ixml_rule->get_first_child( ). + io_style_cond->mode_iconset-iconset = lo_ixml_rule_iconset->get_attribute_ns( 'iconSet' ). + io_style_cond->mode_iconset-showvalue = lo_ixml_rule_iconset->get_attribute_ns( 'showValue' ). + lo_ixml_nodes ?= lo_ixml_rule_iconset->get_elements_by_tag_name_ns( name = 'cfvo' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_nodes->create_iterator( ). + lo_ixml ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml IS BOUND. + + CASE sy-index. + WHEN 1. + io_style_cond->mode_iconset-cfvo1_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_iconset-cfvo1_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 2. + io_style_cond->mode_iconset-cfvo2_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_iconset-cfvo2_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 3. + io_style_cond->mode_iconset-cfvo3_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_iconset-cfvo3_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 4. + io_style_cond->mode_iconset-cfvo4_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_iconset-cfvo4_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN 5. + io_style_cond->mode_iconset-cfvo5_type = lo_ixml->get_attribute_ns( 'type' ). + io_style_cond->mode_iconset-cfvo5_value = lo_ixml->get_attribute_ns( 'val' ). + + WHEN OTHERS. + EXIT. + ENDCASE. + + lo_ixml ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + + ENDMETHOD. + + + METHOD load_worksheet_cond_format_t10. + DATA: lv_dxf_style_index TYPE i. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_dxf_styles. + + io_style_cond->mode_top10-topxx_count = io_ixml_rule->get_attribute_ns( 'rank' ). " Top10, Top20, Top 50... + + io_style_cond->mode_top10-percent = io_ixml_rule->get_attribute_ns( 'percent' ). " Top10 percent instead of Top10 values + IF io_style_cond->mode_top10-percent = '1'. + io_style_cond->mode_top10-percent = 'X'. + ELSE. + io_style_cond->mode_top10-percent = ' '. + ENDIF. + + io_style_cond->mode_top10-bottom = io_ixml_rule->get_attribute_ns( 'bottom' ). " Bottom10 instead of Top10 + IF io_style_cond->mode_top10-bottom = '1'. + io_style_cond->mode_top10-bottom = 'X'. + ELSE. + io_style_cond->mode_top10-bottom = ' '. + ENDIF. +*--------------------------------------------------------------------* +* Cell formatting for top10 +*--------------------------------------------------------------------* + lv_dxf_style_index = io_ixml_rule->get_attribute_ns( 'dxfId' ). + READ TABLE me->mt_dxf_styles ASSIGNING WITH KEY dxf = lv_dxf_style_index. + IF sy-subrc = 0. + io_style_cond->mode_top10-cell_style = -guid. + ENDIF. + + ENDMETHOD. + + + METHOD load_worksheet_drawing. + + TYPES: BEGIN OF t_c_nv_pr, + name TYPE string, + id TYPE string, + END OF t_c_nv_pr. + + TYPES: BEGIN OF t_blip, + cstate TYPE string, + embed TYPE string, + END OF t_blip. + + TYPES: BEGIN OF t_chart, + id TYPE string, + END OF t_chart. + + CONSTANTS: lc_xml_attr_true TYPE string VALUE 'true', + lc_xml_attr_true_int TYPE string VALUE '1'. + CONSTANTS: lc_rel_chart TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', + lc_rel_image TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'. + + DATA: drawing TYPE REF TO if_ixml_document, + anchors TYPE REF TO if_ixml_node_collection, + node TYPE REF TO if_ixml_element, + coll_length TYPE i, + iterator TYPE REF TO if_ixml_node_iterator, + anchor_elem TYPE REF TO if_ixml_element, + + relationship TYPE t_relationship, + rel_drawings TYPE t_rel_drawings, + rel_drawing TYPE t_rel_drawing, + rels_drawing TYPE REF TO if_ixml_document, + rels_drawing_path TYPE string, + stripped_name TYPE chkfile, + dirname TYPE string, + + path TYPE string, + path2 TYPE text255, + file_ext2 TYPE char10. + + " Read Workbook Relationships + CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH' + EXPORTING + full_name = ip_path + IMPORTING + stripped_name = stripped_name + file_path = dirname. + CONCATENATE dirname '_rels/' stripped_name '.rels' + INTO rels_drawing_path. + rels_drawing_path = resolve_path( rels_drawing_path ). + rels_drawing = me->get_ixml_from_zip_archive( rels_drawing_path ). + node ?= rels_drawing->find_from_name_ns( name = 'Relationship' uri = namespace-relationships ). + WHILE node IS BOUND. + fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = relationship ). + + rel_drawing-id = relationship-id. + + CONCATENATE dirname relationship-target INTO path. + path = resolve_path( path ). + rel_drawing-content = me->get_from_zip_archive( path ). "------------> This is for template usage + + path2 = path. + ycl_ecb_common=>split_file( EXPORTING ip_file = path2 + IMPORTING ep_extension = file_ext2 ). + rel_drawing-file_ext = file_ext2. + + "-------------Added by Alessandro Iannacci - Should load graph xml + CASE relationship-type. + WHEN lc_rel_chart. + "Read chart xml + rel_drawing-content_xml = me->get_ixml_from_zip_archive( path ). + WHEN OTHERS. + ENDCASE. + "---------------------------- + + + APPEND rel_drawing TO rel_drawings. + + node ?= node->get_next( ). + ENDWHILE. + + drawing = me->get_ixml_from_zip_archive( ip_path ). + +* one-cell anchor ************** + anchors = drawing->get_elements_by_tag_name_ns( name = 'oneCellAnchor' uri = namespace-xdr ). + coll_length = anchors->get_length( ). + iterator = anchors->create_iterator( ). + DO coll_length TIMES. + anchor_elem ?= iterator->get_next( ). + + CALL METHOD me->load_drawing_anchor + EXPORTING + io_anchor_element = anchor_elem + io_worksheet = io_worksheet + it_related_drawings = rel_drawings. + + ENDDO. + +* two-cell anchor ****************** + anchors = drawing->get_elements_by_tag_name_ns( name = 'twoCellAnchor' uri = namespace-xdr ). + coll_length = anchors->get_length( ). + iterator = anchors->create_iterator( ). + DO coll_length TIMES. + anchor_elem ?= iterator->get_next( ). + + CALL METHOD me->load_drawing_anchor + EXPORTING + io_anchor_element = anchor_elem + io_worksheet = io_worksheet + it_related_drawings = rel_drawings. + + ENDDO. + + ENDMETHOD. + + METHOD load_comments. + DATA: lo_comments_xml TYPE REF TO if_ixml_document, + lo_node_comment TYPE REF TO if_ixml_element, + lo_node_comment_child TYPE REF TO if_ixml_element, + lo_node_r_child_t TYPE REF TO if_ixml_element, + lo_attr TYPE REF TO if_ixml_attribute, + lo_comment TYPE REF TO ycl_ecb_comment, + lv_comment_text TYPE string, + lv_node_value TYPE string, + lv_attr_value TYPE string. + + lo_comments_xml = me->get_ixml_from_zip_archive( ip_path ). + + lo_node_comment ?= lo_comments_xml->find_from_name_ns( name = 'comment' uri = namespace-main ). + WHILE lo_node_comment IS BOUND. + + CLEAR lv_comment_text. + lo_attr = lo_node_comment->get_attribute_node_ns( name = 'ref' ). + lv_attr_value = lo_attr->get_value( ). + + lo_node_comment_child ?= lo_node_comment->get_first_child( ). + WHILE lo_node_comment_child IS BOUND. + " There will be rPr nodes here, but we do not support them + " in comments right now; see 'load_shared_strings' for handling. + " Extract the ... part of each -tag + lo_node_r_child_t ?= lo_node_comment_child->find_from_name_ns( name = 't' uri = namespace-main ). + IF lo_node_r_child_t IS BOUND. + lv_node_value = lo_node_r_child_t->get_value( ). + CONCATENATE lv_comment_text lv_node_value INTO lv_comment_text RESPECTING BLANKS. + ENDIF. + lo_node_comment_child ?= lo_node_comment_child->get_next( ). + ENDWHILE. + + CREATE OBJECT lo_comment. + lo_comment->set_text( ip_ref = lv_attr_value ip_text = lv_comment_text ). + io_worksheet->add_comment( lo_comment ). + + lo_node_comment ?= lo_node_comment->get_next( ). + ENDWHILE. + + ENDMETHOD. + + METHOD load_worksheet_hyperlinks. + + DATA: lo_ixml_hyperlinks TYPE REF TO if_ixml_node_collection, + lo_ixml_hyperlink TYPE REF TO if_ixml_element, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lv_row_start TYPE yecb_cell_row, + lv_row_end TYPE yecb_cell_row, + lv_column_start TYPE yecb_cell_column_alpha, + lv_column_end TYPE yecb_cell_column_alpha, + lv_is_internal TYPE abap_bool, + lv_url TYPE string, + lv_value TYPE yecb_cell_value. + + DATA: BEGIN OF ls_hyperlink, + ref TYPE string, + display TYPE string, + location TYPE string, + tooltip TYPE string, + r_id TYPE string, + END OF ls_hyperlink. + + FIELD-SYMBOLS: LIKE LINE OF it_external_hyperlinks. + + lo_ixml_hyperlinks = io_ixml_worksheet->get_elements_by_tag_name_ns( name = 'hyperlink' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_hyperlinks->create_iterator( ). + lo_ixml_hyperlink ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml_hyperlink IS BOUND. + + CLEAR ls_hyperlink. + CLEAR lv_url. + + ls_hyperlink-ref = lo_ixml_hyperlink->get_attribute_ns( 'ref' ). + ls_hyperlink-display = lo_ixml_hyperlink->get_attribute_ns( 'display' ). + ls_hyperlink-location = lo_ixml_hyperlink->get_attribute_ns( 'location' ). + ls_hyperlink-tooltip = lo_ixml_hyperlink->get_attribute_ns( 'tooltip' ). + ls_hyperlink-r_id = lo_ixml_hyperlink->get_attribute_ns( name = 'id' uri = namespace-r ). + IF ls_hyperlink-r_id IS INITIAL. " Internal link + lv_is_internal = abap_true. + lv_url = ls_hyperlink-location. + ELSE. " External link + READ TABLE it_external_hyperlinks ASSIGNING WITH TABLE KEY id = ls_hyperlink-r_id. + IF sy-subrc = 0. + lv_is_internal = abap_false. + lv_url = -target. + ENDIF. + ENDIF. + + IF lv_url IS NOT INITIAL. " because of unsupported external links + + ycl_ecb_common=>convert_range2column_a_row( + EXPORTING + i_range = ls_hyperlink-ref + IMPORTING + e_column_start = lv_column_start + e_column_end = lv_column_end + e_row_start = lv_row_start + e_row_end = lv_row_end ). + + io_worksheet->set_area_hyperlink( + EXPORTING + ip_column_start = lv_column_start + ip_column_end = lv_column_end + ip_row = lv_row_start + ip_row_to = lv_row_end + ip_url = lv_url + ip_is_internal = lv_is_internal ). + + ENDIF. + + lo_ixml_hyperlink ?= lo_ixml_iterator->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD load_worksheet_ignored_errors. + + DATA: lo_ixml_ignored_errors TYPE REF TO if_ixml_node_collection, + lo_ixml_ignored_error TYPE REF TO if_ixml_element, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + ls_ignored_error TYPE ycl_ecb_worksheet=>mty_s_ignored_errors, + lt_ignored_errors TYPE ycl_ecb_worksheet=>mty_th_ignored_errors. + + DATA: BEGIN OF ls_raw_ignored_error, + sqref TYPE string, + evalerror TYPE string, + twodigittextyear TYPE string, + numberstoredastext TYPE string, + formula TYPE string, + formularange TYPE string, + unlockedformula TYPE string, + emptycellreference TYPE string, + listdatavalidation TYPE string, + calculatedcolumn TYPE string, + END OF ls_raw_ignored_error. + + CLEAR lt_ignored_errors. + + lo_ixml_ignored_errors = io_ixml_worksheet->get_elements_by_tag_name_ns( name = 'ignoredError' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_ignored_errors->create_iterator( ). + lo_ixml_ignored_error ?= lo_ixml_iterator->get_next( ). + + WHILE lo_ixml_ignored_error IS BOUND. + + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_ignored_error + CHANGING + cp_structure = ls_raw_ignored_error ). + + CLEAR ls_ignored_error. + ls_ignored_error-cell_coords = ls_raw_ignored_error-sqref. + ls_ignored_error-eval_error = boolc( ls_raw_ignored_error-evalerror = '1' ). + ls_ignored_error-two_digit_text_year = boolc( ls_raw_ignored_error-twodigittextyear = '1' ). + ls_ignored_error-number_stored_as_text = boolc( ls_raw_ignored_error-numberstoredastext = '1' ). + ls_ignored_error-formula = boolc( ls_raw_ignored_error-formula = '1' ). + ls_ignored_error-formula_range = boolc( ls_raw_ignored_error-formularange = '1' ). + ls_ignored_error-unlocked_formula = boolc( ls_raw_ignored_error-unlockedformula = '1' ). + ls_ignored_error-empty_cell_reference = boolc( ls_raw_ignored_error-emptycellreference = '1' ). + ls_ignored_error-list_data_validation = boolc( ls_raw_ignored_error-listdatavalidation = '1' ). + ls_ignored_error-calculated_column = boolc( ls_raw_ignored_error-calculatedcolumn = '1' ). + + INSERT ls_ignored_error INTO TABLE lt_ignored_errors. + + lo_ixml_ignored_error ?= lo_ixml_iterator->get_next( ). + + ENDWHILE. + + io_worksheet->set_ignored_errors( lt_ignored_errors ). + + ENDMETHOD. + + + METHOD load_worksheet_pagebreaks. + + DATA: lo_node TYPE REF TO if_ixml_element, + lo_ixml_rowbreaks TYPE REF TO if_ixml_node_collection, + lo_ixml_colbreaks TYPE REF TO if_ixml_node_collection, + lo_ixml_iterator TYPE REF TO if_ixml_node_iterator, + lo_ixml_rowbreak TYPE REF TO if_ixml_element, + lo_ixml_colbreak TYPE REF TO if_ixml_element, + lo_style_cond TYPE REF TO ycl_ecb_style_cond, + lv_count TYPE i. + + + DATA: lt_pagebreaks TYPE STANDARD TABLE OF ycl_ecb_worksheet_pagebreaks=>ts_pagebreak_at, + lo_pagebreaks TYPE REF TO ycl_ecb_worksheet_pagebreaks. + + FIELD-SYMBOLS: LIKE LINE OF lt_pagebreaks. + FIELD-SYMBOLS: LIKE LINE OF lt_pagebreaks. + +*--------------------------------------------------------------------* +* Get minimal number of cells where to add pagebreaks +* Since rows and columns are handled in separate nodes +* Build table to identify these cells +*--------------------------------------------------------------------* + lo_node ?= io_ixml_worksheet->find_from_name_ns( name = 'rowBreaks' uri = namespace-main ). + CHECK lo_node IS BOUND. + lo_ixml_rowbreaks = lo_node->get_elements_by_tag_name_ns( name = 'brk' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_rowbreaks->create_iterator( ). + lo_ixml_rowbreak ?= lo_ixml_iterator->get_next( ). + WHILE lo_ixml_rowbreak IS BOUND. + APPEND INITIAL LINE TO lt_pagebreaks ASSIGNING . + -cell_row = lo_ixml_rowbreak->get_attribute_ns( 'id' ). + + lo_ixml_rowbreak ?= lo_ixml_iterator->get_next( ). + ENDWHILE. + CHECK IS ASSIGNED. + + lo_node ?= io_ixml_worksheet->find_from_name_ns( name = 'colBreaks' uri = namespace-main ). + CHECK lo_node IS BOUND. + lo_ixml_colbreaks = lo_node->get_elements_by_tag_name_ns( name = 'brk' uri = namespace-main ). + lo_ixml_iterator = lo_ixml_colbreaks->create_iterator( ). + lo_ixml_colbreak ?= lo_ixml_iterator->get_next( ). + CLEAR lv_count. + WHILE lo_ixml_colbreak IS BOUND. + ADD 1 TO lv_count. + READ TABLE lt_pagebreaks INDEX lv_count ASSIGNING . + IF sy-subrc <> 0. + APPEND INITIAL LINE TO lt_pagebreaks ASSIGNING . + -cell_row = -cell_row. + ENDIF. + -cell_column = lo_ixml_colbreak->get_attribute_ns( 'id' ). + + lo_ixml_colbreak ?= lo_ixml_iterator->get_next( ). + ENDWHILE. +*--------------------------------------------------------------------* +* Finally add each pagebreak +*--------------------------------------------------------------------* + lo_pagebreaks = io_worksheet->get_pagebreaks( ). + LOOP AT lt_pagebreaks ASSIGNING . + lo_pagebreaks->add_pagebreak( ip_column = -cell_column + ip_row = -cell_row ). + ENDLOOP. + + + ENDMETHOD. + + + METHOD load_worksheet_pagemargins. + + TYPES: BEGIN OF lty_page_margins, + footer TYPE string, + header TYPE string, + bottom TYPE string, + top TYPE string, + right TYPE string, + left TYPE string, + END OF lty_page_margins. + + DATA:lo_ixml_pagemargins_elem TYPE REF TO if_ixml_element, + ls_pagemargins TYPE lty_page_margins. + + + lo_ixml_pagemargins_elem = io_ixml_worksheet->find_from_name_ns( name = 'pageMargins' uri = namespace-main ). + IF lo_ixml_pagemargins_elem IS NOT INITIAL. + fill_struct_from_attributes( EXPORTING + ip_element = lo_ixml_pagemargins_elem + CHANGING + cp_structure = ls_pagemargins ). + io_worksheet->sheet_setup->margin_bottom = ycl_ecb_common=>excel_string_to_number( ls_pagemargins-bottom ). + io_worksheet->sheet_setup->margin_footer = ycl_ecb_common=>excel_string_to_number( ls_pagemargins-footer ). + io_worksheet->sheet_setup->margin_header = ycl_ecb_common=>excel_string_to_number( ls_pagemargins-header ). + io_worksheet->sheet_setup->margin_left = ycl_ecb_common=>excel_string_to_number( ls_pagemargins-left ). + io_worksheet->sheet_setup->margin_right = ycl_ecb_common=>excel_string_to_number( ls_pagemargins-right ). + io_worksheet->sheet_setup->margin_top = ycl_ecb_common=>excel_string_to_number( ls_pagemargins-top ). + ENDIF. + + ENDMETHOD. + + + METHOD read_from_applserver. + + DATA: lv_filelength TYPE i, + lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY, + ls_binary_data LIKE LINE OF lt_binary_data, + lv_filename TYPE string, + lv_max_length_line TYPE i, + lv_actual_length_line TYPE i, + lv_errormessage TYPE string. + + lv_filename = i_filename. + + DESCRIBE FIELD ls_binary_data LENGTH lv_max_length_line IN BYTE MODE. + OPEN DATASET lv_filename FOR INPUT IN BINARY MODE. + IF sy-subrc <> 0. + lv_errormessage = 'A problem occured when reading the file'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + WHILE sy-subrc = 0. + + READ DATASET lv_filename INTO ls_binary_data MAXIMUM LENGTH lv_max_length_line ACTUAL LENGTH lv_actual_length_line. + APPEND ls_binary_data TO lt_binary_data. + lv_filelength = lv_filelength + lv_actual_length_line. + + ENDWHILE. + CLOSE DATASET lv_filename. + +*--------------------------------------------------------------------* +* Binary data needs to be provided as XSTRING for further processing +*--------------------------------------------------------------------* + CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' + EXPORTING + input_length = lv_filelength + IMPORTING + buffer = r_excel_data + TABLES + binary_tab = lt_binary_data. + ENDMETHOD. + + + METHOD read_from_local_file. + DATA: lv_filelength TYPE i, + lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY, + ls_binary_data LIKE LINE OF lt_binary_data, + lv_filename TYPE string, + lv_errormessage TYPE string. + + lv_filename = i_filename. + + cl_gui_frontend_services=>gui_upload( EXPORTING + filename = lv_filename + filetype = 'BIN' " We are basically working with zipped directories --> force binary read + IMPORTING + filelength = lv_filelength + CHANGING + data_tab = lt_binary_data + EXCEPTIONS + file_open_error = 1 + file_read_error = 2 + no_batch = 3 + gui_refuse_filetransfer = 4 + invalid_type = 5 + no_authority = 6 + unknown_error = 7 + bad_data_format = 8 + header_not_allowed = 9 + separator_not_allowed = 10 + header_too_long = 11 + unknown_dp_error = 12 + access_denied = 13 + dp_out_of_memory = 14 + disk_full = 15 + dp_timeout = 16 + not_supported_by_gui = 17 + error_no_gui = 18 + OTHERS = 19 ). + IF sy-subrc <> 0. + lv_errormessage = 'A problem occured when reading the file'(001). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + +*--------------------------------------------------------------------* +* Binary data needs to be provided as XSTRING for further processing +*--------------------------------------------------------------------* + CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' + EXPORTING + input_length = lv_filelength + IMPORTING + buffer = r_excel_data + TABLES + binary_tab = lt_binary_data. + + ENDMETHOD. + + + METHOD resolve_path. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Determine whether the replacement should be done +* iterative to allow /../../.. or something alike +* 2do§2 Determine whether /./ has to be supported as well +* 2do§3 Create unit-test for this method +* +* Please don't just delete these ToDos if they are not +* needed but leave a comment that states this +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmoecker, (done) 2012-11-11 +* - ... +* changes: replaced previous coding by regular expression +* adding comments to explain what we are trying to achieve +*--------------------------------------------------------------------* + +*--------------------------------------------------------------------* +* §1 This routine will receive a path, that may have a relative pathname (/../) included somewhere +* The output should be a resolved path without relative references +* Example: Input xl/worksheets/../drawings/drawing1.xml +* Output xl/drawings/drawing1.xml +*--------------------------------------------------------------------* + + rp_result = ip_path. +*--------------------------------------------------------------------* +* §1 Remove relative pathnames +*--------------------------------------------------------------------* +* Regular expression [^/]*/\.\./ +* [^/]* --> any number of characters other than / +* followed by /\.\./ --> the sequence /../ +* ==> worksheets/../ will be found in the example +*--------------------------------------------------------------------* + REPLACE REGEX '[^/]*/\.\./' IN rp_result WITH ``. + + + ENDMETHOD. + + + METHOD resolve_referenced_formulae. + TYPES: BEGIN OF ty_referenced_cells, + sheet TYPE REF TO ycl_ecb_worksheet, + si TYPE i, + row_from TYPE i, + row_to TYPE i, + col_from TYPE i, + col_to TYPE i, + formula TYPE string, + ref_cell TYPE char10, + END OF ty_referenced_cells. + + DATA: ls_ref_formula LIKE LINE OF me->mt_ref_formulae, + lts_referenced_cells TYPE SORTED TABLE OF ty_referenced_cells WITH NON-UNIQUE KEY sheet si row_from row_to col_from col_to, + ls_referenced_cell LIKE LINE OF lts_referenced_cells, + lv_col_from TYPE yecb_cell_column_alpha, + lv_col_to TYPE yecb_cell_column_alpha, + lv_resulting_formula TYPE string, + lv_current_cell TYPE char10. + + + me->mt_ref_formulae = me->mt_ref_formulae. + +*--------------------------------------------------------------------* +* Get referenced Cells, Build ranges for easy lookup +*--------------------------------------------------------------------* + LOOP AT me->mt_ref_formulae INTO ls_ref_formula WHERE ref <> space. + + CLEAR ls_referenced_cell. + ls_referenced_cell-sheet = ls_ref_formula-sheet. + ls_referenced_cell-si = ls_ref_formula-si. + ls_referenced_cell-formula = ls_ref_formula-formula. + + TRY. + ycl_ecb_common=>convert_range2column_a_row( EXPORTING i_range = ls_ref_formula-ref + IMPORTING e_column_start = lv_col_from + e_column_end = lv_col_to + e_row_start = ls_referenced_cell-row_from + e_row_end = ls_referenced_cell-row_to ). + ls_referenced_cell-col_from = ycl_ecb_common=>convert_column2int( lv_col_from ). + ls_referenced_cell-col_to = ycl_ecb_common=>convert_column2int( lv_col_to ). + + + CLEAR ls_referenced_cell-ref_cell. + TRY. + ls_referenced_cell-ref_cell(3) = ycl_ecb_common=>convert_column2alpha( ls_ref_formula-column ). + ls_referenced_cell-ref_cell+3 = ls_ref_formula-row. + CONDENSE ls_referenced_cell-ref_cell NO-GAPS. + CATCH ycx_ecb. + ENDTRY. + + INSERT ls_referenced_cell INTO TABLE lts_referenced_cells. + CATCH ycx_ecb. + ENDTRY. + + ENDLOOP. + +* break x0009004. +*--------------------------------------------------------------------* +* For each referencing cell determine the referenced cell +* and resolve the formula +*--------------------------------------------------------------------* + LOOP AT me->mt_ref_formulae INTO ls_ref_formula WHERE ref = space. + + + CLEAR lv_current_cell. + TRY. + lv_current_cell(3) = ycl_ecb_common=>convert_column2alpha( ls_ref_formula-column ). + lv_current_cell+3 = ls_ref_formula-row. + CONDENSE lv_current_cell NO-GAPS. + CATCH ycx_ecb. + ENDTRY. + + LOOP AT lts_referenced_cells INTO ls_referenced_cell WHERE sheet = ls_ref_formula-sheet + AND si = ls_ref_formula-si + AND row_from <= ls_ref_formula-row + AND row_to >= ls_ref_formula-row + AND col_from <= ls_ref_formula-column + AND col_to >= ls_ref_formula-column. + + TRY. + + lv_resulting_formula = ycl_ecb_common=>determine_resulting_formula( iv_reference_cell = ls_referenced_cell-ref_cell + iv_reference_formula = ls_referenced_cell-formula + iv_current_cell = lv_current_cell ). + + ls_referenced_cell-sheet->set_cell_formula( ip_column = ls_ref_formula-column + ip_row = ls_ref_formula-row + ip_formula = lv_resulting_formula ). + CATCH ycx_ecb. + ENDTRY. + EXIT. + + ENDLOOP. + + ENDLOOP. + ENDMETHOD. + + + METHOD unescape_string_value. + + DATA: lt_character_positions TYPE TABLE OF i, + lv_character_position TYPE i, + lv_character_position_plus_2 TYPE i, + lv_character_position_plus_6 TYPE i, + lv_unescaped_value TYPE string. + + " The text "_x...._", with "_x" not "_X", with exactly 4 ".", each being 0-9 a-f or A-F (case insensitive), is interpreted + " like Unicode character U+.... (e.g. "_x0041_" is rendered like "A") is for characters. + " To not interpret it, Excel replaces the first "_" with "_x005f_". + result = i_value. + IF result CS '_x'. + CLEAR lt_character_positions. + APPEND sy-fdpos TO lt_character_positions. + lv_character_position = sy-fdpos + 1. + WHILE result+lv_character_position CS '_x'. + ADD sy-fdpos TO lv_character_position. + APPEND lv_character_position TO lt_character_positions. + ADD 1 TO lv_character_position. + ENDWHILE. + SORT lt_character_positions BY table_line DESCENDING. + LOOP AT lt_character_positions INTO lv_character_position. + lv_character_position_plus_2 = lv_character_position + 2. + lv_character_position_plus_6 = lv_character_position + 6. + IF substring( val = result off = lv_character_position_plus_2 len = 4 ) CO '0123456789ABCDEFGHIJKLMNOPQRSTUVWabcdefghijklmnopqrstuvw' + AND substring( val = result off = lv_character_position_plus_6 len = 1 ) = '_'. + lv_unescaped_value = cl_abap_conv_in_ce=>uccp( to_upper( substring( val = result off = lv_character_position_plus_2 len = 4 ) ) ). + REPLACE SECTION OFFSET lv_character_position LENGTH 7 OF result WITH lv_unescaped_value. + ENDIF. + ENDLOOP. + ENDIF. + + ENDMETHOD. + + + METHOD yif_ecb_reader~load. +*--------------------------------------------------------------------* +* ToDos: +* 2do§1 Map Document Properties to ZCL_EXCEL +*--------------------------------------------------------------------* + + CONSTANTS: lcv_core_properties TYPE string VALUE 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + lcv_office_document TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'. + + DATA: lo_rels TYPE REF TO if_ixml_document, + lo_node TYPE REF TO if_ixml_element, + ls_relationship TYPE t_relationship. + +*--------------------------------------------------------------------* +* §1 Create EXCEL-Object we want to return to caller + +* §2 We need to read the the file "\\_rels\.rels" because it tells +* us where in this folder structure the data for the workbook +* is located in the xlsx zip-archive +* +* The xlsx Zip-archive has generally the following folder structure: +* | +* |--> _rels +* |--> doc_Props +* |--> xl | +* |--> _rels +* |--> theme +* |--> worksheets + +* §3 Extracting from this the path&file where the workbook is located +* Following is an example how this file could be set up +* +* +* +* +* +* +*--------------------------------------------------------------------* + + CLEAR mt_dxf_styles. + CLEAR mt_ref_formulae. + CLEAR shared_strings. + CLEAR styles. + +*--------------------------------------------------------------------* +* §1 Create EXCEL-Object we want to return to caller +*--------------------------------------------------------------------* + IF iv_zcl_excel_classname IS INITIAL. + CREATE OBJECT r_excel. + ELSE. + CREATE OBJECT r_excel TYPE (iv_zcl_excel_classname). + ENDIF. + + zip = create_zip_archive( i_xlsx_binary = i_excel2007 + i_use_alternate_zip = i_use_alternate_zip ). + +*--------------------------------------------------------------------* +* §2 Get file in folderstructure +*--------------------------------------------------------------------* + lo_rels = get_ixml_from_zip_archive( '_rels/.rels' ). + +*--------------------------------------------------------------------* +* §3 Cycle through the Relationship Tags and use the ones we need +*--------------------------------------------------------------------* + lo_node ?= lo_rels->find_from_name_ns( name = 'Relationship' uri = namespace-relationships ). "#EC NOTEXT + WHILE lo_node IS BOUND. + + fill_struct_from_attributes( EXPORTING + ip_element = lo_node + CHANGING + cp_structure = ls_relationship ). + CASE ls_relationship-type. + + WHEN lcv_office_document. +*--------------------------------------------------------------------* +* Parse workbook - main part here +*--------------------------------------------------------------------* + load_workbook( iv_workbook_full_filename = ls_relationship-target + io_excel = r_excel ). + + WHEN lcv_core_properties. + " 2do§1 Map Document Properties to ZCL_EXCEL + + WHEN OTHERS. + + ENDCASE. + lo_node ?= lo_node->get_next( ). + + ENDWHILE. + + + ENDMETHOD. + + + METHOD yif_ecb_reader~load_file. + + DATA: lv_excel_data TYPE xstring. + +*--------------------------------------------------------------------* +* Read file into binary string +*--------------------------------------------------------------------* + IF i_from_applserver = abap_true. + lv_excel_data = read_from_applserver( i_filename ). + ELSE. + lv_excel_data = read_from_local_file( i_filename ). + ENDIF. + +*--------------------------------------------------------------------* +* Parse Excel data into ZCL_EXCEL object from binary string +*--------------------------------------------------------------------* + r_excel = yif_ecb_reader~load( i_excel2007 = lv_excel_data + i_use_alternate_zip = i_use_alternate_zip + iv_zcl_excel_classname = iv_zcl_excel_classname ). + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_reader_2007.clas.locals_def.abap b/src/abap2xlsx/ycl_ecb_reader_2007.clas.locals_def.abap new file mode 100644 index 0000000..8d41e7e --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_2007.clas.locals_def.abap @@ -0,0 +1,12 @@ +*"* use this source file for any type declarations (class +*"* definitions, interfaces or data types) you need for method +*"* implementation or private method's signature + +* +CLASS lcl_zip_archive DEFINITION ABSTRACT. + PUBLIC SECTION. + METHODS read ABSTRACT + IMPORTING i_filename TYPE csequence + RETURNING VALUE(r_content) TYPE xstring " Remember copy-on-write! + RAISING ycx_ecb. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_reader_2007.clas.locals_imp.abap b/src/abap2xlsx/ycl_ecb_reader_2007.clas.locals_imp.abap new file mode 100644 index 0000000..d3c6379 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_2007.clas.locals_imp.abap @@ -0,0 +1,151 @@ +*"* local class implementation for public class +*"* use this source file for the implementation part of +*"* local helper classes + TYPES: BEGIN OF t_relationship, + id TYPE string, + type TYPE string, + target TYPE string, + END OF t_relationship. + +* + CLASS lcl_abap_zip_archive DEFINITION + INHERITING FROM lcl_zip_archive + CREATE PRIVATE. + PUBLIC SECTION. + CLASS-METHODS create + IMPORTING i_data TYPE xstring + RETURNING VALUE(r_zip) TYPE REF TO lcl_zip_archive + RAISING ycx_ecb. + METHODS read REDEFINITION. + PRIVATE SECTION. + DATA: abap_zip TYPE REF TO cl_abap_zip. + METHODS constructor IMPORTING i_data TYPE xstring + RAISING ycx_ecb. + ENDCLASS. "lcl_abap_zip_archive DEFINITION + +* + CLASS lcl_alternate_zip_archive DEFINITION + INHERITING FROM lcl_zip_archive + CREATE PRIVATE. + PUBLIC SECTION. + CLASS-METHODS create + IMPORTING i_data TYPE xstring + i_alternate_zip_class TYPE seoclsname + RETURNING VALUE(r_zip) TYPE REF TO lcl_zip_archive + RAISING ycx_ecb. + METHODS read REDEFINITION. + PRIVATE SECTION. + DATA: alternate_zip TYPE REF TO object. + METHODS constructor + IMPORTING i_data TYPE xstring + i_alternate_zip_class TYPE seoclsname + RAISING ycx_ecb. + ENDCLASS. "lcl_alternate_zip_archive DEFINITION + +* + CLASS lcl_abap_zip_archive IMPLEMENTATION. + METHOD create. + CREATE OBJECT r_zip TYPE lcl_abap_zip_archive + EXPORTING + i_data = i_data. + ENDMETHOD. "create + METHOD constructor. + DATA: lv_errormessage TYPE string. + super->constructor( ). + CREATE OBJECT abap_zip. + abap_zip->load( + EXPORTING + zip = i_data + EXCEPTIONS + zip_parse_error = 1 + OTHERS = 2 ). + IF sy-subrc <> 0. + lv_errormessage = 'ZIP parse error'(002). + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = lv_errormessage. + ENDIF. + + ENDMETHOD. "constructor + METHOD read. + DATA: lv_errormessage TYPE string. + CALL METHOD abap_zip->get + EXPORTING + name = i_filename + IMPORTING + content = r_content + EXCEPTIONS + zip_index_error = 1 + zip_decompression_error = 2 + OTHERS = 3. + IF sy-subrc <> 0. + lv_errormessage = 'File not found in zip-archive'(003). + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = lv_errormessage. + ENDIF. + + ENDMETHOD. "read + ENDCLASS. "lcl_abap_zip_archive IMPLEMENTATION + +* + CLASS lcl_alternate_zip_archive IMPLEMENTATION. + METHOD create. + CREATE OBJECT r_zip TYPE lcl_alternate_zip_archive + EXPORTING + i_alternate_zip_class = i_alternate_zip_class + i_data = i_data. + ENDMETHOD. "create + METHOD constructor. + DATA: lv_errormessage TYPE string. + super->constructor( ). + CREATE OBJECT alternate_zip TYPE (i_alternate_zip_class). + TRY. + CALL METHOD alternate_zip->('LOAD') + EXPORTING + zip = i_data + EXCEPTIONS + zip_parse_error = 1 + OTHERS = 2. + CATCH cx_sy_dyn_call_illegal_method. + lv_errormessage = 'Method LOAD missing in alternative zipclass'. "#EC NOTEXT This is a workaround until class CL_ABAP_ZIP is fixed + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = lv_errormessage. + ENDTRY. + + IF sy-subrc <> 0. + lv_errormessage = 'ZIP parse error'(002). + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = lv_errormessage. + ENDIF. + + ENDMETHOD. "constructor + METHOD read. + DATA: lv_errormessage TYPE string. + TRY. + CALL METHOD alternate_zip->('GET') + EXPORTING + name = i_filename + IMPORTING + content = r_content " Contents + EXCEPTIONS + zip_index_error = 1 + zip_decompression_error = 2 + OTHERS = 3. + CATCH cx_sy_dyn_call_illegal_method. + lv_errormessage = 'Method GET missing in alternative zipclass'. "#EC NOTEXT This is a workaround until class CL_ABAP_ZIP is fixed + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = lv_errormessage. + ENDTRY. + IF sy-subrc <> 0. + lv_errormessage = 'File not found in zip-archive'(003). + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = lv_errormessage. + ENDIF. + + ENDMETHOD. "read + ENDCLASS. "lcl_alternate_zip_archive IMPLEMENTATION diff --git a/src/abap2xlsx/ycl_ecb_reader_2007.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_reader_2007.clas.testclasses.abap new file mode 100644 index 0000000..8855cf7 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_2007.clas.testclasses.abap @@ -0,0 +1,55 @@ +*"* use this source file for your ABAP unit test classes + +CLASS ltc_unescape_string_value DEFINITION DEFERRED. +CLASS ycl_ecb_reader_2007 DEFINITION LOCAL FRIENDS + ltc_unescape_string_value. + + +CLASS ltc_unescape_string_value DEFINITION + FOR TESTING + DURATION SHORT + RISK LEVEL HARMLESS. + PRIVATE SECTION. + + METHODS escaped_character_inside_text FOR TESTING. + METHODS no_escaping FOR TESTING. + METHODS one_escaped_character FOR TESTING. + METHODS two_escaped_characters FOR TESTING. + + METHODS run_cut + IMPORTING + input TYPE string + exp TYPE string. + +ENDCLASS. + + +CLASS ltc_unescape_string_value IMPLEMENTATION. + + METHOD escaped_character_inside_text. + run_cut( input = 'start _x0000_ end' exp = |start { cl_abap_conv_in_ce=>uccp( '0000' ) } end| ). + ENDMETHOD. + + METHOD no_escaping. + run_cut( input = 'no escaping' exp = 'no escaping' ). + ENDMETHOD. + + METHOD one_escaped_character. + run_cut( input = '_x0000_' exp = cl_abap_conv_in_ce=>uccp( '0000' ) ). + ENDMETHOD. + + METHOD run_cut. + + DATA: lo_excel TYPE REF TO ycl_ecb_reader_2007. + + CREATE OBJECT lo_excel. + + cl_abap_unit_assert=>assert_equals( act = lo_excel->unescape_string_value( input ) exp = exp msg = |input: { input }| ). + + ENDMETHOD. + + METHOD two_escaped_characters. + run_cut( input = '_x0000_ and _xFFFF_' exp = |{ cl_abap_conv_in_ce=>uccp( '0000' ) } and { cl_abap_conv_in_ce=>uccp( 'FFFF' ) }| ). + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_reader_2007.clas.xml b/src/abap2xlsx/ycl_ecb_reader_2007.clas.xml new file mode 100644 index 0000000..1e321b2 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_2007.clas.xml @@ -0,0 +1,324 @@ + + + + + + YCL_ECB_READER_2007 + E + Read Excel 2007 into ZCL_EXCEL + 1 + X + X + X + X + + + + I + 001 + A problem occured when reading the file + 60 + + + I + 002 + ZIP parse error + 60 + + + I + 003 + File not found in zip-archive + 60 + + + + + CREATE_ZIP_ARCHIVE + E + Create the zip reference object + + + FILL_ROW_OUTLINES + E + Fill row outlines from collapsed and hierarchy information + + + FILL_STRUCT_FROM_ATTRIBUTES + E + Fills structure fields based on XML node attributes + + + FILL_STRUCT_FROM_ATTRIBUTES + I + Fills structure fields based on XML node attributes + + + GET_DXF_STYLE_GUID + E + Get guid of dxf style + + + GET_FROM_ZIP_ARCHIVE + E + Read file from ZIP Archive + + + GET_FROM_ZIP_ARCHIVE + I + Read file from ZIP Archive + + + GET_IXML_FROM_ZIP_ARCHIVE + E + Read file from ZIP Archive and convert to ixml document + + + GET_IXML_FROM_ZIP_ARCHIVE + I + Read file from ZIP Archive + + + GTS_EXTERNAL_HYPERLINK + E + External hyperlink + + + GTT_EXTERNAL_HYPERLINKS + E + Table with external hyperlinks + + + LOAD_DRAWING_ANCHOR + E + Loads drawing anchor + + + LOAD_DRAWING_ANCHOR + I + Loads worksheet + + + LOAD_DXF_STYLES + E + Loads dxf styles + + + LOAD_SHARED_STRINGS + E + Loads shared strings table + + + LOAD_SHARED_STRINGS + I + Loads shared strings table + + + LOAD_STYLES + E + Loads styles + + + LOAD_STYLES + I + Loads styles + + + LOAD_STYLE_BORDERS + E + Loads 'borders' part of styles + + + LOAD_STYLE_BORDERS + I + Loads 'borders' part of styles + + + LOAD_STYLE_FILLS + E + Loads 'fills' part of styles + + + LOAD_STYLE_FILLS + I + Loads 'fills' part of styles + + + LOAD_STYLE_FONTS + E + Loads 'fonts' part of styles + + + LOAD_STYLE_FONTS + I + Loads 'fonts' part of styles + + + LOAD_STYLE_NUM_FORMATS + E + Loads 'number format' part of styles + + + LOAD_STYLE_NUM_FORMATS + I + Loads 'number format' part of styles + + + LOAD_THEME + E + Loads theme + + + LOAD_WORKBOOK + E + Loads workbook + + + LOAD_WORKBOOK + I + Loads workbook + + + LOAD_WORKSHEET + E + Loads worksheet + + + LOAD_WORKSHEET + I + Loads worksheet + + + LOAD_WORKSHEET_COND_FORMAT + E + Load worksheet's conditional formattings + + + LOAD_WORKSHEET_COND_FORMAT_AA + E + Load worksheet's conditional formatting - type above average + + + LOAD_WORKSHEET_COND_FORMAT_CI + E + Load worksheet's conditional formatting - type cellIs + + + LOAD_WORKSHEET_COND_FORMAT_CS + E + Load worksheet's conditional formatting - type colorscale + + + LOAD_WORKSHEET_COND_FORMAT_DB + E + Load worksheet's conditional formatting - type databar + + + LOAD_WORKSHEET_COND_FORMAT_EX + E + Load worksheet's conditional formatting - type expression + + + LOAD_WORKSHEET_COND_FORMAT_IS + E + Load worksheet's conditional formatting - type iconset + + + LOAD_WORKSHEET_COND_FORMAT_T10 + E + Load worksheet's conditional formatting - type top10 + + + LOAD_WORKSHEET_DRAWING + E + Loads worksheet drawings + + + LOAD_WORKSHEET_DRAWING + I + Loads worksheet drawings + + + LOAD_WORKSHEET_HYPERLINKS + E + Loads hyperlinks of worksheet + + + LOAD_WORKSHEET_PAGEBREAKS + E + Load pagebreaks of worksheet + + + LOAD_WORKSHEET_PAGEMARGINS + E + Loads pagemargings of worksheet + + + MT_DXF_STYLES + E + Styles mapping + + + MT_REF_FORMULAE + E + Referenced formulae before resolving + + + MT_REF_FORMULAE + I + Referenced formulae before resolving + + + READ_FROM_APPLSERVER + E + Load excel data from appserver + + + READ_FROM_LOCAL_FILE + E + Load excel data from local file + + + RESOLVE_PATH + E + Return path after ../ values are removed + + + RESOLVE_PATH + I + Return path after ../ values are removed + + + RESOLVE_REFERENCED_FORMULAE + E + Resolve referenced formulae + + + RESOLVE_REFERENCED_FORMULAE + I + Resolve referenced formulae + + + SHARED_STRINGS + E + Table with Strings + + + SHARED_STRINGS + I + Table with Strings + + + ZIP + E + Zip Utility + + + ZIP + I + Zip Utility + + + + + diff --git a/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.abap b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.abap new file mode 100644 index 0000000..96b733e --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.abap @@ -0,0 +1,333 @@ +CLASS ycl_ecb_reader_huge_file DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_reader_2007 + CREATE PUBLIC . + + PUBLIC SECTION. + PROTECTED SECTION. + + METHODS load_shared_strings + REDEFINITION . + METHODS load_worksheet + REDEFINITION . + PRIVATE SECTION. + + TYPES: + BEGIN OF t_cell_content, + datatype TYPE yecb_cell_data_type, + value TYPE yecb_cell_value, + formula TYPE yecb_cell_formula, + style TYPE yecb_cell_style, + END OF t_cell_content . + TYPES: + BEGIN OF t_cell_coord, + row TYPE yecb_cell_row, + column TYPE yecb_cell_column_alpha, + END OF t_cell_coord . + TYPES: + BEGIN OF t_cell. + INCLUDE TYPE t_cell_coord AS coord. + INCLUDE TYPE t_cell_content AS content. + TYPES: END OF t_cell . + + INTERFACE if_sxml_node LOAD . + CONSTANTS c_end_of_stream TYPE if_sxml_node=>node_type VALUE if_sxml_node=>co_nt_final. "#EC NOTEXT + CONSTANTS c_element_open TYPE if_sxml_node=>node_type VALUE if_sxml_node=>co_nt_element_open. "#EC NOTEXT + CONSTANTS c_element_close TYPE if_sxml_node=>node_type VALUE if_sxml_node=>co_nt_element_close. "#EC NOTEXT + DATA: + BEGIN OF gs_buffer_style, + index TYPE i VALUE -1, + guid TYPE yecb_cell_style, + END OF gs_buffer_style . + CONSTANTS c_attribute TYPE if_sxml_node=>node_type VALUE if_sxml_node=>co_nt_attribute. "#EC NOTEXT + CONSTANTS c_node_value TYPE if_sxml_node=>node_type VALUE if_sxml_node=>co_nt_value. "#EC NOTEXT + + METHODS skip_to + IMPORTING + !iv_element_name TYPE string + !io_reader TYPE REF TO if_sxml_reader + RAISING + lcx_not_found . + METHODS fill_cell_from_attributes + IMPORTING + !io_reader TYPE REF TO if_sxml_reader + RETURNING + VALUE(es_cell) TYPE t_cell + RAISING + lcx_not_found + ycx_ecb. + METHODS read_shared_strings + IMPORTING + !io_reader TYPE REF TO if_sxml_reader + RETURNING + VALUE(et_shared_strings) TYPE stringtab . + METHODS get_cell_coord + IMPORTING + !iv_coord TYPE string + RETURNING + VALUE(es_coord) TYPE t_cell_coord + RAISING + ycx_ecb. + METHODS put_cell_to_worksheet + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet + !is_cell TYPE t_cell + RAISING + ycx_ecb. + METHODS get_shared_string + IMPORTING + !iv_index TYPE any + RETURNING + VALUE(ev_value) TYPE string + RAISING + lcx_not_found . + METHODS get_style + IMPORTING + !iv_index TYPE any + RETURNING + VALUE(ev_style_guid) TYPE yecb_cell_style + RAISING + lcx_not_found . + METHODS read_worksheet_data + IMPORTING + !io_reader TYPE REF TO if_sxml_reader + !io_worksheet TYPE REF TO ycl_ecb_worksheet + RAISING + lcx_not_found + ycx_ecb . + METHODS get_sxml_reader + IMPORTING + !iv_path TYPE string + RETURNING + VALUE(eo_reader) TYPE REF TO if_sxml_reader + RAISING + ycx_ecb . +ENDCLASS. + + + +CLASS ycl_ecb_reader_huge_file IMPLEMENTATION. + + + METHOD fill_cell_from_attributes. + + WHILE io_reader->node_type NE c_end_of_stream. + io_reader->next_attribute( ). + IF io_reader->node_type NE c_attribute. + EXIT. + ENDIF. + CASE io_reader->name. + WHEN `t`. + es_cell-datatype = io_reader->value. + WHEN `s`. + IF io_reader->value IS NOT INITIAL. + es_cell-style = get_style( io_reader->value ). + ENDIF. + WHEN `r`. + es_cell-coord = get_cell_coord( io_reader->value ). + ENDCASE. + ENDWHILE. + + ENDMETHOD. + + + METHOD get_cell_coord. + + ycl_ecb_common=>convert_columnrow2column_a_row( + EXPORTING + i_columnrow = iv_coord + IMPORTING + e_column = es_coord-column + e_row = es_coord-row + ). + + ENDMETHOD. + + + METHOD get_shared_string. + DATA: lv_tabix TYPE i, + lv_error TYPE string. + FIELD-SYMBOLS: TYPE t_shared_string. + lv_tabix = iv_index + 1. + READ TABLE shared_strings ASSIGNING INDEX lv_tabix. + IF sy-subrc NE 0. + CONCATENATE 'Entry ' iv_index ' not found in Shared String Table' INTO lv_error. + RAISE EXCEPTION TYPE lcx_not_found + EXPORTING + error = lv_error. + ENDIF. + ev_value = -value. + ENDMETHOD. + + + METHOD get_style. + + DATA: lv_tabix TYPE i, + lo_style TYPE REF TO ycl_ecb_style, + lv_error TYPE string. + + IF gs_buffer_style-index NE iv_index. + lv_tabix = iv_index + 1. + READ TABLE styles INTO lo_style INDEX lv_tabix. + IF sy-subrc NE 0. + CONCATENATE 'Entry ' iv_index ' not found in Style Table' INTO lv_error. + RAISE EXCEPTION TYPE lcx_not_found + EXPORTING + error = lv_error. + ELSE. + gs_buffer_style-index = iv_index. + gs_buffer_style-guid = lo_style->get_guid( ). + ENDIF. + ENDIF. + + ev_style_guid = gs_buffer_style-guid. + + ENDMETHOD. + + + METHOD get_sxml_reader. + + DATA: lv_xml TYPE xstring. + + lv_xml = get_from_zip_archive( iv_path ). + eo_reader = cl_sxml_string_reader=>create( lv_xml ). + + ENDMETHOD. + + + METHOD load_shared_strings. + + DATA: lo_reader TYPE REF TO if_sxml_reader. + DATA: lt_shared_strings TYPE TABLE OF string, + ls_shared_string TYPE t_shared_string. + FIELD-SYMBOLS: TYPE string. + + lo_reader = get_sxml_reader( ip_path ). + + lt_shared_strings = read_shared_strings( lo_reader ). + LOOP AT lt_shared_strings ASSIGNING . + ls_shared_string-value = unescape_string_value( ). + APPEND ls_shared_string TO shared_strings. + ENDLOOP. + + ENDMETHOD. + + + METHOD load_worksheet. + + DATA: lo_reader TYPE REF TO if_sxml_reader. + DATA: lx_not_found TYPE REF TO lcx_not_found. + + lo_reader = get_sxml_reader( ip_path ). + + TRY. + + read_worksheet_data( io_reader = lo_reader + io_worksheet = io_worksheet ). + + CATCH lcx_not_found INTO lx_not_found. + ycx_ecb=>raise_text( lx_not_found->error ). + ENDTRY. + ENDMETHOD. + + + METHOD put_cell_to_worksheet. + CHECK is_cell-value IS NOT INITIAL + OR is_cell-formula IS NOT INITIAL + OR is_cell-style IS NOT INITIAL. + CALL METHOD io_worksheet->set_cell + EXPORTING + ip_column = is_cell-column + ip_row = is_cell-row + ip_value = is_cell-value + ip_formula = is_cell-formula + ip_data_type = is_cell-datatype + ip_style = is_cell-style. + ENDMETHOD. + + + METHOD read_shared_strings. + + DATA lv_value TYPE string. + + WHILE io_reader->node_type NE c_end_of_stream. + io_reader->next_node( ). + CASE io_reader->name. + WHEN 'si'. + CASE io_reader->node_type . + WHEN c_element_open . + CLEAR lv_value . + WHEN c_element_close . + APPEND lv_value TO et_shared_strings. + ENDCASE . + WHEN 't'. + CASE io_reader->node_type . + WHEN c_node_value . + lv_value = lv_value && io_reader->value . + ENDCASE . + ENDCASE . + ENDWHILE. + + ENDMETHOD. + + + METHOD read_worksheet_data. + + DATA: ls_cell TYPE t_cell. + +* Skip to element + skip_to( iv_element_name = `sheetData` io_reader = io_reader ). + +* Main loop: Evaluate the elements and its children + WHILE io_reader->node_type NE c_end_of_stream. + io_reader->next_node( ). + CASE io_reader->node_type. + WHEN c_element_open. + IF io_reader->name EQ `c`. + ls_cell = fill_cell_from_attributes( io_reader ). + ENDIF. + WHEN c_node_value. + CASE io_reader->name. + WHEN `f`. + ls_cell-formula = io_reader->value. + WHEN `v`. + IF ls_cell-datatype EQ `s`. + ls_cell-value = get_shared_string( io_reader->value ). + ELSE. + ls_cell-value = io_reader->value. + ENDIF. + WHEN `t` OR `is`. + ls_cell-value = io_reader->value. + ENDCASE. + WHEN c_element_close. + CASE io_reader->name. + WHEN `c`. + put_cell_to_worksheet( is_cell = ls_cell io_worksheet = io_worksheet ). + WHEN `sheetData`. + EXIT. + ENDCASE. + ENDCASE. + ENDWHILE. + + ENDMETHOD. + + + METHOD skip_to. + + DATA: lv_error TYPE string. + +* Skip forward to given element + WHILE io_reader->name NE iv_element_name OR + io_reader->node_type NE c_element_open. + io_reader->next_node( ). + IF io_reader->node_type = c_end_of_stream. + CONCATENATE 'XML error: Didn''t find element <' iv_element_name '>' INTO lv_error. + RAISE EXCEPTION TYPE lcx_not_found + EXPORTING + error = lv_error. + ENDIF. + ENDWHILE. + + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.locals_def.abap b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.locals_def.abap new file mode 100644 index 0000000..2c283c8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.locals_def.abap @@ -0,0 +1,14 @@ +*"* use this source file for any type of declarations (class +*"* definitions, interfaces or type declarations) you need for +*"* components in the private section + +* Signal for "Not found" +CLASS lcx_not_found DEFINITION INHERITING FROM cx_static_check. + PUBLIC SECTION. + DATA error TYPE string. + METHODS constructor + IMPORTING error TYPE string + textid TYPE sotr_conc OPTIONAL + previous TYPE REF TO cx_root OPTIONAL. + METHODS if_message~get_text REDEFINITION. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.locals_imp.abap b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.locals_imp.abap new file mode 100644 index 0000000..5798188 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.locals_imp.abap @@ -0,0 +1,14 @@ +*"* use this source file for the definition and implementation of +*"* local helper classes, interface definitions and type +*"* declarations + +* Signal "not found" +CLASS lcx_not_found IMPLEMENTATION. + METHOD constructor. + super->constructor( textid = textid previous = previous ). + me->error = error. + ENDMETHOD. "constructor + METHOD if_message~get_text. + result = error. + ENDMETHOD. "if_message~get_text +ENDCLASS. "lcx_not_found IMPLEMENTATION diff --git a/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.testclasses.abap new file mode 100644 index 0000000..0a93d6d --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.testclasses.abap @@ -0,0 +1,399 @@ +*"* use this source file for your ABAP unit test classes +CLASS lcl_test DEFINITION DEFERRED. +CLASS ycl_ecb_reader_huge_file DEFINITION LOCAL FRIENDS lcl_test. + +* +CLASS lcl_test DEFINITION FOR TESTING + RISK LEVEL HARMLESS + DURATION SHORT. + + PRIVATE SECTION. + DATA: + out TYPE REF TO ycl_ecb_reader_huge_file, " object under test + excel TYPE REF TO ycl_ecb, + worksheet TYPE REF TO ycl_ecb_worksheet. + METHODS: + setup RAISING cx_static_check, + test_number FOR TESTING RAISING cx_static_check, + test_shared_string FOR TESTING RAISING cx_static_check, + test_shared_string_missing FOR TESTING RAISING cx_static_check, + test_inline_string FOR TESTING RAISING cx_static_check, + test_empty_cells FOR TESTING RAISING cx_static_check, + test_boolean FOR TESTING RAISING cx_static_check, + test_style FOR TESTING RAISING cx_static_check, + test_style_missing FOR TESTING RAISING cx_static_check, + test_formula FOR TESTING RAISING cx_static_check, + test_read_shared_strings FOR TESTING RAISING cx_static_check, + test_shared_string_some_empty FOR TESTING RAISING cx_static_check, + test_shared_string_multi_style FOR TESTING RAISING cx_static_check, + test_skip_to_inexistent FOR TESTING RAISING cx_static_check, + get_reader IMPORTING iv_xml TYPE string RETURNING VALUE(eo_reader) TYPE REF TO if_sxml_reader, + assert_value_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_value TYPE string, + assert_formula_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_formula TYPE string, + assert_style_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_style TYPE yecb_cell_style, + assert_datatype_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_datatype TYPE string. + +ENDCLASS. "lcl_test DEFINITION + +* +CLASS lcl_test IMPLEMENTATION. + +* + METHOD test_number. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + lo_reader = get_reader( + `17` + ). + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + assert_value_equals( `17` ). + assert_datatype_equals( `n` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + ENDMETHOD. "test_shared_string + +* + METHOD test_shared_string. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + DATA: ls_shared_string TYPE ycl_ecb_reader_huge_file=>t_shared_string. + ls_shared_string-value = `Test1`. + APPEND ls_shared_string TO out->shared_strings. + ls_shared_string-value = `Test2`. + APPEND ls_shared_string TO out->shared_strings. + lo_reader = get_reader( + `1` + ). + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + assert_value_equals( `Test2` ). + assert_datatype_equals( `s` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + ENDMETHOD. "test_shared_string +* + METHOD test_shared_string_missing. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + DATA: ls_shared_string TYPE ycl_ecb_reader_huge_file=>t_shared_string. + ls_shared_string-value = `Test`. + APPEND ls_shared_string TO out->shared_strings. + lo_reader = get_reader( + `1` + ). + + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + cl_abap_unit_assert=>fail( `Index to non-existent shared string should give an error` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + ENDTRY. + + ENDMETHOD. +* + METHOD test_inline_string. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + lo_reader = get_reader( + `Alpha` + ). + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + assert_value_equals( `Alpha` ). + assert_datatype_equals( `inlineStr` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + ENDMETHOD. "test_inline_string + +* + METHOD test_boolean. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + lo_reader = get_reader( + `1` + ). + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + assert_value_equals( `1` ). + assert_datatype_equals( `b` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + ENDMETHOD. "test_boolean + +* + METHOD test_formula. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + lo_reader = get_reader( + `A2*A2` + ). + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + assert_formula_equals( `A2*A2` ). + assert_datatype_equals( `n` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + ENDMETHOD. "test_formula + +* + METHOD test_empty_cells. + +* There is no need to store an empty cell in the ABAP worksheet structure + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + DATA: ls_shared_string TYPE ycl_ecb_reader_huge_file=>t_shared_string. + ls_shared_string-value = ``. + APPEND ls_shared_string TO out->shared_strings. + ls_shared_string-value = `t`. + APPEND ls_shared_string TO out->shared_strings. + lo_reader = get_reader( + `0` & + `` & + `1` + ). + + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + + assert_value_equals( iv_row = 1 iv_col = 1 iv_value = `` ). + assert_value_equals( iv_row = 2 iv_col = 1 iv_value = `` ). + assert_value_equals( iv_row = 3 iv_col = 1 iv_value = `t` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + ENDMETHOD. + +* + METHOD test_style. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string, + lo_style TYPE REF TO ycl_ecb_style, + lv_guid TYPE yecb_cell_style. + CREATE OBJECT lo_style. + APPEND lo_style TO out->styles. + lv_guid = lo_style->get_guid( ). + + lo_reader = get_reader( + `18` + ). + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + assert_style_equals( lv_guid ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + cl_abap_unit_assert=>fail( lv_text ). + ENDTRY. + + ENDMETHOD. "test_style + +* + METHOD test_style_missing. + + DATA: + lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + + lo_reader = get_reader( + `18` + ). + + TRY. + out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ). + cl_abap_unit_assert=>fail( `Reference to non-existent style should throw an lcx_not_found exception` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger + ENDTRY. + + ENDMETHOD. "test_style + +* + METHOD test_read_shared_strings. + DATA: lo_c2x TYPE REF TO cl_abap_conv_out_ce, + lv_xstring TYPE xstring, + lo_reader TYPE REF TO if_sxml_reader, + lt_act TYPE stringtab, + lt_exp TYPE stringtab. + + lo_c2x = cl_abap_conv_out_ce=>create( ). + lo_c2x->convert( EXPORTING data = `AlphaBravo` + IMPORTING buffer = lv_xstring ). + lo_reader = cl_sxml_string_reader=>create( lv_xstring ). + APPEND : + `` TO lt_exp, + `Alpha` TO lt_exp, + `Bravo` TO lt_exp. + + lt_act = out->read_shared_strings( lo_reader ). + + cl_abap_unit_assert=>assert_equals( act = lt_act + exp = lt_exp ). + + ENDMETHOD. + +* + METHOD test_shared_string_some_empty. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lt_act TYPE stringtab, + lt_exp TYPE stringtab. + lo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( + `` & + `Alpha` & + `` & + `Bravo` + ) ). + APPEND : + `` TO lt_exp, + `Alpha` TO lt_exp, + `` TO lt_exp, + `Bravo` TO lt_exp. + + lt_act = out->read_shared_strings( lo_reader ). + + cl_abap_unit_assert=>assert_equals( act = lt_act + exp = lt_exp ). + + ENDMETHOD. + +* + METHOD test_shared_string_multi_style. + DATA: lo_reader TYPE REF TO if_sxml_reader, + lt_act TYPE stringtab, + lt_exp TYPE stringtab. + lo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to( + `` && + `Cell A2` && + `the following coloured part will be preserved` && + `Cell A3` && + `` ) ). + APPEND : + `Cell A2` TO lt_exp, + `the following coloured part will be preserved` TO lt_exp, + `Cell A3` TO lt_exp. + + lt_act = out->read_shared_strings( lo_reader ). + + cl_abap_unit_assert=>assert_equals( act = lt_act + exp = lt_exp ). + + ENDMETHOD. + + +* + METHOD test_skip_to_inexistent. + DATA: lo_c2x TYPE REF TO cl_abap_conv_out_ce, + lv_xstring TYPE xstring, + lo_reader TYPE REF TO if_sxml_reader, + lo_ex TYPE REF TO lcx_not_found, + lv_text TYPE string. + + lo_c2x = cl_abap_conv_out_ce=>create( ). + lo_c2x->convert( EXPORTING data = `AlphaBravo` + IMPORTING buffer = lv_xstring ). + lo_reader = cl_sxml_string_reader=>create( lv_xstring ). + TRY. + out->skip_to( iv_element_name = `nonExistingElement` io_reader = lo_reader ). + cl_abap_unit_assert=>fail( `Skipping to non-existing element must raise lcx_not_found exception` ). + CATCH lcx_not_found INTO lo_ex. + lv_text = lo_ex->get_text( ). " May inspect exception text in debugger + ENDTRY. + ENDMETHOD. + +* + METHOD get_reader. + DATA: lv_full TYPE string, + lo_c2x TYPE REF TO cl_abap_conv_out_ce, + lv_xstring TYPE xstring. + CONCATENATE `` iv_xml `` INTO lv_full. + lo_c2x = cl_abap_conv_out_ce=>create( ). + lo_c2x->convert( EXPORTING data = lv_full + IMPORTING buffer = lv_xstring ). + eo_reader = cl_sxml_string_reader=>create( lv_xstring ). + ENDMETHOD. "get_reader +* + METHOD assert_value_equals. + + CONSTANTS: lc_empty_string TYPE string VALUE IS INITIAL. + + FIELD-SYMBOLS: TYPE yecb_s_cell_data, + TYPE string. + + READ TABLE worksheet->sheet_content ASSIGNING + WITH TABLE KEY cell_row = iv_row cell_column = iv_col. + IF sy-subrc EQ 0. + ASSIGN -cell_value TO . + ELSE. + ASSIGN lc_empty_string TO . + ENDIF. + + cl_abap_unit_assert=>assert_equals( act = + exp = iv_value ). + + ENDMETHOD. "assert_value_equals +** + METHOD assert_formula_equals. + + FIELD-SYMBOLS: TYPE yecb_s_cell_data. + + READ TABLE worksheet->sheet_content ASSIGNING + WITH TABLE KEY cell_row = iv_row cell_column = iv_col. + cl_abap_unit_assert=>assert_subrc( sy-subrc ). + + cl_abap_unit_assert=>assert_equals( act = -cell_formula + exp = iv_formula ). + + ENDMETHOD. "assert_formula_equals +* + METHOD assert_style_equals. + + FIELD-SYMBOLS: TYPE yecb_s_cell_data. + + READ TABLE worksheet->sheet_content ASSIGNING + WITH TABLE KEY cell_row = iv_row cell_column = iv_col. + cl_abap_unit_assert=>assert_subrc( sy-subrc ). + + cl_abap_unit_assert=>assert_equals( act = -cell_style + exp = iv_style ). + + ENDMETHOD. +* + METHOD assert_datatype_equals. + + FIELD-SYMBOLS: TYPE yecb_s_cell_data. + + READ TABLE worksheet->sheet_content ASSIGNING + WITH TABLE KEY cell_row = iv_row cell_column = iv_col. + cl_abap_unit_assert=>assert_subrc( sy-subrc ). + + cl_abap_unit_assert=>assert_equals( act = -data_type + exp = iv_datatype ). + + ENDMETHOD. "assert_datatype_equals + METHOD setup. + CREATE OBJECT out. + CREATE OBJECT excel. + CREATE OBJECT worksheet + EXPORTING + ip_excel = excel. + ENDMETHOD. "setup +ENDCLASS. "lcl_test IMPLEMENTATION diff --git a/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.xml b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.xml new file mode 100644 index 0000000..3f10987 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_huge_file.clas.xml @@ -0,0 +1,64 @@ + + + + + + YCL_ECB_READER_HUGE_FILE + E + Can read large .xlsx files + 1 + X + X + X + X + + + + FILL_CELL_FROM_ATTRIBUTES + E + Fill some cell properties from <c> element attributes + + + GET_CELL_COORD + E + Cell coordinates from expression (like "B2") + + + GET_SHARED_STRING + E + Read from shared string table + + + GET_STYLE + E + Read from style table + + + GET_SXML_READER + E + Create an sXML reader for an XML file in the zip archive + + + PUT_CELL_TO_WORKSHEET + E + Put cell data to worksheet + + + READ_SHARED_STRINGS + E + Reads the XML file containing the shared strings + + + READ_WORKSHEET_DATA + E + Reads the data, formula and styles of the worksheet's cells + + + SKIP_TO + E + Go ahead till element with given name is found + + + + + diff --git a/src/abap2xlsx/ycl_ecb_reader_xlsm.clas.abap b/src/abap2xlsx/ycl_ecb_reader_xlsm.clas.abap new file mode 100644 index 0000000..28e788a --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_xlsm.clas.abap @@ -0,0 +1,138 @@ +CLASS ycl_ecb_reader_xlsm DEFINITION + PUBLIC + INHERITING FROM ycl_ecb_reader_2007 + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_READER_XLSM +*"* do not include other source files here!!! + PROTECTED SECTION. + +*"* protected components of class ZCL_EXCEL_READER_XLSM +*"* do not include other source files here!!! + METHODS load_workbook + REDEFINITION . + METHODS load_worksheet + REDEFINITION . + PRIVATE SECTION. + +*"* private components of class ZCL_EXCEL_READER_XLSM +*"* do not include other source files here!!! + METHODS load_vbaproject + IMPORTING + !ip_path TYPE string + !ip_excel TYPE REF TO ycl_ecb + RAISING + ycx_ecb . +ENDCLASS. + + + +CLASS ycl_ecb_reader_xlsm IMPLEMENTATION. + + + METHOD load_vbaproject. + + DATA lv_content TYPE xstring. + + lv_content = me->get_from_zip_archive( ip_path ). + + ip_excel->yif_ecb_book_vba_project~set_vbaproject( lv_content ). + + ENDMETHOD. + + + METHOD load_workbook. + super->load_workbook( EXPORTING iv_workbook_full_filename = iv_workbook_full_filename + io_excel = io_excel ). + + CONSTANTS: lc_vba_project TYPE string VALUE 'http://schemas.microsoft.com/office/2006/relationships/vbaProject'. + + DATA: rels_workbook_path TYPE string, + rels_workbook TYPE REF TO if_ixml_document, + path TYPE string, + node TYPE REF TO if_ixml_element, + workbook TYPE REF TO if_ixml_document, + stripped_name TYPE chkfile, + dirname TYPE string, + relationship TYPE t_relationship, + fileversion TYPE t_fileversion, + workbookpr TYPE t_workbookpr. + + CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH' + EXPORTING + full_name = iv_workbook_full_filename + IMPORTING + stripped_name = stripped_name + file_path = dirname. + + " Read Workbook Relationships + CONCATENATE dirname '_rels/' stripped_name '.rels' + INTO rels_workbook_path. + + rels_workbook = me->get_ixml_from_zip_archive( rels_workbook_path ). + + node ?= rels_workbook->find_from_name_ns( name = 'Relationship' uri = namespace-relationships ). + WHILE node IS BOUND. + me->fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = relationship ). + + CASE relationship-type. + WHEN lc_vba_project. + " Read VBA binary + CONCATENATE dirname relationship-target INTO path. + me->load_vbaproject( ip_path = path + ip_excel = io_excel ). + WHEN OTHERS. + ENDCASE. + + node ?= node->get_next( ). + ENDWHILE. + + " Read Workbook codeName + workbook = me->get_ixml_from_zip_archive( iv_workbook_full_filename ). + node ?= workbook->find_from_name_ns( name = 'fileVersion' uri = namespace-main ). + IF node IS BOUND. + + fill_struct_from_attributes( EXPORTING ip_element = node + CHANGING cp_structure = fileversion ). + + io_excel->yif_ecb_book_vba_project~set_codename( fileversion-codename ). + ENDIF. + + " Read Workbook codeName + workbook = me->get_ixml_from_zip_archive( iv_workbook_full_filename ). + node ?= workbook->find_from_name_ns( name = 'workbookPr' uri = namespace-main ). + IF node IS BOUND. + + fill_struct_from_attributes( EXPORTING ip_element = node + CHANGING cp_structure = workbookpr ). + + io_excel->yif_ecb_book_vba_project~set_codename_pr( workbookpr-codename ). + ENDIF. + + ENDMETHOD. + + + METHOD load_worksheet. + + super->load_worksheet( EXPORTING ip_path = ip_path + io_worksheet = io_worksheet ). + + DATA: node TYPE REF TO if_ixml_element, + worksheet TYPE REF TO if_ixml_document, + sheetpr TYPE t_sheetpr. + + " Read Workbook codeName + worksheet = me->get_ixml_from_zip_archive( ip_path ). + node ?= worksheet->find_from_name_ns( name = 'sheetPr' uri = namespace-main ). + IF node IS BOUND. + + fill_struct_from_attributes( EXPORTING ip_element = node + CHANGING cp_structure = sheetpr ). + IF sheetpr-codename IS NOT INITIAL. + io_worksheet->yif_ecb_sheet_vba_project~set_codename_pr( sheetpr-codename ). + ENDIF. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_reader_xlsm.clas.xml b/src/abap2xlsx/ycl_ecb_reader_xlsm.clas.xml new file mode 100644 index 0000000..4a71070 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_reader_xlsm.clas.xml @@ -0,0 +1,28 @@ + + + + + + YCL_ECB_READER_XLSM + E + Excel with macro reader + 1 + X + X + X + + + + LOAD_VBAPROJECT + E + Load VBA binary + + + LOAD_VBAPROJECT + I + Load VBA binary + + + + + diff --git a/src/abap2xlsx/ycl_ecb_row.clas.abap b/src/abap2xlsx/ycl_ecb_row.clas.abap new file mode 100644 index 0000000..5ad0d0d --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_row.clas.abap @@ -0,0 +1,238 @@ +CLASS ycl_ecb_row DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_ROW +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS constructor + IMPORTING + !ip_index TYPE int4 DEFAULT 0 . + METHODS get_collapsed + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet OPTIONAL + RETURNING + VALUE(r_collapsed) TYPE abap_bool . + METHODS get_outline_level + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet OPTIONAL + RETURNING + VALUE(r_outline_level) TYPE int4 . + METHODS get_row_height + RETURNING + VALUE(r_row_height) TYPE f . + METHODS get_custom_height + RETURNING + VALUE(r_custom_height) TYPE abap_bool . + METHODS get_row_index + RETURNING + VALUE(r_row_index) TYPE int4 . + METHODS get_visible + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet OPTIONAL + RETURNING + VALUE(r_visible) TYPE abap_bool . + METHODS get_xf_index + RETURNING + VALUE(r_xf_index) TYPE int4 . + METHODS set_collapsed + IMPORTING + !ip_collapsed TYPE abap_bool . + METHODS set_outline_level + IMPORTING + !ip_outline_level TYPE int4 + RAISING + ycx_ecb . + METHODS set_row_height + IMPORTING + !ip_row_height TYPE simple + !ip_custom_height TYPE abap_bool DEFAULT abap_true + RAISING + ycx_ecb . + METHODS set_row_index + IMPORTING + !ip_index TYPE int4 . + METHODS set_visible + IMPORTING + !ip_visible TYPE abap_bool . + METHODS set_xf_index + IMPORTING + !ip_xf_index TYPE int4 . +*"* protected components of class ZCL_EXCEL_ROW +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_ROW +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA row_index TYPE int4 . + DATA row_height TYPE f . + DATA visible TYPE abap_bool . + DATA outline_level TYPE int4 VALUE 0. "#EC NOTEXT . . . . . . . . . " . + DATA collapsed TYPE abap_bool . + DATA xf_index TYPE int4 . + DATA custom_height TYPE abap_bool . +ENDCLASS. + + + +CLASS ycl_ecb_row IMPLEMENTATION. + + + METHOD constructor. + " Initialise values + me->row_index = ip_index. + me->row_height = -1. + me->visible = abap_true. + me->outline_level = 0. + me->collapsed = abap_false. + + " set row dimension as unformatted by default + me->xf_index = 0. + me->custom_height = abap_false. + ENDMETHOD. + + + METHOD get_collapsed. + + DATA: lt_row_outlines TYPE ycl_ecb_worksheet=>mty_ts_outlines_row, + lv_previous_row TYPE i, + lv_following_row TYPE i. + + r_collapsed = me->collapsed. + + CHECK r_collapsed = abap_false. " Maybe new method for outlines is being used + CHECK io_worksheet IS BOUND. + +* If an outline is collapsed ( even inside an outer outline ) the line following the last line +* of the group gets the flag "collapsed" + IF io_worksheet->yif_ecb_sheet_properties~summarybelow = yif_ecb_sheet_properties=>c_below_off. + lv_following_row = me->row_index + 1. + lt_row_outlines = io_worksheet->get_row_outlines( ). + READ TABLE lt_row_outlines TRANSPORTING NO FIELDS WITH KEY row_from = lv_following_row " first line of an outline + collapsed = abap_true. " that is collapsed + ELSE. + lv_previous_row = me->row_index - 1. + lt_row_outlines = io_worksheet->get_row_outlines( ). + READ TABLE lt_row_outlines TRANSPORTING NO FIELDS WITH KEY row_to = lv_previous_row " last line of an outline + collapsed = abap_true. " that is collapsed + ENDIF. + CHECK sy-subrc = 0. " ok - we found it + r_collapsed = abap_true. + + + ENDMETHOD. + + + METHOD get_outline_level. + + DATA: lt_row_outlines TYPE ycl_ecb_worksheet=>mty_ts_outlines_row. + FIELD-SYMBOLS: LIKE LINE OF lt_row_outlines. + +* if someone has set the outline level explicitly - just use that + IF me->outline_level IS NOT INITIAL. + r_outline_level = me->outline_level. + RETURN. + ENDIF. +* Maybe we can use the outline information in the worksheet + CHECK io_worksheet IS BOUND. + + lt_row_outlines = io_worksheet->get_row_outlines( ). + LOOP AT lt_row_outlines ASSIGNING WHERE row_from <= me->row_index + AND row_to >= me->row_index. + + ADD 1 TO r_outline_level. + + ENDLOOP. + + ENDMETHOD. + + + METHOD get_row_height. + r_row_height = me->row_height. + ENDMETHOD. + + + METHOD get_custom_height. + r_custom_height = me->custom_height. + ENDMETHOD. + + + METHOD get_row_index. + r_row_index = me->row_index. + ENDMETHOD. + + + METHOD get_visible. + + DATA: lt_row_outlines TYPE ycl_ecb_worksheet=>mty_ts_outlines_row. + FIELD-SYMBOLS: LIKE LINE OF lt_row_outlines. + + r_visible = me->visible. + CHECK r_visible = abap_true. " Currently visible --> but maybe the new outline methodology will hide it implicitly + CHECK io_worksheet IS BOUND. " But we have to see the worksheet to make sure + + lt_row_outlines = io_worksheet->get_row_outlines( ). + LOOP AT lt_row_outlines ASSIGNING WHERE row_from <= me->row_index + AND row_to >= me->row_index + AND collapsed = abap_true. " row is in a collapsed outline --> not visible + CLEAR r_visible. + RETURN. " one hit is enough to ensure invisibility + + ENDLOOP. + + ENDMETHOD. + + + METHOD get_xf_index. + r_xf_index = me->xf_index. + ENDMETHOD. + + + METHOD set_collapsed. + me->collapsed = ip_collapsed. + ENDMETHOD. + + + METHOD set_outline_level. + IF ip_outline_level < 0 + OR ip_outline_level > 7. + + ycx_ecb=>raise_text( 'Outline level must range between 0 and 7.' ). + + ENDIF. + me->outline_level = ip_outline_level. + ENDMETHOD. + + + METHOD set_row_height. + DATA: height TYPE f. + TRY. + height = ip_row_height. + IF height <= 0. + ycx_ecb=>raise_text( 'Please supply a positive number as row-height' ). + ENDIF. + me->row_height = ip_row_height. + CATCH cx_sy_conversion_no_number. + ycx_ecb=>raise_text( 'Unable to interpret ip_row_height as number' ). + ENDTRY. + me->custom_height = ip_custom_height. + ENDMETHOD. + + + METHOD set_row_index. + me->row_index = ip_index. + ENDMETHOD. + + + METHOD set_visible. + me->visible = ip_visible. + ENDMETHOD. + + + METHOD set_xf_index. + me->xf_index = ip_xf_index. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_row.clas.xml b/src/abap2xlsx/ycl_ecb_row.clas.xml new file mode 100644 index 0000000..e88e29a --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_row.clas.xml @@ -0,0 +1,73 @@ + + + + + + YCL_ECB_ROW + E + Worksheet RowDimension + 1 + X + X + X + + + + COLLAPSED + E + Boolean Variable (X=True, -=False, Space=Unknown) + + + GET_COLLAPSED + E + new - please pass worksheet to make use of new outline info + + + GET_OUTLINE_LEVEL + E + new - please pass worksheet to make use of new outline info + + + GET_VISIBLE + E + new - please pass worksheet to make use of new outline info + + + OUTLINE_LEVEL + E + Natural number + + + ROW_HEIGHT + E + Field of type FLTP + + + ROW_INDEX + E + Natural number + + + SET_COLLAPSED + E + obsolete - please use worksheet->set_outline instead + + + SET_OUTLINE_LEVEL + E + obsolete - please use worksheet->set_outline instead + + + VISIBLE + E + Boolean Variable (X=True, -=False, Space=Unknown) + + + XF_INDEX + E + Natural number + + + + + diff --git a/src/abap2xlsx/ycl_ecb_rows.clas.abap b/src/abap2xlsx/ycl_ecb_rows.clas.abap new file mode 100644 index 0000000..4849052 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_rows.clas.abap @@ -0,0 +1,141 @@ +*----------------------------------------------------------------------* +* CLASS ZCL_EXCEL_ROWS DEFINITION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS ycl_ecb_rows DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_ROWS +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! + PUBLIC SECTION. + METHODS add + IMPORTING + !io_row TYPE REF TO ycl_ecb_row . + METHODS clear . + METHODS constructor . + METHODS get + IMPORTING + !ip_index TYPE i + RETURNING + VALUE(eo_row) TYPE REF TO ycl_ecb_row . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !io_row TYPE REF TO ycl_ecb_row . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . + METHODS get_min_index + RETURNING + VALUE(ep_index) TYPE i . + METHODS get_max_index + RETURNING + VALUE(ep_index) TYPE i . + PROTECTED SECTION. +*"* private components of class ZABAP_EXCEL_RANGES +*"* do not include other source files here!!! + PRIVATE SECTION. + TYPES: + BEGIN OF mty_s_hashed_row, + row_index TYPE int4, + row TYPE REF TO ycl_ecb_row, + END OF mty_s_hashed_row , + mty_ts_hashed_row TYPE HASHED TABLE OF mty_s_hashed_row WITH UNIQUE KEY row_index. + + DATA rows TYPE REF TO ycl_ecb_collection . + DATA rows_hashed TYPE mty_ts_hashed_row . + +ENDCLASS. + + + +CLASS ycl_ecb_rows IMPLEMENTATION. + + + METHOD add. + DATA: ls_hashed_row TYPE mty_s_hashed_row. + + ls_hashed_row-row_index = io_row->get_row_index( ). + ls_hashed_row-row = io_row. + + INSERT ls_hashed_row INTO TABLE rows_hashed. + + rows->add( io_row ). + ENDMETHOD. "ADD + + + METHOD clear. + CLEAR rows_hashed. + rows->clear( ). + ENDMETHOD. "CLEAR + + + METHOD constructor. + + CREATE OBJECT rows. + + ENDMETHOD. "CONSTRUCTOR + + + METHOD get. + FIELD-SYMBOLS: TYPE mty_s_hashed_row. + + READ TABLE rows_hashed WITH KEY row_index = ip_index ASSIGNING . + IF sy-subrc = 0. + eo_row = -row. + ENDIF. + ENDMETHOD. "GET + + + METHOD get_iterator. + eo_iterator ?= rows->get_iterator( ). + ENDMETHOD. "GET_ITERATOR + + + METHOD get_max_index. + FIELD-SYMBOLS: TYPE mty_s_hashed_row. + + LOOP AT rows_hashed ASSIGNING . + IF -row_index > ep_index. + ep_index = -row_index. + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD get_min_index. + FIELD-SYMBOLS: TYPE mty_s_hashed_row. + + LOOP AT rows_hashed ASSIGNING . + IF ep_index = 0 OR -row_index < ep_index. + ep_index = -row_index. + ENDIF. + ENDLOOP. + ENDMETHOD. + + + METHOD is_empty. + is_empty = rows->is_empty( ). + ENDMETHOD. "IS_EMPTY + + + METHOD remove. + DELETE TABLE rows_hashed WITH TABLE KEY row_index = io_row->get_row_index( ) . + rows->remove( io_row ). + ENDMETHOD. "REMOVE + + + METHOD size. + ep_size = rows->size( ). + ENDMETHOD. "SIZE +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_rows.clas.xml b/src/abap2xlsx/ycl_ecb_rows.clas.xml new file mode 100644 index 0000000..56db04b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_rows.clas.xml @@ -0,0 +1,58 @@ + + + + + + YCL_ECB_ROWS + E + Ranges collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + GET + E + Gets Element + + + GET_ITERATOR + E + Returns an iterator + + + IS_EMPTY + E + Checks whether elements are contained + + + REMOVE + E + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + + + diff --git a/src/abap2xlsx/ycl_ecb_security.clas.abap b/src/abap2xlsx/ycl_ecb_security.clas.abap new file mode 100644 index 0000000..e04aa9b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_security.clas.abap @@ -0,0 +1,39 @@ +CLASS ycl_ecb_security DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_SECURITY +*"* do not include other source files here!!! + PUBLIC SECTION. + + DATA lockrevision TYPE flag . + DATA lockstructure TYPE flag . + DATA lockwindows TYPE flag . + DATA revisionspassword TYPE yecb_revisionspassword . + DATA workbookpassword TYPE yecb_workbookpassword . + + METHODS is_security_enabled + RETURNING + VALUE(ep_security_enabled) TYPE flag . +*"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZABAP_EXCEL_SECURITY +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_security IMPLEMENTATION. + + + METHOD is_security_enabled. + IF lockrevision EQ abap_true OR lockstructure EQ abap_true OR lockwindows EQ abap_true. + ep_security_enabled = abap_true. + ENDIF. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_security.clas.xml b/src/abap2xlsx/ycl_ecb_security.clas.xml new file mode 100644 index 0000000..1969ba8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_security.clas.xml @@ -0,0 +1,78 @@ + + + + + + YCL_ECB_SECURITY + E + Security + 1 + X + X + X + + + + IS_SECURITY_ENABLED + E + Is some sort of dcument security enabled? + + + IS_SECURITY_ENABLED + I + Is some sort of dcument security enabled? + + + LOCKREVISION + E + General Flag + + + LOCKREVISION + I + General Flag + + + LOCKSTRUCTURE + E + General Flag + + + LOCKSTRUCTURE + I + General Flag + + + LOCKWINDOWS + E + General Flag + + + LOCKWINDOWS + I + General Flag + + + REVISIONSPASSWORD + E + Revisions password + + + REVISIONSPASSWORD + I + Revisions password + + + WORKBOOKPASSWORD + E + Workbook password + + + WORKBOOKPASSWORD + I + Workbook password + + + + + diff --git a/src/abap2xlsx/ycl_ecb_sheet_setup.clas.abap b/src/abap2xlsx/ycl_ecb_sheet_setup.clas.abap new file mode 100644 index 0000000..5ad4a85 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_sheet_setup.clas.abap @@ -0,0 +1,478 @@ +CLASS ycl_ecb_sheet_setup DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! + + DATA black_and_white TYPE flag . + DATA cell_comments TYPE string . + DATA copies TYPE int2 . + CONSTANTS c_break_column TYPE yecb_break VALUE 2. "#EC NOTEXT + CONSTANTS c_break_none TYPE yecb_break VALUE 0. "#EC NOTEXT + CONSTANTS c_break_row TYPE yecb_break VALUE 1. "#EC NOTEXT + CONSTANTS c_cc_as_displayed TYPE string VALUE 'asDisplayed'. "#EC NOTEXT + CONSTANTS c_cc_at_end TYPE string VALUE 'atEnd'. "#EC NOTEXT + CONSTANTS c_cc_none TYPE string VALUE 'none'. "#EC NOTEXT + CONSTANTS c_ord_downthenover TYPE string VALUE 'downThenOver'. "#EC NOTEXT + CONSTANTS c_ord_overthendown TYPE string VALUE 'overThenDown'. "#EC NOTEXT + CONSTANTS c_orientation_default TYPE yecb_sheet_orienatation VALUE 'default'. "#EC NOTEXT + CONSTANTS c_orientation_landscape TYPE yecb_sheet_orienatation VALUE 'landscape'. "#EC NOTEXT + CONSTANTS c_orientation_portrait TYPE yecb_sheet_orienatation VALUE 'portrait'. "#EC NOTEXT + CONSTANTS c_papersize_6_3_4_envelope TYPE yecb_sheet_paper_size VALUE 38. "#EC NOTEXT + CONSTANTS c_papersize_a2_paper TYPE yecb_sheet_paper_size VALUE 64. "#EC NOTEXT + CONSTANTS c_papersize_a3 TYPE yecb_sheet_paper_size VALUE 8. "#EC NOTEXT + CONSTANTS c_papersize_a3_extra_paper TYPE yecb_sheet_paper_size VALUE 61. "#EC NOTEXT + CONSTANTS c_papersize_a3_extra_tv_paper TYPE yecb_sheet_paper_size VALUE 66. "#EC NOTEXT + CONSTANTS c_papersize_a3_tv_paper TYPE yecb_sheet_paper_size VALUE 65. "#EC NOTEXT + CONSTANTS c_papersize_a4 TYPE yecb_sheet_paper_size VALUE 9. "#EC NOTEXT + CONSTANTS c_papersize_a4_extra_paper TYPE yecb_sheet_paper_size VALUE 51. "#EC NOTEXT + CONSTANTS c_papersize_a4_plus_paper TYPE yecb_sheet_paper_size VALUE 58. "#EC NOTEXT + CONSTANTS c_papersize_a4_small TYPE yecb_sheet_paper_size VALUE 10. "#EC NOTEXT + CONSTANTS c_papersize_a4_tv_paper TYPE yecb_sheet_paper_size VALUE 53. "#EC NOTEXT + CONSTANTS c_papersize_a5 TYPE yecb_sheet_paper_size VALUE 11. "#EC NOTEXT + CONSTANTS c_papersize_a5_extra_paper TYPE yecb_sheet_paper_size VALUE 62. "#EC NOTEXT + CONSTANTS c_papersize_a5_tv_paper TYPE yecb_sheet_paper_size VALUE 59. "#EC NOTEXT + CONSTANTS c_papersize_b4 TYPE yecb_sheet_paper_size VALUE 12. "#EC NOTEXT + CONSTANTS c_papersize_b4_envelope TYPE yecb_sheet_paper_size VALUE 33. "#EC NOTEXT + CONSTANTS c_papersize_b5 TYPE yecb_sheet_paper_size VALUE 13. "#EC NOTEXT + CONSTANTS c_papersize_b5_envelope TYPE yecb_sheet_paper_size VALUE 34. "#EC NOTEXT + CONSTANTS c_papersize_b6_envelope TYPE yecb_sheet_paper_size VALUE 35. "#EC NOTEXT + CONSTANTS c_papersize_c TYPE yecb_sheet_paper_size VALUE 24. "#EC NOTEXT + CONSTANTS c_papersize_c3_envelope TYPE yecb_sheet_paper_size VALUE 29. "#EC NOTEXT + CONSTANTS c_papersize_c4_envelope TYPE yecb_sheet_paper_size VALUE 30. "#EC NOTEXT + CONSTANTS c_papersize_c5_envelope TYPE yecb_sheet_paper_size VALUE 28. "#EC NOTEXT + CONSTANTS c_papersize_c65_envelope TYPE yecb_sheet_paper_size VALUE 32. "#EC NOTEXT + CONSTANTS c_papersize_c6_envelope TYPE yecb_sheet_paper_size VALUE 31. "#EC NOTEXT + CONSTANTS c_papersize_d TYPE yecb_sheet_paper_size VALUE 25. "#EC NOTEXT + CONSTANTS c_papersize_de_leg_fanfold TYPE yecb_sheet_paper_size VALUE 41. "#EC NOTEXT + CONSTANTS c_papersize_de_std_fanfold TYPE yecb_sheet_paper_size VALUE 40. "#EC NOTEXT + CONSTANTS c_papersize_dl_envelope TYPE yecb_sheet_paper_size VALUE 27. "#EC NOTEXT + CONSTANTS c_papersize_e TYPE yecb_sheet_paper_size VALUE 26. "#EC NOTEXT + CONSTANTS c_papersize_executive TYPE yecb_sheet_paper_size VALUE 7. "#EC NOTEXT + CONSTANTS c_papersize_folio TYPE yecb_sheet_paper_size VALUE 14. "#EC NOTEXT + CONSTANTS c_papersize_invite_envelope TYPE yecb_sheet_paper_size VALUE 47. "#EC NOTEXT + CONSTANTS c_papersize_iso_b4 TYPE yecb_sheet_paper_size VALUE 42. "#EC NOTEXT + CONSTANTS c_papersize_iso_b5_extra_paper TYPE yecb_sheet_paper_size VALUE 63. "#EC NOTEXT + CONSTANTS c_papersize_italy_envelope TYPE yecb_sheet_paper_size VALUE 36. "#EC NOTEXT + CONSTANTS c_papersize_jis_b5_tv_paper TYPE yecb_sheet_paper_size VALUE 60. "#EC NOTEXT + CONSTANTS c_papersize_jpn_dbl_postcard TYPE yecb_sheet_paper_size VALUE 43. "#EC NOTEXT + CONSTANTS c_papersize_ledger TYPE yecb_sheet_paper_size VALUE 4. "#EC NOTEXT + CONSTANTS c_papersize_legal TYPE yecb_sheet_paper_size VALUE 5. "#EC NOTEXT + CONSTANTS c_papersize_legal_extra_paper TYPE yecb_sheet_paper_size VALUE 49. "#EC NOTEXT + CONSTANTS c_papersize_letter TYPE yecb_sheet_paper_size VALUE 1. "#EC NOTEXT + CONSTANTS c_papersize_letter_extra_paper TYPE yecb_sheet_paper_size VALUE 48. "#EC NOTEXT + CONSTANTS c_papersize_letter_extv_paper TYPE yecb_sheet_paper_size VALUE 54. "#EC NOTEXT + CONSTANTS c_papersize_letter_plus_paper TYPE yecb_sheet_paper_size VALUE 57. "#EC NOTEXT + CONSTANTS c_papersize_letter_small TYPE yecb_sheet_paper_size VALUE 2. "#EC NOTEXT + CONSTANTS c_papersize_letter_tv_paper TYPE yecb_sheet_paper_size VALUE 52. "#EC NOTEXT + CONSTANTS c_papersize_monarch_envelope TYPE yecb_sheet_paper_size VALUE 37. "#EC NOTEXT + CONSTANTS c_papersize_no10_envelope TYPE yecb_sheet_paper_size VALUE 20. "#EC NOTEXT + CONSTANTS c_papersize_no11_envelope TYPE yecb_sheet_paper_size VALUE 21. "#EC NOTEXT + CONSTANTS c_papersize_no12_envelope TYPE yecb_sheet_paper_size VALUE 22. "#EC NOTEXT + CONSTANTS c_papersize_no14_envelope TYPE yecb_sheet_paper_size VALUE 23. "#EC NOTEXT + CONSTANTS c_papersize_no9_envelope TYPE yecb_sheet_paper_size VALUE 19. "#EC NOTEXT + CONSTANTS c_papersize_note TYPE yecb_sheet_paper_size VALUE 18. "#EC NOTEXT + CONSTANTS c_papersize_quarto TYPE yecb_sheet_paper_size VALUE 15. "#EC NOTEXT + CONSTANTS c_papersize_standard_1 TYPE yecb_sheet_paper_size VALUE 16. "#EC NOTEXT + CONSTANTS c_papersize_standard_2 TYPE yecb_sheet_paper_size VALUE 17. "#EC NOTEXT + CONSTANTS c_papersize_standard_paper_1 TYPE yecb_sheet_paper_size VALUE 44. "#EC NOTEXT + CONSTANTS c_papersize_standard_paper_2 TYPE yecb_sheet_paper_size VALUE 45. "#EC NOTEXT + CONSTANTS c_papersize_standard_paper_3 TYPE yecb_sheet_paper_size VALUE 46. "#EC NOTEXT + CONSTANTS c_papersize_statement TYPE yecb_sheet_paper_size VALUE 6. "#EC NOTEXT + CONSTANTS c_papersize_supera_a4_paper TYPE yecb_sheet_paper_size VALUE 55. "#EC NOTEXT + CONSTANTS c_papersize_superb_a3_paper TYPE yecb_sheet_paper_size VALUE 56. "#EC NOTEXT + CONSTANTS c_papersize_tabloid TYPE yecb_sheet_paper_size VALUE 3. "#EC NOTEXT + CONSTANTS c_papersize_tabl_extra_paper TYPE yecb_sheet_paper_size VALUE 50. "#EC NOTEXT + CONSTANTS c_papersize_us_std_fanfold TYPE yecb_sheet_paper_size VALUE 39. "#EC NOTEXT + CONSTANTS c_pe_blank TYPE string VALUE 'blank'. "#EC NOTEXT + CONSTANTS c_pe_dash TYPE string VALUE 'dash'. "#EC NOTEXT + CONSTANTS c_pe_displayed TYPE string VALUE 'displayed'. "#EC NOTEXT + CONSTANTS c_pe_na TYPE string VALUE 'NA'. "#EC NOTEXT + DATA diff_oddeven_headerfooter TYPE flag . + DATA draft TYPE flag . + DATA errors TYPE string . + DATA even_footer TYPE yecb_s_worksheet_head_foot . + DATA even_header TYPE yecb_s_worksheet_head_foot . + DATA first_page_number TYPE int2 . + DATA fit_to_height TYPE int2 . + DATA fit_to_page TYPE flag . + DATA fit_to_width TYPE int2 . + DATA horizontal_centered TYPE flag . + DATA horizontal_dpi TYPE int2 . + DATA margin_bottom TYPE yecb_dec_8_2 . + DATA margin_footer TYPE yecb_dec_8_2 . + DATA margin_header TYPE yecb_dec_8_2 . + DATA margin_left TYPE yecb_dec_8_2 . + DATA margin_right TYPE yecb_dec_8_2 . + DATA margin_top TYPE yecb_dec_8_2 . + DATA odd_footer TYPE yecb_s_worksheet_head_foot . + DATA odd_header TYPE yecb_s_worksheet_head_foot . + DATA orientation TYPE yecb_sheet_orienatation . + DATA page_order TYPE string . + DATA paper_height TYPE string . + DATA paper_size TYPE int2 . + DATA paper_width TYPE string . + DATA scale TYPE int2 . + DATA use_first_page_num TYPE flag . + DATA use_printer_defaults TYPE flag . + DATA vertical_centered TYPE flag . + DATA vertical_dpi TYPE int2 . + + METHODS constructor . + METHODS set_page_margins + IMPORTING + !ip_bottom TYPE f OPTIONAL + !ip_footer TYPE f OPTIONAL + !ip_header TYPE f OPTIONAL + !ip_left TYPE f OPTIONAL + !ip_right TYPE f OPTIONAL + !ip_top TYPE f OPTIONAL + !ip_unit TYPE csequence DEFAULT 'in' . + METHODS set_header_footer + IMPORTING + !ip_odd_header TYPE yecb_s_worksheet_head_foot OPTIONAL + !ip_odd_footer TYPE yecb_s_worksheet_head_foot OPTIONAL + !ip_even_header TYPE yecb_s_worksheet_head_foot OPTIONAL + !ip_even_footer TYPE yecb_s_worksheet_head_foot OPTIONAL . + METHODS get_header_footer_string + EXPORTING + !ep_odd_header TYPE string + !ep_odd_footer TYPE string + !ep_even_header TYPE string + !ep_even_footer TYPE string . + METHODS get_header_footer + EXPORTING + !ep_odd_header TYPE yecb_s_worksheet_head_foot + !ep_odd_footer TYPE yecb_s_worksheet_head_foot + !ep_even_header TYPE yecb_s_worksheet_head_foot + !ep_even_footer TYPE yecb_s_worksheet_head_foot . + PROTECTED SECTION. + +*"* protected components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! + METHODS process_header_footer + IMPORTING + !ip_header TYPE yecb_s_worksheet_head_foot + !ip_side TYPE string + RETURNING + VALUE(rv_processed_string) TYPE string . + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_SHEET_SETUP +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_sheet_setup IMPLEMENTATION. + + + METHOD constructor. + orientation = me->c_orientation_default. + +* default margins + margin_bottom = '0.75'. + margin_footer = '0.3'. + margin_header = '0.3'. + margin_left = '0.7'. + margin_right = '0.7'. + margin_top = '0.75'. + +* clear page settings + CLEAR: black_and_white, + cell_comments, + copies, + draft, + errors, + first_page_number, + fit_to_page, + fit_to_height, + fit_to_width, + horizontal_dpi, + orientation, + page_order, + paper_height, + paper_size, + paper_width, + scale, + use_first_page_num, + use_printer_defaults, + vertical_dpi. + ENDMETHOD. + + + METHOD get_header_footer. + +* Only Basic font/text formatting possible: +* Bold (yes / no), Font Type, Font Size +* +* usefull placeholders, which can be used in header/footer value strings +* '&P' - page number +* '&N' - total number of pages +* '&D' - Date +* '&T' - Time +* '&F' - File Name +* '&Z' - Path +* '&A' - Sheet name +* new line via class constant CL_ABAP_CHAR_UTILITIES=>newline +* +* Example Value String 'page &P of &N' +* +* DO NOT USE &L , &C or &R which automatically created as position markers + + ep_odd_header = me->odd_header. + ep_odd_footer = me->odd_footer. + ep_even_header = me->even_header. + ep_even_footer = me->even_footer. + + ENDMETHOD. + + + METHOD get_header_footer_string. +* ---------------------------------------------------------------------- + DATA: lc_marker_left(2) TYPE c VALUE '&L' + , lc_marker_right(2) TYPE c VALUE '&R' + , lc_marker_center(2) TYPE c VALUE '&C' + , lv_value TYPE string + . +* ---------------------------------------------------------------------- + IF ep_odd_header IS SUPPLIED. + + IF me->odd_header-left_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->odd_header ip_side = 'LEFT' ). + CONCATENATE lc_marker_left lv_value INTO ep_odd_header. + ENDIF. + + IF me->odd_header-center_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->odd_header ip_side = 'CENTER' ). + CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_odd_header. + ENDIF. + + IF me->odd_header-right_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->odd_header ip_side = 'RIGHT' ). + CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_odd_header. + ENDIF. + + IF me->odd_header-left_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_odd_header. + ENDIF. + IF me->odd_header-center_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_odd_header. + ENDIF. + IF me->odd_header-right_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_odd_header. + ENDIF. + + ENDIF. +* ---------------------------------------------------------------------- + IF ep_odd_footer IS SUPPLIED. + + IF me->odd_footer-left_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->odd_footer ip_side = 'LEFT' ). + CONCATENATE lc_marker_left lv_value INTO ep_odd_footer. + ENDIF. + + IF me->odd_footer-center_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->odd_footer ip_side = 'CENTER' ). + CONCATENATE ep_odd_footer lc_marker_center lv_value INTO ep_odd_footer. + ENDIF. + + IF me->odd_footer-right_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->odd_footer ip_side = 'RIGHT' ). + CONCATENATE ep_odd_footer lc_marker_right lv_value INTO ep_odd_footer. + ENDIF. + + IF me->odd_footer-left_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_odd_footer. + ENDIF. + IF me->odd_footer-center_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_odd_footer. + ENDIF. + IF me->odd_footer-right_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_odd_footer. + ENDIF. + + ENDIF. +* ---------------------------------------------------------------------- + IF ep_even_header IS SUPPLIED. + + IF me->even_header-left_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->even_header ip_side = 'LEFT' ). + CONCATENATE lc_marker_left lv_value INTO ep_even_header. + ENDIF. + + IF me->even_header-center_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->even_header ip_side = 'CENTER' ). + CONCATENATE ep_even_header lc_marker_center lv_value INTO ep_even_header. + ENDIF. + + IF me->even_header-right_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->even_header ip_side = 'RIGHT' ). + CONCATENATE ep_even_header lc_marker_right lv_value INTO ep_even_header. + ENDIF. + + IF me->even_header-left_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_even_header. + ENDIF. + IF me->even_header-center_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_even_header. + ENDIF. + IF me->even_header-right_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_even_header. + ENDIF. + + ENDIF. +* ---------------------------------------------------------------------- + IF ep_even_footer IS SUPPLIED. + + IF me->even_footer-left_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->even_footer ip_side = 'LEFT' ). + CONCATENATE lc_marker_left lv_value INTO ep_even_footer. + ENDIF. + + IF me->even_footer-center_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->even_footer ip_side = 'CENTER' ). + CONCATENATE ep_even_footer lc_marker_center lv_value INTO ep_even_footer. + ENDIF. + + IF me->even_footer-right_value IS NOT INITIAL. + lv_value = me->process_header_footer( ip_header = me->even_footer ip_side = 'RIGHT' ). + CONCATENATE ep_even_footer lc_marker_right lv_value INTO ep_even_footer. + ENDIF. + + IF me->even_footer-left_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_left lv_value INTO ep_even_footer. + ENDIF. + IF me->even_footer-center_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_center lv_value INTO ep_even_footer. + ENDIF. + IF me->even_footer-right_image IS NOT INITIAL. + lv_value = '&G'. + CONCATENATE ep_odd_header lc_marker_right lv_value INTO ep_even_footer. + ENDIF. + + ENDIF. +* ---------------------------------------------------------------------- + ENDMETHOD. + + + METHOD process_header_footer. + +* ---------------------------------------------------------------------- +* Only Basic font/text formatting possible: +* Bold (yes / no), Font Type, Font Size + + DATA: lv_fname(12) TYPE c + , lv_string TYPE string + . + + FIELD-SYMBOLS: TYPE string + , TYPE yecb_s_style_font + . + +* ---------------------------------------------------------------------- + CONCATENATE ip_side '_VALUE' INTO lv_fname. + ASSIGN COMPONENT lv_fname OF STRUCTURE ip_header TO . + + CONCATENATE ip_side '_FONT' INTO lv_fname. + ASSIGN COMPONENT lv_fname OF STRUCTURE ip_header TO . + + IF IS ASSIGNED AND IS ASSIGNED. + + IF = '&G'. "image header + rv_processed_string = . + ELSE. + + IF -name IS NOT INITIAL. + CONCATENATE '&"' -name ',' INTO rv_processed_string. + ELSE. + rv_processed_string = '&"-,'. + ENDIF. + + IF -bold = abap_true. + CONCATENATE rv_processed_string 'Bold"' INTO rv_processed_string. + ELSE. + CONCATENATE rv_processed_string 'Standard"' INTO rv_processed_string. + ENDIF. + + IF -size IS NOT INITIAL. + lv_string = -size. + CONCATENATE rv_processed_string '&' lv_string INTO rv_processed_string. + CONDENSE rv_processed_string NO-GAPS. + ENDIF. + + CONCATENATE rv_processed_string INTO rv_processed_string. + ENDIF. + ENDIF. +* ---------------------------------------------------------------------- + + ENDMETHOD. + + + METHOD set_header_footer. + +* Only Basic font/text formatting possible: +* Bold (yes / no), Font Type, Font Size +* +* usefull placeholders, which can be used in header/footer value strings +* '&P' - page number +* '&N' - total number of pages +* '&D' - Date +* '&T' - Time +* '&F' - File Name +* '&Z' - Path +* '&A' - Sheet name +* new line via class constant CL_ABAP_CHAR_UTILITIES=>newline +* +* Example Value String 'page &P of &N' +* +* DO NOT USE &L , &C or &R which automatically created as position markers + + me->odd_header = ip_odd_header. + me->odd_footer = ip_odd_footer. + me->even_header = ip_even_header. + me->even_footer = ip_even_footer. + + IF me->even_header IS NOT INITIAL OR me->even_footer IS NOT INITIAL. + me->diff_oddeven_headerfooter = abap_true. + ENDIF. + + + ENDMETHOD. + + + METHOD set_page_margins. + DATA: lv_coef TYPE f, + lv_unit TYPE string. + + lv_unit = ip_unit. + TRANSLATE lv_unit TO UPPER CASE. + + CASE lv_unit. + WHEN 'IN'. lv_coef = 1. + WHEN 'CM'. lv_coef = '0.393700787'. + WHEN 'MM'. lv_coef = '0.0393700787'. + ENDCASE. + + IF ip_bottom IS SUPPLIED. margin_bottom = lv_coef * ip_bottom. ENDIF. + IF ip_footer IS SUPPLIED. margin_footer = lv_coef * ip_footer. ENDIF. + IF ip_header IS SUPPLIED. margin_header = lv_coef * ip_header. ENDIF. + IF ip_left IS SUPPLIED. margin_left = lv_coef * ip_left. ENDIF. + IF ip_right IS SUPPLIED. margin_right = lv_coef * ip_right. ENDIF. + IF ip_top IS SUPPLIED. margin_top = lv_coef * ip_top. ENDIF. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_sheet_setup.clas.xml b/src/abap2xlsx/ycl_ecb_sheet_setup.clas.xml new file mode 100644 index 0000000..e3a3336 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_sheet_setup.clas.xml @@ -0,0 +1,1198 @@ + + + + + + YCL_ECB_SHEET_SETUP + E + Sheet setup + 1 + X + X + X + + + + BLACK_AND_WHITE + E + Print black and white + + + BLACK_AND_WHITE + I + Print black and white + + + CELL_COMMENTS + E + This attribute specifies how to print cell comments + + + CELL_COMMENTS + I + This attribute specifies how to print cell comments + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + COPIES + E + Number of copies to print + + + COPIES + I + Number of copies to print + + + C_BREAK_COLUMN + E + Worksheet Break + + + C_BREAK_COLUMN + I + Worksheet Break + + + C_BREAK_NONE + E + Worksheet Break + + + C_BREAK_NONE + I + Worksheet Break + + + C_BREAK_ROW + E + Worksheet Break + + + C_BREAK_ROW + I + Worksheet Break + + + C_CC_AS_DISPLAYED + E + Cell comments + + + C_CC_AS_DISPLAYED + I + Cell comments + + + C_CC_AT_END + E + Cell comments + + + C_CC_AT_END + I + Cell comments + + + C_CC_NONE + E + Cell commenct + + + C_CC_NONE + I + Cell commenct + + + C_ORD_DOWNTHENOVER + E + Page order + + + C_ORD_DOWNTHENOVER + I + Page order + + + C_ORD_OVERTHENDOWN + E + Page order + + + C_ORD_OVERTHENDOWN + I + Page order + + + C_ORIENTATION_DEFAULT + E + Sheet orientation + + + C_ORIENTATION_DEFAULT + I + Sheet orientation + + + C_ORIENTATION_LANDSCAPE + E + Sheet orientation + + + C_ORIENTATION_LANDSCAPE + I + Sheet orientation + + + C_ORIENTATION_PORTRAIT + E + Sheet orientation + + + C_ORIENTATION_PORTRAIT + I + Sheet orientation + + + C_PAPERSIZE_6_3_4_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_6_3_4_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_A2_PAPER + E + Fill Type + + + C_PAPERSIZE_A2_PAPER + I + Fill Type + + + C_PAPERSIZE_A3 + E + Fill Type + + + C_PAPERSIZE_A3 + I + Fill Type + + + C_PAPERSIZE_A3_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_A3_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_A3_EXTRA_TV_PAPER + E + Fill Type + + + C_PAPERSIZE_A3_EXTRA_TV_PAPER + I + Fill Type + + + C_PAPERSIZE_A3_TV_PAPER + E + Fill Type + + + C_PAPERSIZE_A3_TV_PAPER + I + Fill Type + + + C_PAPERSIZE_A4 + E + Fill Type + + + C_PAPERSIZE_A4 + I + Fill Type + + + C_PAPERSIZE_A4_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_A4_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_A4_PLUS_PAPER + E + Fill Type + + + C_PAPERSIZE_A4_PLUS_PAPER + I + Fill Type + + + C_PAPERSIZE_A4_SMALL + E + Fill Type + + + C_PAPERSIZE_A4_SMALL + I + Fill Type + + + C_PAPERSIZE_A4_TV_PAPER + E + Fill Type + + + C_PAPERSIZE_A4_TV_PAPER + I + Fill Type + + + C_PAPERSIZE_A5 + E + Fill Type + + + C_PAPERSIZE_A5 + I + Fill Type + + + C_PAPERSIZE_A5_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_A5_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_A5_TV_PAPER + E + Fill Type + + + C_PAPERSIZE_A5_TV_PAPER + I + Fill Type + + + C_PAPERSIZE_B4 + E + Fill Type + + + C_PAPERSIZE_B4 + I + Fill Type + + + C_PAPERSIZE_B4_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_B4_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_B5 + E + Fill Type + + + C_PAPERSIZE_B5 + I + Fill Type + + + C_PAPERSIZE_B5_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_B5_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_B6_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_B6_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_C + E + Fill Type + + + C_PAPERSIZE_C + I + Fill Type + + + C_PAPERSIZE_C3_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_C3_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_C4_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_C4_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_C5_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_C5_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_C65_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_C65_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_C6_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_C6_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_D + E + Fill Type + + + C_PAPERSIZE_D + I + Fill Type + + + C_PAPERSIZE_DE_LEG_FANFOLD + E + Fill Type + + + C_PAPERSIZE_DE_LEG_FANFOLD + I + Fill Type + + + C_PAPERSIZE_DE_STD_FANFOLD + E + Fill Type + + + C_PAPERSIZE_DE_STD_FANFOLD + I + Fill Type + + + C_PAPERSIZE_DL_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_DL_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_E + E + Fill Type + + + C_PAPERSIZE_E + I + Fill Type + + + C_PAPERSIZE_EXECUTIVE + E + Fill Type + + + C_PAPERSIZE_EXECUTIVE + I + Fill Type + + + C_PAPERSIZE_FOLIO + E + Fill Type + + + C_PAPERSIZE_FOLIO + I + Fill Type + + + C_PAPERSIZE_INVITE_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_INVITE_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_ISO_B4 + E + Fill Type + + + C_PAPERSIZE_ISO_B4 + I + Fill Type + + + C_PAPERSIZE_ISO_B5_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_ISO_B5_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_ITALY_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_ITALY_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_JIS_B5_TV_PAPER + E + Fill Type + + + C_PAPERSIZE_JIS_B5_TV_PAPER + I + Fill Type + + + C_PAPERSIZE_JPN_DBL_POSTCARD + E + Fill Type + + + C_PAPERSIZE_JPN_DBL_POSTCARD + I + Fill Type + + + C_PAPERSIZE_LEDGER + E + Fill Type + + + C_PAPERSIZE_LEDGER + I + Fill Type + + + C_PAPERSIZE_LEGAL + E + Fill Type + + + C_PAPERSIZE_LEGAL + I + Fill Type + + + C_PAPERSIZE_LEGAL_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_LEGAL_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_LETTER + E + Fill Type + + + C_PAPERSIZE_LETTER + I + Fill Type + + + C_PAPERSIZE_LETTER_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_LETTER_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_LETTER_EXTV_PAPER + E + Fill Type + + + C_PAPERSIZE_LETTER_EXTV_PAPER + I + Fill Type + + + C_PAPERSIZE_LETTER_PLUS_PAPER + E + Fill Type + + + C_PAPERSIZE_LETTER_PLUS_PAPER + I + Fill Type + + + C_PAPERSIZE_LETTER_SMALL + E + Fill Type + + + C_PAPERSIZE_LETTER_SMALL + I + Fill Type + + + C_PAPERSIZE_LETTER_TV_PAPER + E + Fill Type + + + C_PAPERSIZE_LETTER_TV_PAPER + I + Fill Type + + + C_PAPERSIZE_MONARCH_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_MONARCH_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_NO10_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_NO10_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_NO11_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_NO11_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_NO12_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_NO12_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_NO14_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_NO14_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_NO9_ENVELOPE + E + Fill Type + + + C_PAPERSIZE_NO9_ENVELOPE + I + Fill Type + + + C_PAPERSIZE_NOTE + E + Fill Type + + + C_PAPERSIZE_NOTE + I + Fill Type + + + C_PAPERSIZE_QUARTO + E + Fill Type + + + C_PAPERSIZE_QUARTO + I + Fill Type + + + C_PAPERSIZE_STANDARD_1 + E + Fill Type + + + C_PAPERSIZE_STANDARD_1 + I + Fill Type + + + C_PAPERSIZE_STANDARD_2 + E + Fill Type + + + C_PAPERSIZE_STANDARD_2 + I + Fill Type + + + C_PAPERSIZE_STANDARD_PAPER_1 + E + Fill Type + + + C_PAPERSIZE_STANDARD_PAPER_1 + I + Fill Type + + + C_PAPERSIZE_STANDARD_PAPER_2 + E + Fill Type + + + C_PAPERSIZE_STANDARD_PAPER_2 + I + Fill Type + + + C_PAPERSIZE_STANDARD_PAPER_3 + E + Fill Type + + + C_PAPERSIZE_STANDARD_PAPER_3 + I + Fill Type + + + C_PAPERSIZE_STATEMENT + E + Fill Type + + + C_PAPERSIZE_STATEMENT + I + Fill Type + + + C_PAPERSIZE_SUPERA_A4_PAPER + E + Fill Type + + + C_PAPERSIZE_SUPERA_A4_PAPER + I + Fill Type + + + C_PAPERSIZE_SUPERB_A3_PAPER + E + Fill Type + + + C_PAPERSIZE_SUPERB_A3_PAPER + I + Fill Type + + + C_PAPERSIZE_TABLOID + E + Fill Type + + + C_PAPERSIZE_TABLOID + I + Fill Type + + + C_PAPERSIZE_TABL_EXTRA_PAPER + E + Fill Type + + + C_PAPERSIZE_TABL_EXTRA_PAPER + I + Fill Type + + + C_PAPERSIZE_US_STD_FANFOLD + E + Fill Type + + + C_PAPERSIZE_US_STD_FANFOLD + I + Fill Type + + + C_PE_BLANK + E + Print error + + + C_PE_BLANK + I + Print error + + + C_PE_DASH + E + Print error + + + C_PE_DASH + I + Print error + + + C_PE_DISPLAYED + E + Print error + + + C_PE_DISPLAYED + I + Print error + + + C_PE_NA + E + Print error + + + C_PE_NA + I + Print error + + + DIFF_ODDEVEN_HEADERFOOTER + E + Different Header/Footer for odd/even pages + + + DIFF_ODDEVEN_HEADERFOOTER + I + Different Header/Footer for odd/even pages + + + DRAFT + E + Print without graphics + + + DRAFT + I + Print without graphics + + + ERRORS + E + Specifies how to print cell values for cells with errors + + + ERRORS + I + Specifies how to print cell values for cells with errors + + + EVEN_FOOTER + E + Footer for even pages + + + EVEN_FOOTER + I + Footer for even pages + + + EVEN_HEADER + E + Header for even pages + + + EVEN_HEADER + I + Header for even pages + + + FIRST_PAGE_NUMBER + E + Page number for first printed page + + + FIRST_PAGE_NUMBER + I + Page number for first printed page + + + FIT_TO_HEIGHT + E + Flag indicating whether the Fit to Page print option is enab + + + FIT_TO_HEIGHT + I + Flag indicating whether the Fit to Page print option is enab + + + FIT_TO_PAGE + E + Number of vertical pages to fit on + + + FIT_TO_PAGE + I + Number of vertical pages to fit on + + + FIT_TO_WIDTH + E + Number of horizontal pages to fit on + + + FIT_TO_WIDTH + I + Number of horizontal pages to fit on + + + GET_HEADER_FOOTER_STRING + E + Get processed Header/Footer value strings + + + GET_HEADER_FOOTER_STRING + I + Get processed Header/Footer value strings + + + HORIZONTAL_CENTERED + E + horizontal Centered + + + HORIZONTAL_CENTERED + I + horizontal Centered + + + HORIZONTAL_DPI + E + Horizontal print resolution of the device + + + HORIZONTAL_DPI + I + Horizontal print resolution of the device + + + MARGIN_BOTTOM + E + Margin bottom in inches + + + MARGIN_BOTTOM + I + Margin bottom in inches + + + MARGIN_FOOTER + E + Margin footer in inches + + + MARGIN_FOOTER + I + Margin footer in inches + + + MARGIN_HEADER + E + Margin header in inches + + + MARGIN_HEADER + I + Margin header in inches + + + MARGIN_LEFT + E + Margin left in inches + + + MARGIN_LEFT + I + Margin left in inches + + + MARGIN_RIGHT + E + Margin right in inches + + + MARGIN_RIGHT + I + Margin right in inches + + + MARGIN_TOP + E + Margin top in inches + + + MARGIN_TOP + I + Margin top in inches + + + ODD_FOOTER + E + Footer for all OR odd Pages + + + ODD_FOOTER + I + Footer for all OR odd Pages + + + ODD_HEADER + E + Header for all OR odd Pages + + + ODD_HEADER + I + Header for all OR odd Pages + + + ORIENTATION + E + Sheet orientation + + + ORIENTATION + I + Sheet orientation + + + PAGE_ORDER + E + Order of printed pages + + + PAGE_ORDER + I + Order of printed pages + + + PAPER_HEIGHT + E + Height of custom paper as a number followed by a unit id + + + PAPER_HEIGHT + I + Height of custom paper as a number followed by a unit id + + + PAPER_SIZE + E + Paper size + + + PAPER_SIZE + I + Paper size + + + PAPER_WIDTH + E + Width of custom paper as a number followed by a unit id + + + PAPER_WIDTH + I + Width of custom paper as a number followed by a unit id + + + PROCESS_HEADER_FOOTER + E + Process (formating / editing) Header/Footer + + + PROCESS_HEADER_FOOTER + I + Process (formating / editing) Header/Footer + + + SCALE + E + Scale 10 - 400 (percent) + + + SCALE + I + Scale 10 - 400 (percent) + + + SET_HEADER_FOOTER + E + set page header and footer + + + SET_HEADER_FOOTER + I + set page header and footer + + + SET_PAGE_MARGINS + E + Set page margins + + + SET_PAGE_MARGINS + I + Set page margins + + + USE_FIRST_PAGE_NUM + E + Use firstPageNumber value for first page number + + + USE_FIRST_PAGE_NUM + I + Use firstPageNumber value for first page number + + + USE_PRINTER_DEFAULTS + E + Use the printer’s defaults settings for page setup values + + + USE_PRINTER_DEFAULTS + I + Use the printer’s defaults settings for page setup values + + + VERTICAL_CENTERED + E + vertical Centered + + + VERTICAL_CENTERED + I + vertical Centered + + + VERTICAL_DPI + E + Vertical print resolution of the device + + + VERTICAL_DPI + I + Vertical print resolution of the device + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style.clas.abap b/src/abap2xlsx/ycl_ecb_style.clas.abap new file mode 100644 index 0000000..757d4f8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style.clas.abap @@ -0,0 +1,104 @@ +CLASS ycl_ecb_style DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! + PUBLIC SECTION. + + DATA font TYPE REF TO ycl_ecb_style_font . + DATA fill TYPE REF TO ycl_ecb_style_fill . + DATA borders TYPE REF TO ycl_ecb_style_borders . + DATA alignment TYPE REF TO ycl_ecb_style_alignment . + DATA number_format TYPE REF TO ycl_ecb_style_number_format . + DATA protection TYPE REF TO ycl_ecb_style_protection . + + METHODS constructor + IMPORTING + !ip_guid TYPE yecb_cell_style OPTIONAL + !io_clone_of TYPE REF TO ycl_ecb_style OPTIONAL . + METHODS get_guid + RETURNING + VALUE(ep_guid) TYPE yecb_cell_style . +*"* protected components of class ZABAP_EXCEL_STYLE +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLE +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA guid TYPE yecb_cell_style . +ENDCLASS. + + + +CLASS ycl_ecb_style IMPLEMENTATION. + + + METHOD constructor. + + + CREATE OBJECT font. + CREATE OBJECT fill. + CREATE OBJECT borders. + CREATE OBJECT alignment. + CREATE OBJECT number_format. + CREATE OBJECT protection. + + IF ip_guid IS NOT INITIAL. + me->guid = ip_guid. + ELSE. + me->guid = ycl_ecb_obsolete_func_wrap=>guid_create( ). + ENDIF. + + IF io_clone_of IS BOUND. + + font->bold = io_clone_of->font->bold. + font->color = io_clone_of->font->color. + font->family = io_clone_of->font->family. + font->italic = io_clone_of->font->italic. + font->name = io_clone_of->font->name. + font->scheme = io_clone_of->font->scheme. + font->size = io_clone_of->font->size. + font->strikethrough = io_clone_of->font->strikethrough. + font->underline = io_clone_of->font->underline. + font->underline_mode = io_clone_of->font->underline_mode. + + fill->gradtype = io_clone_of->fill->gradtype. + fill->filltype = io_clone_of->fill->filltype. + fill->rotation = io_clone_of->fill->rotation. + fill->fgcolor = io_clone_of->fill->fgcolor. + fill->bgcolor = io_clone_of->fill->bgcolor. + + borders->allborders = io_clone_of->borders->allborders. + borders->diagonal = io_clone_of->borders->diagonal. + borders->diagonal_mode = io_clone_of->borders->diagonal_mode. + borders->down = io_clone_of->borders->down. + borders->left = io_clone_of->borders->left. + borders->right = io_clone_of->borders->right. + borders->top = io_clone_of->borders->top. + + alignment->horizontal = io_clone_of->alignment->horizontal. + alignment->vertical = io_clone_of->alignment->vertical. + alignment->textrotation = io_clone_of->alignment->textrotation. + alignment->wraptext = io_clone_of->alignment->wraptext. + alignment->shrinktofit = io_clone_of->alignment->shrinktofit. + alignment->indent = io_clone_of->alignment->indent. + + number_format->format_code = io_clone_of->number_format->format_code. + + protection->hidden = io_clone_of->protection->hidden. + protection->locked = io_clone_of->protection->locked. + + ENDIF. + + ENDMETHOD. + + + METHOD get_guid. + + + ep_guid = me->guid. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style.clas.xml b/src/abap2xlsx/ycl_ecb_style.clas.xml new file mode 100644 index 0000000..10b0883 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style.clas.xml @@ -0,0 +1,98 @@ + + + + + + YCL_ECB_STYLE + E + Style + 1 + X + X + X + + + + ALIGNMENT + E + Alignment Style + + + ALIGNMENT + I + Alignment Style + + + BORDERS + E + Border Style + + + BORDERS + I + Border Style + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + FILL + E + Fill Style + + + FILL + I + Fill Style + + + FONT + E + Font Style + + + FONT + I + Font Style + + + GUID + E + Style identifier + + + GUID + I + Style identifier + + + NUMBER_FORMAT + E + Number Format Style + + + NUMBER_FORMAT + I + Number Format Style + + + PROTECTION + E + Protection Style + + + PROTECTION + I + Protection Style + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_alignment.clas.abap b/src/abap2xlsx/ycl_ecb_style_alignment.clas.abap new file mode 100644 index 0000000..1e94e1c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_alignment.clas.abap @@ -0,0 +1,64 @@ +CLASS ycl_ecb_style_alignment DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! + PUBLIC SECTION. + + CONSTANTS c_horizontal_general TYPE yecb_alignment VALUE 'general'. "#EC NOTEXT + CONSTANTS c_horizontal_left TYPE yecb_alignment VALUE 'left'. "#EC NOTEXT + CONSTANTS c_horizontal_right TYPE yecb_alignment VALUE 'right'. "#EC NOTEXT + CONSTANTS c_horizontal_center TYPE yecb_alignment VALUE 'center'. "#EC NOTEXT + CONSTANTS c_horizontal_center_continuous TYPE yecb_alignment VALUE 'centerContinuous'. "#EC NOTEXT + CONSTANTS c_horizontal_justify TYPE yecb_alignment VALUE 'justify'. "#EC NOTEXT + CONSTANTS c_vertical_bottom TYPE yecb_alignment VALUE 'bottom'. "#EC NOTEXT + CONSTANTS c_vertical_top TYPE yecb_alignment VALUE 'top'. "#EC NOTEXT + CONSTANTS c_vertical_center TYPE yecb_alignment VALUE 'center'. "#EC NOTEXT + CONSTANTS c_vertical_justify TYPE yecb_alignment VALUE 'justify'. "#EC NOTEXT + DATA horizontal TYPE yecb_alignment . + DATA vertical TYPE yecb_alignment . + DATA textrotation TYPE yecb_text_rotation VALUE 0. "#EC NOTEXT . . . . . . . . . . " . + DATA wraptext TYPE flag . + DATA shrinktofit TYPE flag . + DATA indent TYPE yecb_indent VALUE 0. "#EC NOTEXT . . . . . . . . . . " . + + METHODS constructor . + METHODS get_structure + RETURNING + VALUE(es_alignment) TYPE yecb_s_style_alignment . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLE_ALIGNMENT +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_style_alignment IMPLEMENTATION. + + + METHOD constructor. + horizontal = me->c_horizontal_general. + vertical = me->c_vertical_bottom. + wraptext = abap_false. + shrinktofit = abap_false. + ENDMETHOD. + + + METHOD get_structure. + + es_alignment-horizontal = me->horizontal. + es_alignment-vertical = me->vertical. + es_alignment-textrotation = me->textrotation. + es_alignment-wraptext = me->wraptext. + es_alignment-shrinktofit = me->shrinktofit. + es_alignment-indent = me->indent. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_alignment.clas.xml b/src/abap2xlsx/ycl_ecb_style_alignment.clas.xml new file mode 100644 index 0000000..5e8637b --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_alignment.clas.xml @@ -0,0 +1,198 @@ + + + + + + YCL_ECB_STYLE_ALIGNMENT + E + Alignment Style + 1 + X + X + X + + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_HORIZONTAL_CENTER + E + Alignment + + + C_HORIZONTAL_CENTER + I + Alignment + + + C_HORIZONTAL_CENTER_CONTINUOUS + E + Alignment + + + C_HORIZONTAL_CENTER_CONTINUOUS + I + Alignment + + + C_HORIZONTAL_GENERAL + E + Alignment + + + C_HORIZONTAL_GENERAL + I + Alignment + + + C_HORIZONTAL_JUSTIFY + E + Alignment + + + C_HORIZONTAL_JUSTIFY + I + Alignment + + + C_HORIZONTAL_LEFT + E + Alignment + + + C_HORIZONTAL_LEFT + I + Alignment + + + C_HORIZONTAL_RIGHT + E + Alignment + + + C_HORIZONTAL_RIGHT + I + Alignment + + + C_VERTICAL_BOTTOM + E + Alignment + + + C_VERTICAL_BOTTOM + I + Alignment + + + C_VERTICAL_CENTER + E + Alignment + + + C_VERTICAL_CENTER + I + Alignment + + + C_VERTICAL_JUSTIFY + E + Alignment + + + C_VERTICAL_JUSTIFY + I + Alignment + + + C_VERTICAL_TOP + E + Alignment + + + C_VERTICAL_TOP + I + Alignment + + + GET_STRUCTURE + E + Get class as a structure + + + GET_STRUCTURE + I + Get class as a structure + + + HORIZONTAL + E + Alignment + + + HORIZONTAL + I + Alignment + + + INDENT + E + Indent + + + INDENT + I + Indent + + + SHRINKTOFIT + E + General Flag + + + SHRINKTOFIT + I + General Flag + + + TEXTROTATION + E + Text Rotation + + + TEXTROTATION + I + Text Rotation + + + VERTICAL + E + Alignment + + + VERTICAL + I + Alignment + + + WRAPTEXT + E + General Flag + + + WRAPTEXT + I + General Flag + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_border.clas.abap b/src/abap2xlsx/ycl_ecb_style_border.clas.abap new file mode 100644 index 0000000..9242e60 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_border.clas.abap @@ -0,0 +1,48 @@ +CLASS ycl_ecb_style_border DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + +*"* public components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! + DATA border_style TYPE yecb_border . + DATA border_color TYPE yecb_s_style_color . + CONSTANTS c_border_none TYPE yecb_border VALUE 'none'. "#EC NOTEXT + CONSTANTS c_border_dashdot TYPE yecb_border VALUE 'dashDot'. "#EC NOTEXT + CONSTANTS c_border_dashdotdot TYPE yecb_border VALUE 'dashDotDot'. "#EC NOTEXT + CONSTANTS c_border_dashed TYPE yecb_border VALUE 'dashed'. "#EC NOTEXT + CONSTANTS c_border_dotted TYPE yecb_border VALUE 'dotted'. "#EC NOTEXT + CONSTANTS c_border_double TYPE yecb_border VALUE 'double'. "#EC NOTEXT + CONSTANTS c_border_hair TYPE yecb_border VALUE 'hair'. "#EC NOTEXT + CONSTANTS c_border_medium TYPE yecb_border VALUE 'medium'. "#EC NOTEXT + CONSTANTS c_border_mediumdashdot TYPE yecb_border VALUE 'mediumDashDot'. "#EC NOTEXT + CONSTANTS c_border_mediumdashdotdot TYPE yecb_border VALUE 'mediumDashDotDot'. "#EC NOTEXT + CONSTANTS c_border_mediumdashed TYPE yecb_border VALUE 'mediumDashed'. "#EC NOTEXT + CONSTANTS c_border_slantdashdot TYPE yecb_border VALUE 'slantDashDot'. "#EC NOTEXT + CONSTANTS c_border_thick TYPE yecb_border VALUE 'thick'. "#EC NOTEXT + CONSTANTS c_border_thin TYPE yecb_border VALUE 'thin'. "#EC NOTEXT + + METHODS constructor . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLE_BORDER +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_style_border IMPLEMENTATION. + + + METHOD constructor. + border_style = ycl_ecb_style_border=>c_border_none. + border_color-theme = ycl_ecb_style_color=>c_theme_not_set. + border_color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_border.clas.xml b/src/abap2xlsx/ycl_ecb_style_border.clas.xml new file mode 100644 index 0000000..b342199 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_border.clas.xml @@ -0,0 +1,188 @@ + + + + + + YCL_ECB_STYLE_BORDER + E + Border + 1 + X + X + X + + + + BORDER_COLOR + E + Color ARGB + + + BORDER_COLOR + I + Color ARGB + + + BORDER_STYLE + E + Border style + + + BORDER_STYLE + I + Border style + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_BORDER_DASHDOT + E + Border style + + + C_BORDER_DASHDOT + I + Border style + + + C_BORDER_DASHDOTDOT + E + Border style + + + C_BORDER_DASHDOTDOT + I + Border style + + + C_BORDER_DASHED + E + Border style + + + C_BORDER_DASHED + I + Border style + + + C_BORDER_DOTTED + E + Border style + + + C_BORDER_DOTTED + I + Border style + + + C_BORDER_DOUBLE + E + Border style + + + C_BORDER_DOUBLE + I + Border style + + + C_BORDER_HAIR + E + Border style + + + C_BORDER_HAIR + I + Border style + + + C_BORDER_MEDIUM + E + Border style + + + C_BORDER_MEDIUM + I + Border style + + + C_BORDER_MEDIUMDASHDOT + E + Border style + + + C_BORDER_MEDIUMDASHDOT + I + Border style + + + C_BORDER_MEDIUMDASHDOTDOT + E + Border style + + + C_BORDER_MEDIUMDASHDOTDOT + I + Border style + + + C_BORDER_MEDIUMDASHED + E + Border style + + + C_BORDER_MEDIUMDASHED + I + Border style + + + C_BORDER_NONE + E + Border style + + + C_BORDER_NONE + I + Border style + + + C_BORDER_SLANTDASHDOT + E + Border style + + + C_BORDER_SLANTDASHDOT + I + Border style + + + C_BORDER_THICK + E + Border style + + + C_BORDER_THICK + I + Border style + + + C_BORDER_THIN + E + Border style + + + C_BORDER_THIN + I + Border style + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_borders.clas.abap b/src/abap2xlsx/ycl_ecb_style_borders.clas.abap new file mode 100644 index 0000000..bac0c34 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_borders.clas.abap @@ -0,0 +1,103 @@ +CLASS ycl_ecb_style_borders DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! + PUBLIC SECTION. + + DATA allborders TYPE REF TO ycl_ecb_style_border . + CONSTANTS c_diagonal_both TYPE yecb_diagonal VALUE 3. "#EC NOTEXT + CONSTANTS c_diagonal_down TYPE yecb_diagonal VALUE 2. "#EC NOTEXT + CONSTANTS c_diagonal_none TYPE yecb_diagonal VALUE 0. "#EC NOTEXT + CONSTANTS c_diagonal_up TYPE yecb_diagonal VALUE 1. "#EC NOTEXT + DATA diagonal TYPE REF TO ycl_ecb_style_border . + DATA diagonal_mode TYPE yecb_diagonal . + DATA down TYPE REF TO ycl_ecb_style_border . + DATA left TYPE REF TO ycl_ecb_style_border . + DATA right TYPE REF TO ycl_ecb_style_border . + DATA top TYPE REF TO ycl_ecb_style_border . + + METHODS get_structure + RETURNING + VALUE(es_fill) TYPE yecb_s_style_border . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLE_BORDERS +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_style_borders IMPLEMENTATION. + + + METHOD get_structure. +*initialize colors to 'not set' + es_fill-left_color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + es_fill-left_color-theme = ycl_ecb_style_color=>c_theme_not_set. + es_fill-right_color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + es_fill-right_color-theme = ycl_ecb_style_color=>c_theme_not_set. + es_fill-top_color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + es_fill-top_color-theme = ycl_ecb_style_color=>c_theme_not_set. + es_fill-bottom_color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + es_fill-bottom_color-theme = ycl_ecb_style_color=>c_theme_not_set. + es_fill-diagonal_color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + es_fill-diagonal_color-theme = ycl_ecb_style_color=>c_theme_not_set. + +* Check if all borders is set otherwise check single border + IF me->allborders IS BOUND. + es_fill-left_color = me->allborders->border_color. + es_fill-left_style = me->allborders->border_style. + es_fill-right_color = me->allborders->border_color. + es_fill-right_style = me->allborders->border_style. + es_fill-top_color = me->allborders->border_color. + es_fill-top_style = me->allborders->border_style. + es_fill-bottom_color = me->allborders->border_color. + es_fill-bottom_style = me->allborders->border_style. + ELSE. + IF me->left IS BOUND. + es_fill-left_color = me->left->border_color. + es_fill-left_style = me->left->border_style. + ENDIF. + IF me->right IS BOUND. + es_fill-right_color = me->right->border_color. + es_fill-right_style = me->right->border_style. + ENDIF. + IF me->top IS BOUND. + es_fill-top_color = me->top->border_color. + es_fill-top_style = me->top->border_style. + ENDIF. + IF me->down IS BOUND. + es_fill-bottom_color = me->down->border_color. + es_fill-bottom_style = me->down->border_style. + ENDIF. + ENDIF. + +* Check if diagonal is set + IF me->diagonal IS BOUND. + es_fill-diagonal_color = me->diagonal->border_color. + es_fill-diagonal_style = me->diagonal->border_style. + CASE me->diagonal_mode. + WHEN 1. + es_fill-diagonalup = 1. + es_fill-diagonaldown = 0. + WHEN 2. + es_fill-diagonalup = 0. + es_fill-diagonaldown = 1. + WHEN 3. + es_fill-diagonalup = 1. + es_fill-diagonaldown = 1. + WHEN OTHERS. + es_fill-diagonalup = 0. + es_fill-diagonaldown = 0. + ENDCASE. + ENDIF. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_borders.clas.xml b/src/abap2xlsx/ycl_ecb_style_borders.clas.xml new file mode 100644 index 0000000..7ce023f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_borders.clas.xml @@ -0,0 +1,138 @@ + + + + + + YCL_ECB_STYLE_BORDERS + E + Border Style + 1 + X + X + X + + + + ALLBORDERS + E + Border + + + ALLBORDERS + I + Border + + + C_DIAGONAL_BOTH + E + Diagonal + + + C_DIAGONAL_BOTH + I + Diagonal + + + C_DIAGONAL_DOWN + E + Diagonal + + + C_DIAGONAL_DOWN + I + Diagonal + + + C_DIAGONAL_NONE + E + Diagonal + + + C_DIAGONAL_NONE + I + Diagonal + + + C_DIAGONAL_UP + E + Diagonal + + + C_DIAGONAL_UP + I + Diagonal + + + DIAGONAL + E + Border + + + DIAGONAL + I + Border + + + DIAGONAL_MODE + E + Diagonal + + + DIAGONAL_MODE + I + Diagonal + + + DOWN + E + Border + + + DOWN + I + Border + + + GET_STRUCTURE + E + Get structure + + + GET_STRUCTURE + I + Get structure + + + LEFT + E + Border + + + LEFT + I + Border + + + RIGHT + E + Border + + + RIGHT + I + Border + + + TOP + E + Border + + + TOP + I + Border + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_changer.clas.abap b/src/abap2xlsx/ycl_ecb_style_changer.clas.abap new file mode 100644 index 0000000..110ebdc --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_changer.clas.abap @@ -0,0 +1,1672 @@ +CLASS ycl_ecb_style_changer DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + INTERFACES yif_ecb_style_changer. + + CLASS-METHODS create + IMPORTING + excel TYPE REF TO ycl_ecb + RETURNING + VALUE(result) TYPE REF TO yif_ecb_style_changer + RAISING + ycx_ecb. + + PROTECTED SECTION. + PRIVATE SECTION. + + METHODS clear_initial_colorxfields + IMPORTING + is_color TYPE yecb_s_style_color + CHANGING + cs_xcolor TYPE yecb_s_cstylex_color. + + METHODS move_supplied_borders + IMPORTING + iv_border_supplied TYPE abap_bool + is_border TYPE yecb_s_cstyle_border + iv_xborder_supplied TYPE abap_bool + is_xborder TYPE yecb_s_cstylex_border + CHANGING + cs_complete_style_border TYPE yecb_s_cstyle_border + cs_complete_stylex_border TYPE yecb_s_cstylex_border. + + DATA: excel TYPE REF TO ycl_ecb, + lv_xborder_supplied TYPE abap_bool, + single_change_requested TYPE yecb_s_cstylex_complete, + BEGIN OF multiple_change_requested, + complete TYPE abap_bool, + font TYPE abap_bool, + fill TYPE abap_bool, + BEGIN OF borders, + complete TYPE abap_bool, + allborders TYPE abap_bool, + diagonal TYPE abap_bool, + down TYPE abap_bool, + left TYPE abap_bool, + right TYPE abap_bool, + top TYPE abap_bool, + END OF borders, + alignment TYPE abap_bool, + protection TYPE abap_bool, + END OF multiple_change_requested. + CONSTANTS: + lv_border_supplied TYPE abap_bool VALUE abap_true. + ALIASES: + complete_style FOR yif_ecb_style_changer~complete_style, + complete_stylex FOR yif_ecb_style_changer~complete_stylex. + +ENDCLASS. + + + +CLASS ycl_ecb_style_changer IMPLEMENTATION. + + + METHOD clear_initial_colorxfields. + + IF is_color-rgb IS INITIAL. + CLEAR cs_xcolor-rgb. + ENDIF. + IF is_color-indexed IS INITIAL. + CLEAR cs_xcolor-indexed. + ENDIF. + IF is_color-theme IS INITIAL. + CLEAR cs_xcolor-theme. + ENDIF. + IF is_color-tint IS INITIAL. + CLEAR cs_xcolor-tint. + ENDIF. + + ENDMETHOD. + + + METHOD create. + + DATA: style TYPE REF TO ycl_ecb_style_changer. + + CREATE OBJECT style. + style->excel = excel. + result = style. + + ENDMETHOD. + + + METHOD move_supplied_borders. + + DATA: cs_borderx TYPE yecb_s_cstylex_border. + + IF iv_border_supplied = abap_true. " only act if parameter was supplied + IF iv_xborder_supplied = abap_true. " + cs_borderx = is_xborder. " use supplied x-parameter + ELSE. + CLEAR cs_borderx WITH 'X'. " <============================== DDIC structure enh. category to set? + " clear in a way that would be expected to work easily + IF is_border-border_style IS INITIAL. + CLEAR cs_borderx-border_style. + ENDIF. + clear_initial_colorxfields( + EXPORTING + is_color = is_border-border_color + CHANGING + cs_xcolor = cs_borderx-border_color ). + ENDIF. + cs_complete_style_border = is_border. + cs_complete_stylex_border = cs_borderx. + ENDIF. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~apply. + + DATA: stylemapping TYPE yecb_s_stylemapping, + lo_worksheet TYPE REF TO ycl_ecb_worksheet, + l_guid TYPE yecb_cell_style. + + lo_worksheet = excel->get_worksheet_by_name( ip_sheet_name = ip_worksheet->get_title( ) ). + IF lo_worksheet <> ip_worksheet. + ycx_ecb=>raise_text( 'Worksheet doesn''t correspond to workbook of style changer'(001) ). + ENDIF. + + TRY. + ip_worksheet->get_cell( EXPORTING ip_column = ip_column + ip_row = ip_row + IMPORTING ep_guid = l_guid ). + stylemapping = excel->get_style_to_guid( l_guid ). + CATCH ycx_ecb. +* Error --> use submitted style + ENDTRY. + + + IF multiple_change_requested-complete = abap_true. + stylemapping-complete_style = complete_style. + stylemapping-complete_stylex = complete_stylex. + ENDIF. + + IF multiple_change_requested-font = abap_true. + stylemapping-complete_style-font = complete_style-font. + stylemapping-complete_stylex-font = complete_stylex-font. + ENDIF. + + IF multiple_change_requested-fill = abap_true. + stylemapping-complete_style-fill = complete_style-fill. + stylemapping-complete_stylex-fill = complete_stylex-fill. + ENDIF. + + IF multiple_change_requested-borders-complete = abap_true. + stylemapping-complete_style-borders = complete_style-borders. + stylemapping-complete_stylex-borders = complete_stylex-borders. + ENDIF. + + IF multiple_change_requested-borders-allborders = abap_true. + stylemapping-complete_style-borders-allborders = complete_style-borders-allborders. + stylemapping-complete_stylex-borders-allborders = complete_stylex-borders-allborders. + ENDIF. + + IF multiple_change_requested-borders-diagonal = abap_true. + stylemapping-complete_style-borders-diagonal = complete_style-borders-diagonal. + stylemapping-complete_stylex-borders-diagonal = complete_stylex-borders-diagonal. + ENDIF. + + IF multiple_change_requested-borders-down = abap_true. + stylemapping-complete_style-borders-down = complete_style-borders-down. + stylemapping-complete_stylex-borders-down = complete_stylex-borders-down. + ENDIF. + + IF multiple_change_requested-borders-left = abap_true. + stylemapping-complete_style-borders-left = complete_style-borders-left. + stylemapping-complete_stylex-borders-left = complete_stylex-borders-left. + ENDIF. + + IF multiple_change_requested-borders-right = abap_true. + stylemapping-complete_style-borders-right = complete_style-borders-right. + stylemapping-complete_stylex-borders-right = complete_stylex-borders-right. + ENDIF. + + IF multiple_change_requested-borders-top = abap_true. + stylemapping-complete_style-borders-top = complete_style-borders-top. + stylemapping-complete_stylex-borders-top = complete_stylex-borders-top. + ENDIF. + + IF multiple_change_requested-alignment = abap_true. + stylemapping-complete_style-alignment = complete_style-alignment. + stylemapping-complete_stylex-alignment = complete_stylex-alignment. + ENDIF. + + IF multiple_change_requested-protection = abap_true. + stylemapping-complete_style-protection = complete_style-protection. + stylemapping-complete_stylex-protection = complete_stylex-protection. + ENDIF. + + IF complete_stylex-number_format = abap_true. + stylemapping-complete_style-number_format-format_code = complete_style-number_format-format_code. + stylemapping-complete_stylex-number_format-format_code = abap_true. + ENDIF. + IF complete_stylex-font-bold = abap_true. + stylemapping-complete_style-font-bold = complete_style-font-bold. + stylemapping-complete_stylex-font-bold = complete_stylex-font-bold. + ENDIF. + IF complete_stylex-font-color = abap_true. + stylemapping-complete_style-font-color = complete_style-font-color. + stylemapping-complete_stylex-font-color = complete_stylex-font-color. + ENDIF. + IF complete_stylex-font-color-rgb = abap_true. + stylemapping-complete_style-font-color-rgb = complete_style-font-color-rgb. + stylemapping-complete_stylex-font-color-rgb = complete_stylex-font-color-rgb. + ENDIF. + IF complete_stylex-font-color-indexed = abap_true. + stylemapping-complete_style-font-color-indexed = complete_style-font-color-indexed. + stylemapping-complete_stylex-font-color-indexed = complete_stylex-font-color-indexed. + ENDIF. + IF complete_stylex-font-color-theme = abap_true. + stylemapping-complete_style-font-color-theme = complete_style-font-color-theme. + stylemapping-complete_stylex-font-color-theme = complete_stylex-font-color-theme. + ENDIF. + IF complete_stylex-font-color-tint = abap_true. + stylemapping-complete_style-font-color-tint = complete_style-font-color-tint. + stylemapping-complete_stylex-font-color-tint = complete_stylex-font-color-tint. + ENDIF. + IF complete_stylex-font-family = abap_true. + stylemapping-complete_style-font-family = complete_style-font-family. + stylemapping-complete_stylex-font-family = complete_stylex-font-family. + ENDIF. + IF complete_stylex-font-italic = abap_true. + stylemapping-complete_style-font-italic = complete_style-font-italic. + stylemapping-complete_stylex-font-italic = complete_stylex-font-italic. + ENDIF. + IF complete_stylex-font-name = abap_true. + stylemapping-complete_style-font-name = complete_style-font-name. + stylemapping-complete_stylex-font-name = complete_stylex-font-name. + ENDIF. + IF complete_stylex-font-scheme = abap_true. + stylemapping-complete_style-font-scheme = complete_style-font-scheme. + stylemapping-complete_stylex-font-scheme = complete_stylex-font-scheme. + ENDIF. + IF complete_stylex-font-size = abap_true. + stylemapping-complete_style-font-size = complete_style-font-size. + stylemapping-complete_stylex-font-size = complete_stylex-font-size. + ENDIF. + IF complete_stylex-font-strikethrough = abap_true. + stylemapping-complete_style-font-strikethrough = complete_style-font-strikethrough. + stylemapping-complete_stylex-font-strikethrough = complete_stylex-font-strikethrough. + ENDIF. + IF complete_stylex-font-underline = abap_true. + stylemapping-complete_style-font-underline = complete_style-font-underline. + stylemapping-complete_stylex-font-underline = complete_stylex-font-underline. + ENDIF. + IF complete_stylex-font-underline_mode = abap_true. + stylemapping-complete_style-font-underline_mode = complete_style-font-underline_mode. + stylemapping-complete_stylex-font-underline_mode = complete_stylex-font-underline_mode. + ENDIF. + + IF complete_stylex-fill-filltype = abap_true. + stylemapping-complete_style-fill-filltype = complete_style-fill-filltype. + stylemapping-complete_stylex-fill-filltype = complete_stylex-fill-filltype. + ENDIF. + IF complete_stylex-fill-rotation = abap_true. + stylemapping-complete_style-fill-rotation = complete_style-fill-rotation. + stylemapping-complete_stylex-fill-rotation = complete_stylex-fill-rotation. + ENDIF. + IF complete_stylex-fill-fgcolor = abap_true. + stylemapping-complete_style-fill-fgcolor = complete_style-fill-fgcolor. + stylemapping-complete_stylex-fill-fgcolor = complete_stylex-fill-fgcolor. + ENDIF. + IF complete_stylex-fill-fgcolor-rgb = abap_true. + stylemapping-complete_style-fill-fgcolor-rgb = complete_style-fill-fgcolor-rgb. + stylemapping-complete_stylex-fill-fgcolor-rgb = complete_stylex-fill-fgcolor-rgb. + ENDIF. + IF complete_stylex-fill-fgcolor-indexed = abap_true. + stylemapping-complete_style-fill-fgcolor-indexed = complete_style-fill-fgcolor-indexed. + stylemapping-complete_stylex-fill-fgcolor-indexed = complete_stylex-fill-fgcolor-indexed. + ENDIF. + IF complete_stylex-fill-fgcolor-theme = abap_true. + stylemapping-complete_style-fill-fgcolor-theme = complete_style-fill-fgcolor-theme. + stylemapping-complete_stylex-fill-fgcolor-theme = complete_stylex-fill-fgcolor-theme. + ENDIF. + IF complete_stylex-fill-fgcolor-tint = abap_true. + stylemapping-complete_style-fill-fgcolor-tint = complete_style-fill-fgcolor-tint. + stylemapping-complete_stylex-fill-fgcolor-tint = complete_stylex-fill-fgcolor-tint. + ENDIF. + + IF complete_stylex-fill-bgcolor = abap_true. + stylemapping-complete_style-fill-bgcolor = complete_style-fill-bgcolor. + stylemapping-complete_stylex-fill-bgcolor = complete_stylex-fill-bgcolor. + ENDIF. + IF complete_stylex-fill-bgcolor-rgb = abap_true. + stylemapping-complete_style-fill-bgcolor-rgb = complete_style-fill-bgcolor-rgb. + stylemapping-complete_stylex-fill-bgcolor-rgb = complete_stylex-fill-bgcolor-rgb. + ENDIF. + IF complete_stylex-fill-bgcolor-indexed = abap_true. + stylemapping-complete_style-fill-bgcolor-indexed = complete_style-fill-bgcolor-indexed. + stylemapping-complete_stylex-fill-bgcolor-indexed = complete_stylex-fill-bgcolor-indexed. + ENDIF. + IF complete_stylex-fill-bgcolor-theme = abap_true. + stylemapping-complete_style-fill-bgcolor-theme = complete_style-fill-bgcolor-theme. + stylemapping-complete_stylex-fill-bgcolor-theme = complete_stylex-fill-bgcolor-theme. + ENDIF. + IF complete_stylex-fill-bgcolor-tint = abap_true. + stylemapping-complete_style-fill-bgcolor-tint = complete_style-fill-bgcolor-tint. + stylemapping-complete_stylex-fill-bgcolor-tint = complete_stylex-fill-bgcolor-tint. + ENDIF. + + IF complete_stylex-fill-gradtype-type = abap_true. + stylemapping-complete_style-fill-gradtype-type = complete_style-fill-gradtype-type. + stylemapping-complete_stylex-fill-gradtype-type = complete_stylex-fill-gradtype-type. + ENDIF. + IF complete_stylex-fill-gradtype-degree = abap_true. + stylemapping-complete_style-fill-gradtype-degree = complete_style-fill-gradtype-degree. + stylemapping-complete_stylex-fill-gradtype-degree = complete_stylex-fill-gradtype-degree. + ENDIF. + IF complete_stylex-fill-gradtype-bottom = abap_true. + stylemapping-complete_style-fill-gradtype-bottom = complete_style-fill-gradtype-bottom. + stylemapping-complete_stylex-fill-gradtype-bottom = complete_stylex-fill-gradtype-bottom. + ENDIF. + IF complete_stylex-fill-gradtype-left = abap_true. + stylemapping-complete_style-fill-gradtype-left = complete_style-fill-gradtype-left. + stylemapping-complete_stylex-fill-gradtype-left = complete_stylex-fill-gradtype-left. + ENDIF. + IF complete_stylex-fill-gradtype-top = abap_true. + stylemapping-complete_style-fill-gradtype-top = complete_style-fill-gradtype-top. + stylemapping-complete_stylex-fill-gradtype-top = complete_stylex-fill-gradtype-top. + ENDIF. + IF complete_stylex-fill-gradtype-right = abap_true. + stylemapping-complete_style-fill-gradtype-right = complete_style-fill-gradtype-right. + stylemapping-complete_stylex-fill-gradtype-right = complete_stylex-fill-gradtype-right. + ENDIF. + IF complete_stylex-fill-gradtype-position1 = abap_true. + stylemapping-complete_style-fill-gradtype-position1 = complete_style-fill-gradtype-position1. + stylemapping-complete_stylex-fill-gradtype-position1 = complete_stylex-fill-gradtype-position1. + ENDIF. + IF complete_stylex-fill-gradtype-position2 = abap_true. + stylemapping-complete_style-fill-gradtype-position2 = complete_style-fill-gradtype-position2. + stylemapping-complete_stylex-fill-gradtype-position2 = complete_stylex-fill-gradtype-position2. + ENDIF. + IF complete_stylex-fill-gradtype-position3 = abap_true. + stylemapping-complete_style-fill-gradtype-position3 = complete_style-fill-gradtype-position3. + stylemapping-complete_stylex-fill-gradtype-position3 = complete_stylex-fill-gradtype-position3. + ENDIF. + + + + IF complete_stylex-borders-diagonal_mode = abap_true. + stylemapping-complete_style-borders-diagonal_mode = complete_style-borders-diagonal_mode. + stylemapping-complete_stylex-borders-diagonal_mode = complete_stylex-borders-diagonal_mode. + ENDIF. + IF complete_stylex-alignment-horizontal = abap_true. + stylemapping-complete_style-alignment-horizontal = complete_style-alignment-horizontal. + stylemapping-complete_stylex-alignment-horizontal = complete_stylex-alignment-horizontal. + ENDIF. + IF complete_stylex-alignment-vertical = abap_true. + stylemapping-complete_style-alignment-vertical = complete_style-alignment-vertical. + stylemapping-complete_stylex-alignment-vertical = complete_stylex-alignment-vertical. + ENDIF. + IF complete_stylex-alignment-textrotation = abap_true. + stylemapping-complete_style-alignment-textrotation = complete_style-alignment-textrotation. + stylemapping-complete_stylex-alignment-textrotation = complete_stylex-alignment-textrotation. + ENDIF. + IF complete_stylex-alignment-wraptext = abap_true. + stylemapping-complete_style-alignment-wraptext = complete_style-alignment-wraptext. + stylemapping-complete_stylex-alignment-wraptext = complete_stylex-alignment-wraptext. + ENDIF. + IF complete_stylex-alignment-shrinktofit = abap_true. + stylemapping-complete_style-alignment-shrinktofit = complete_style-alignment-shrinktofit. + stylemapping-complete_stylex-alignment-shrinktofit = complete_stylex-alignment-shrinktofit. + ENDIF. + IF complete_stylex-alignment-indent = abap_true. + stylemapping-complete_style-alignment-indent = complete_style-alignment-indent. + stylemapping-complete_stylex-alignment-indent = complete_stylex-alignment-indent. + ENDIF. + IF complete_stylex-protection-hidden = abap_true. + stylemapping-complete_style-protection-hidden = complete_style-protection-hidden. + stylemapping-complete_stylex-protection-hidden = complete_stylex-protection-hidden. + ENDIF. + IF complete_stylex-protection-locked = abap_true. + stylemapping-complete_style-protection-locked = complete_style-protection-locked. + stylemapping-complete_stylex-protection-locked = complete_stylex-protection-locked. + ENDIF. + + IF complete_stylex-borders-allborders-border_style = abap_true. + stylemapping-complete_style-borders-allborders-border_style = complete_style-borders-allborders-border_style. + stylemapping-complete_stylex-borders-allborders-border_style = complete_stylex-borders-allborders-border_style. + ENDIF. + IF complete_stylex-borders-allborders-border_color-rgb = abap_true. + stylemapping-complete_style-borders-allborders-border_color-rgb = complete_style-borders-allborders-border_color-rgb. + stylemapping-complete_stylex-borders-allborders-border_color-rgb = complete_stylex-borders-allborders-border_color-rgb. + ENDIF. + IF complete_stylex-borders-allborders-border_color-indexed = abap_true. + stylemapping-complete_style-borders-allborders-border_color-indexed = complete_style-borders-allborders-border_color-indexed. + stylemapping-complete_stylex-borders-allborders-border_color-indexed = complete_stylex-borders-allborders-border_color-indexed. + ENDIF. + IF complete_stylex-borders-allborders-border_color-theme = abap_true. + stylemapping-complete_style-borders-allborders-border_color-theme = complete_style-borders-allborders-border_color-theme. + stylemapping-complete_stylex-borders-allborders-border_color-theme = complete_stylex-borders-allborders-border_color-theme. + ENDIF. + IF complete_stylex-borders-allborders-border_color-tint = abap_true. + stylemapping-complete_style-borders-allborders-border_color-tint = complete_style-borders-allborders-border_color-tint. + stylemapping-complete_stylex-borders-allborders-border_color-tint = complete_stylex-borders-allborders-border_color-tint. + ENDIF. + + IF complete_stylex-borders-diagonal-border_style = abap_true. + stylemapping-complete_style-borders-diagonal-border_style = complete_style-borders-diagonal-border_style. + stylemapping-complete_stylex-borders-diagonal-border_style = complete_stylex-borders-diagonal-border_style. + ENDIF. + IF complete_stylex-borders-diagonal-border_color-rgb = abap_true. + stylemapping-complete_style-borders-diagonal-border_color-rgb = complete_style-borders-diagonal-border_color-rgb. + stylemapping-complete_stylex-borders-diagonal-border_color-rgb = complete_stylex-borders-diagonal-border_color-rgb. + ENDIF. + IF complete_stylex-borders-diagonal-border_color-indexed = abap_true. + stylemapping-complete_style-borders-diagonal-border_color-indexed = complete_style-borders-diagonal-border_color-indexed. + stylemapping-complete_stylex-borders-diagonal-border_color-indexed = complete_stylex-borders-diagonal-border_color-indexed. + ENDIF. + IF complete_stylex-borders-diagonal-border_color-theme = abap_true. + stylemapping-complete_style-borders-diagonal-border_color-theme = complete_style-borders-diagonal-border_color-theme. + stylemapping-complete_stylex-borders-diagonal-border_color-theme = complete_stylex-borders-diagonal-border_color-theme. + ENDIF. + IF complete_stylex-borders-diagonal-border_color-tint = abap_true. + stylemapping-complete_style-borders-diagonal-border_color-tint = complete_style-borders-diagonal-border_color-tint. + stylemapping-complete_stylex-borders-diagonal-border_color-tint = complete_stylex-borders-diagonal-border_color-tint. + ENDIF. + + IF complete_stylex-borders-down-border_style = abap_true. + stylemapping-complete_style-borders-down-border_style = complete_style-borders-down-border_style. + stylemapping-complete_stylex-borders-down-border_style = complete_stylex-borders-down-border_style. + ENDIF. + IF complete_stylex-borders-down-border_color-rgb = abap_true. + stylemapping-complete_style-borders-down-border_color-rgb = complete_style-borders-down-border_color-rgb. + stylemapping-complete_stylex-borders-down-border_color-rgb = complete_stylex-borders-down-border_color-rgb. + ENDIF. + IF complete_stylex-borders-down-border_color-indexed = abap_true. + stylemapping-complete_style-borders-down-border_color-indexed = complete_style-borders-down-border_color-indexed. + stylemapping-complete_stylex-borders-down-border_color-indexed = complete_stylex-borders-down-border_color-indexed. + ENDIF. + IF complete_stylex-borders-down-border_color-theme = abap_true. + stylemapping-complete_style-borders-down-border_color-theme = complete_style-borders-down-border_color-theme. + stylemapping-complete_stylex-borders-down-border_color-theme = complete_stylex-borders-down-border_color-theme. + ENDIF. + IF complete_stylex-borders-down-border_color-tint = abap_true. + stylemapping-complete_style-borders-down-border_color-tint = complete_style-borders-down-border_color-tint. + stylemapping-complete_stylex-borders-down-border_color-tint = complete_stylex-borders-down-border_color-tint. + ENDIF. + + IF complete_stylex-borders-left-border_style = abap_true. + stylemapping-complete_style-borders-left-border_style = complete_style-borders-left-border_style. + stylemapping-complete_stylex-borders-left-border_style = complete_stylex-borders-left-border_style. + ENDIF. + IF complete_stylex-borders-left-border_color-rgb = abap_true. + stylemapping-complete_style-borders-left-border_color-rgb = complete_style-borders-left-border_color-rgb. + stylemapping-complete_stylex-borders-left-border_color-rgb = complete_stylex-borders-left-border_color-rgb. + ENDIF. + IF complete_stylex-borders-left-border_color-indexed = abap_true. + stylemapping-complete_style-borders-left-border_color-indexed = complete_style-borders-left-border_color-indexed. + stylemapping-complete_stylex-borders-left-border_color-indexed = complete_stylex-borders-left-border_color-indexed. + ENDIF. + IF complete_stylex-borders-left-border_color-theme = abap_true. + stylemapping-complete_style-borders-left-border_color-theme = complete_style-borders-left-border_color-theme. + stylemapping-complete_stylex-borders-left-border_color-theme = complete_stylex-borders-left-border_color-theme. + ENDIF. + IF complete_stylex-borders-left-border_color-tint = abap_true. + stylemapping-complete_style-borders-left-border_color-tint = complete_style-borders-left-border_color-tint. + stylemapping-complete_stylex-borders-left-border_color-tint = complete_stylex-borders-left-border_color-tint. + ENDIF. + + IF complete_stylex-borders-right-border_style = abap_true. + stylemapping-complete_style-borders-right-border_style = complete_style-borders-right-border_style. + stylemapping-complete_stylex-borders-right-border_style = complete_stylex-borders-right-border_style. + ENDIF. + IF complete_stylex-borders-right-border_color-rgb = abap_true. + stylemapping-complete_style-borders-right-border_color-rgb = complete_style-borders-right-border_color-rgb. + stylemapping-complete_stylex-borders-right-border_color-rgb = complete_stylex-borders-right-border_color-rgb. + ENDIF. + IF complete_stylex-borders-right-border_color-indexed = abap_true. + stylemapping-complete_style-borders-right-border_color-indexed = complete_style-borders-right-border_color-indexed. + stylemapping-complete_stylex-borders-right-border_color-indexed = complete_stylex-borders-right-border_color-indexed. + ENDIF. + IF complete_stylex-borders-right-border_color-theme = abap_true. + stylemapping-complete_style-borders-right-border_color-theme = complete_style-borders-right-border_color-theme. + stylemapping-complete_stylex-borders-right-border_color-theme = complete_stylex-borders-right-border_color-theme. + ENDIF. + IF complete_stylex-borders-right-border_color-tint = abap_true. + stylemapping-complete_style-borders-right-border_color-tint = complete_style-borders-right-border_color-tint. + stylemapping-complete_stylex-borders-right-border_color-tint = complete_stylex-borders-right-border_color-tint. + ENDIF. + + IF complete_stylex-borders-top-border_style = abap_true. + stylemapping-complete_style-borders-top-border_style = complete_style-borders-top-border_style. + stylemapping-complete_stylex-borders-top-border_style = complete_stylex-borders-top-border_style. + ENDIF. + IF complete_stylex-borders-top-border_color-rgb = abap_true. + stylemapping-complete_style-borders-top-border_color-rgb = complete_style-borders-top-border_color-rgb. + stylemapping-complete_stylex-borders-top-border_color-rgb = complete_stylex-borders-top-border_color-rgb. + ENDIF. + IF complete_stylex-borders-top-border_color-indexed = abap_true. + stylemapping-complete_style-borders-top-border_color-indexed = complete_style-borders-top-border_color-indexed. + stylemapping-complete_stylex-borders-top-border_color-indexed = complete_stylex-borders-top-border_color-indexed. + ENDIF. + IF complete_stylex-borders-top-border_color-theme = abap_true. + stylemapping-complete_style-borders-top-border_color-theme = complete_style-borders-top-border_color-theme. + stylemapping-complete_stylex-borders-top-border_color-theme = complete_stylex-borders-top-border_color-theme. + ENDIF. + IF complete_stylex-borders-top-border_color-tint = abap_true. + stylemapping-complete_style-borders-top-border_color-tint = complete_style-borders-top-border_color-tint. + stylemapping-complete_stylex-borders-top-border_color-tint = complete_stylex-borders-top-border_color-tint. + ENDIF. + + +* Now we have a completly filled styles. +* This can be used to get the guid +* Return guid if requested. Might be used if copy&paste of styles is requested + ep_guid = me->excel->get_static_cellstyle_guid( ip_cstyle_complete = stylemapping-complete_style + ip_cstylex_complete = stylemapping-complete_stylex ). + lo_worksheet->set_cell_style( ip_column = ip_column + ip_row = ip_row + ip_style = ep_guid ). + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~get_guid. + + result = excel->get_static_cellstyle_guid( ip_cstyle_complete = complete_style + ip_cstylex_complete = complete_stylex ). + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_alignment_horizontal. + + complete_style-alignment-horizontal = value. + complete_stylex-alignment-horizontal = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_alignment_indent. + + complete_style-alignment-indent = value. + complete_stylex-alignment-indent = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_alignment_shrinktofit. + + complete_style-alignment-shrinktofit = value. + complete_stylex-alignment-shrinktofit = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_alignment_textrotation. + + complete_style-alignment-textrotation = value. + complete_stylex-alignment-textrotation = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_alignment_vertical. + + complete_style-alignment-vertical = value. + complete_stylex-alignment-vertical = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_alignment_wraptext. + + complete_style-alignment-wraptext = value. + complete_stylex-alignment-wraptext = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_allborders_color. + + complete_style-borders-allborders-border_color = value. + complete_stylex-borders-allborders-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_allborders_style. + + complete_style-borders-allborders-border_style = value. + complete_stylex-borders-allborders-border_style = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_allbo_color_indexe. + + complete_style-borders-allborders-border_color-indexed = value. + complete_stylex-borders-allborders-border_color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_allbo_color_rgb. + + complete_style-borders-allborders-border_color-rgb = value. + complete_stylex-borders-allborders-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_allbo_color_theme. + + complete_style-borders-allborders-border_color-theme = value. + complete_stylex-borders-allborders-border_color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_allbo_color_tint. + + complete_style-borders-allborders-border_color-tint = value. + complete_stylex-borders-allborders-border_color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_color. + + complete_style-borders-diagonal-border_color = value. + complete_stylex-borders-diagonal-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_color_ind. + + complete_style-borders-diagonal-border_color-indexed = value. + complete_stylex-borders-diagonal-border_color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_color_rgb. + + complete_style-borders-diagonal-border_color-rgb = value. + complete_stylex-borders-diagonal-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_color_the. + + complete_style-borders-diagonal-border_color-theme = value. + complete_stylex-borders-diagonal-border_color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_color_tin. + + complete_style-borders-diagonal-border_color-tint = value. + complete_stylex-borders-diagonal-border_color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_mode. + + complete_style-borders-diagonal_mode = value. + complete_stylex-borders-diagonal_mode = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_diagonal_style. + + complete_style-borders-diagonal-border_style = value. + complete_stylex-borders-diagonal-border_style = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_down_color. + + complete_style-borders-down-border_color = value. + complete_stylex-borders-down-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_down_color_indexed. + + complete_style-borders-down-border_color-indexed = value. + complete_stylex-borders-down-border_color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_down_color_rgb. + + complete_style-borders-down-border_color-rgb = value. + complete_stylex-borders-down-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_down_color_theme. + + complete_style-borders-down-border_color-theme = value. + complete_stylex-borders-down-border_color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_down_color_tint. + + complete_style-borders-down-border_color-tint = value. + complete_stylex-borders-down-border_color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_down_style. + + complete_style-borders-down-border_style = value. + complete_stylex-borders-down-border_style = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_left_color. + + complete_style-borders-left-border_color = value. + complete_stylex-borders-left-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_left_color_indexed. + + complete_style-borders-left-border_color-indexed = value. + complete_stylex-borders-left-border_color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_left_color_rgb. + + complete_style-borders-left-border_color-rgb = value. + complete_stylex-borders-left-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_left_color_theme. + + complete_style-borders-left-border_color-theme = value. + complete_stylex-borders-left-border_color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_left_color_tint. + + complete_style-borders-left-border_color-tint = value. + complete_stylex-borders-left-border_color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_left_style. + + complete_style-borders-left-border_style = value. + complete_stylex-borders-left-border_style = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_right_color. + + complete_style-borders-right-border_color = value. + complete_stylex-borders-right-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_right_color_indexe. + + complete_style-borders-right-border_color-indexed = value. + complete_stylex-borders-right-border_color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_right_color_rgb. + + complete_style-borders-right-border_color-rgb = value. + complete_stylex-borders-right-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_right_color_theme. + + complete_style-borders-right-border_color-theme = value. + complete_stylex-borders-right-border_color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_right_color_tint. + + complete_style-borders-right-border_color-tint = value. + complete_stylex-borders-right-border_color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_right_style. + + complete_style-borders-right-border_style = value. + complete_stylex-borders-right-border_style = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_top_color. + + complete_style-borders-top-border_color = value. + complete_stylex-borders-top-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_top_color_indexed. + + complete_style-borders-top-border_color-indexed = value. + complete_stylex-borders-top-border_color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_top_color_rgb. + + complete_style-borders-top-border_color-rgb = value. + complete_stylex-borders-top-border_color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_top_color_theme. + + complete_style-borders-top-border_color-theme = value. + complete_stylex-borders-top-border_color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_top_color_tint. + + complete_style-borders-top-border_color-tint = value. + complete_stylex-borders-top-border_color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_borders_top_style. + + complete_style-borders-top-border_style = value. + complete_stylex-borders-top-border_style = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete. + + complete_style = ip_complete. + complete_stylex = ip_xcomplete. + multiple_change_requested-complete = abap_true. + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_alignment. + + DATA: alignmentx LIKE ip_xalignment. + + IF ip_xalignment IS SUPPLIED. + alignmentx = ip_xalignment. + ELSE. + CLEAR alignmentx WITH 'X'. + IF ip_alignment-horizontal IS INITIAL. + CLEAR alignmentx-horizontal. + ENDIF. + IF ip_alignment-vertical IS INITIAL. + CLEAR alignmentx-vertical. + ENDIF. + ENDIF. + + complete_style-alignment = ip_alignment . + complete_stylex-alignment = alignmentx . + multiple_change_requested-alignment = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders. + + DATA: bordersx LIKE ip_xborders. + IF ip_xborders IS SUPPLIED. + bordersx = ip_xborders. + ELSE. + CLEAR bordersx WITH 'X'. + IF ip_borders-allborders-border_style IS INITIAL. + CLEAR bordersx-allborders-border_style. + ENDIF. + IF ip_borders-diagonal-border_style IS INITIAL. + CLEAR bordersx-diagonal-border_style. + ENDIF. + IF ip_borders-down-border_style IS INITIAL. + CLEAR bordersx-down-border_style. + ENDIF. + IF ip_borders-left-border_style IS INITIAL. + CLEAR bordersx-left-border_style. + ENDIF. + IF ip_borders-right-border_style IS INITIAL. + CLEAR bordersx-right-border_style. + ENDIF. + IF ip_borders-top-border_style IS INITIAL. + CLEAR bordersx-top-border_style. + ENDIF. + + clear_initial_colorxfields( + EXPORTING + is_color = ip_borders-allborders-border_color + CHANGING + cs_xcolor = bordersx-allborders-border_color ). + + clear_initial_colorxfields( + EXPORTING + is_color = ip_borders-diagonal-border_color + CHANGING + cs_xcolor = bordersx-diagonal-border_color ). + + clear_initial_colorxfields( + EXPORTING + is_color = ip_borders-down-border_color + CHANGING + cs_xcolor = bordersx-down-border_color ). + + clear_initial_colorxfields( + EXPORTING + is_color = ip_borders-left-border_color + CHANGING + cs_xcolor = bordersx-left-border_color ). + + clear_initial_colorxfields( + EXPORTING + is_color = ip_borders-right-border_color + CHANGING + cs_xcolor = bordersx-right-border_color ). + + clear_initial_colorxfields( + EXPORTING + is_color = ip_borders-top-border_color + CHANGING + cs_xcolor = bordersx-top-border_color ). + + ENDIF. + + complete_style-borders = ip_borders. + complete_stylex-borders = bordersx. + multiple_change_requested-borders-complete = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders_all. + + lv_xborder_supplied = boolc( ip_xborders_allborders IS SUPPLIED ). + move_supplied_borders( + EXPORTING + iv_border_supplied = lv_border_supplied + is_border = ip_borders_allborders + iv_xborder_supplied = lv_xborder_supplied + is_xborder = ip_xborders_allborders + CHANGING + cs_complete_style_border = complete_style-borders-allborders + cs_complete_stylex_border = complete_stylex-borders-allborders ). + multiple_change_requested-borders-allborders = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders_diagonal. + + lv_xborder_supplied = boolc( ip_xborders_diagonal IS SUPPLIED ). + move_supplied_borders( + EXPORTING + iv_border_supplied = lv_border_supplied + is_border = ip_borders_diagonal + iv_xborder_supplied = lv_xborder_supplied + is_xborder = ip_xborders_diagonal + CHANGING + cs_complete_style_border = complete_style-borders-diagonal + cs_complete_stylex_border = complete_stylex-borders-diagonal ). + multiple_change_requested-borders-diagonal = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders_down. + + lv_xborder_supplied = boolc( ip_xborders_down IS SUPPLIED ). + move_supplied_borders( + EXPORTING + iv_border_supplied = lv_border_supplied + is_border = ip_borders_down + iv_xborder_supplied = lv_xborder_supplied + is_xborder = ip_xborders_down + CHANGING + cs_complete_style_border = complete_style-borders-down + cs_complete_stylex_border = complete_stylex-borders-down ). + multiple_change_requested-borders-down = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders_left. + + lv_xborder_supplied = boolc( ip_xborders_left IS SUPPLIED ). + move_supplied_borders( + EXPORTING + iv_border_supplied = lv_border_supplied + is_border = ip_borders_left + iv_xborder_supplied = lv_xborder_supplied + is_xborder = ip_xborders_left + CHANGING + cs_complete_style_border = complete_style-borders-left + cs_complete_stylex_border = complete_stylex-borders-left ). + multiple_change_requested-borders-left = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders_right. + + lv_xborder_supplied = boolc( ip_xborders_right IS SUPPLIED ). + move_supplied_borders( + EXPORTING + iv_border_supplied = lv_border_supplied + is_border = ip_borders_right + iv_xborder_supplied = lv_xborder_supplied + is_xborder = ip_xborders_right + CHANGING + cs_complete_style_border = complete_style-borders-right + cs_complete_stylex_border = complete_stylex-borders-right ). + multiple_change_requested-borders-right = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_borders_top. + + lv_xborder_supplied = boolc( ip_xborders_top IS SUPPLIED ). + move_supplied_borders( + EXPORTING + iv_border_supplied = lv_border_supplied + is_border = ip_borders_top + iv_xborder_supplied = lv_xborder_supplied + is_xborder = ip_xborders_top + CHANGING + cs_complete_style_border = complete_style-borders-top + cs_complete_stylex_border = complete_stylex-borders-top ). + multiple_change_requested-borders-top = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_fill. + + DATA: fillx LIKE ip_xfill. + IF ip_xfill IS SUPPLIED. + fillx = ip_xfill. + ELSE. + CLEAR fillx WITH 'X'. + IF ip_fill-filltype IS INITIAL. + CLEAR fillx-filltype. + ENDIF. + clear_initial_colorxfields( + EXPORTING + is_color = ip_fill-fgcolor + CHANGING + cs_xcolor = fillx-fgcolor ). + clear_initial_colorxfields( + EXPORTING + is_color = ip_fill-bgcolor + CHANGING + cs_xcolor = fillx-bgcolor ). + + ENDIF. + + complete_style-fill = ip_fill. + complete_stylex-fill = fillx. + multiple_change_requested-fill = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_font. + + DATA: fontx TYPE yecb_s_cstylex_font. + + IF ip_xfont IS SUPPLIED. + fontx = ip_xfont. + ELSE. +* Only supplied values should be used - exception: Flags bold and italic strikethrough underline + fontx-bold = 'X'. + fontx-italic = 'X'. + fontx-strikethrough = 'X'. + fontx-underline_mode = 'X'. + CLEAR fontx-color WITH 'X'. + clear_initial_colorxfields( + EXPORTING + is_color = ip_font-color + CHANGING + cs_xcolor = fontx-color ). + IF ip_font-family IS NOT INITIAL. + fontx-family = 'X'. + ENDIF. + IF ip_font-name IS NOT INITIAL. + fontx-name = 'X'. + ENDIF. + IF ip_font-scheme IS NOT INITIAL. + fontx-scheme = 'X'. + ENDIF. + IF ip_font-size IS NOT INITIAL. + fontx-size = 'X'. + ENDIF. + IF ip_font-underline_mode IS NOT INITIAL. + fontx-underline_mode = 'X'. + ENDIF. + ENDIF. + + complete_style-font = ip_font. + complete_stylex-font = fontx. + multiple_change_requested-font = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_complete_protection. + + MOVE-CORRESPONDING ip_protection TO complete_style-protection. + IF ip_xprotection IS SUPPLIED. + MOVE-CORRESPONDING ip_xprotection TO complete_stylex-protection. + ELSE. + IF ip_protection-hidden IS NOT INITIAL. + complete_stylex-protection-hidden = 'X'. + ENDIF. + IF ip_protection-locked IS NOT INITIAL. + complete_stylex-protection-locked = 'X'. + ENDIF. + ENDIF. + multiple_change_requested-protection = abap_true. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_bgcolor. + + complete_style-fill-bgcolor = value. + complete_stylex-fill-bgcolor-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_bgcolor_indexed. + + complete_style-fill-bgcolor-indexed = value. + complete_stylex-fill-bgcolor-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_bgcolor_rgb. + + complete_style-fill-bgcolor-rgb = value. + complete_stylex-fill-bgcolor-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_bgcolor_theme. + + complete_style-fill-bgcolor-theme = value. + complete_stylex-fill-bgcolor-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_bgcolor_tint. + + complete_style-fill-bgcolor-tint = value. + complete_stylex-fill-bgcolor-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_fgcolor. + + complete_style-fill-fgcolor = value. + complete_stylex-fill-fgcolor-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_fgcolor_indexed. + + complete_style-fill-fgcolor-indexed = value. + complete_stylex-fill-fgcolor-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_fgcolor_rgb. + + complete_style-fill-fgcolor-rgb = value. + complete_stylex-fill-fgcolor-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_fgcolor_theme. + + complete_style-fill-fgcolor-theme = value. + complete_stylex-fill-fgcolor-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_fgcolor_tint. + + complete_style-fill-fgcolor-tint = value. + complete_stylex-fill-fgcolor-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_filltype. + + complete_style-fill-filltype = value. + complete_stylex-fill-filltype = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_bottom. + + complete_style-fill-gradtype-bottom = value. + complete_stylex-fill-gradtype-bottom = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_degree. + + complete_style-fill-gradtype-degree = value. + complete_stylex-fill-gradtype-degree = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_left. + + complete_style-fill-gradtype-left = value. + complete_stylex-fill-gradtype-left = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_position1. + + complete_style-fill-gradtype-position1 = value. + complete_stylex-fill-gradtype-position1 = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_position2. + + complete_style-fill-gradtype-position2 = value. + complete_stylex-fill-gradtype-position2 = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_position3. + + complete_style-fill-gradtype-position3 = value. + complete_stylex-fill-gradtype-position3 = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_right. + + complete_style-fill-gradtype-right = value. + complete_stylex-fill-gradtype-right = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_top. + + complete_style-fill-gradtype-top = value. + complete_stylex-fill-gradtype-top = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_gradtype_type. + + complete_style-fill-gradtype-type = value. + complete_stylex-fill-gradtype-type = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_fill_rotation. + + complete_style-fill-rotation = value. + complete_stylex-fill-rotation = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_bold. + + complete_style-font-bold = value. + complete_stylex-font-bold = 'X'. + single_change_requested-font-bold = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_color. + + complete_style-font-color = value. + complete_stylex-font-color-rgb = 'X'. + single_change_requested-font-color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_color_indexed. + + complete_style-font-color-indexed = value. + complete_stylex-font-color-indexed = 'X'. + single_change_requested-font-color-indexed = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_color_rgb. + + complete_style-font-color-rgb = value. + complete_stylex-font-color-rgb = 'X'. + single_change_requested-font-color-rgb = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_color_theme. + + complete_style-font-color-theme = value. + complete_stylex-font-color-theme = 'X'. + single_change_requested-font-color-theme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_color_tint. + + complete_style-font-color-tint = value. + complete_stylex-font-color-tint = 'X'. + single_change_requested-font-color-tint = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_family. + + complete_style-font-family = value. + complete_stylex-font-family = 'X'. + single_change_requested-font-family = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_italic. + + complete_style-font-italic = value. + complete_stylex-font-italic = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_name. + + complete_style-font-name = value. + complete_stylex-font-name = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_scheme. + + complete_style-font-scheme = value. + complete_stylex-font-scheme = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_size. + + complete_style-font-size = value. + complete_stylex-font-size = abap_true. + single_change_requested-font-size = abap_true. + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_strikethrough. + + complete_style-font-strikethrough = value. + complete_stylex-font-strikethrough = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_underline. + + complete_style-font-underline = value. + complete_stylex-font-underline = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_font_underline_mode. + + complete_style-font-underline_mode = value. + complete_stylex-font-underline_mode = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_number_format. + + complete_style-number_format-format_code = value. + complete_stylex-number_format-format_code = abap_true. + single_change_requested-number_format-format_code = abap_true. + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_protection_hidden. + + complete_style-protection-hidden = value. + complete_stylex-protection-hidden = 'X'. + + result = me. + + ENDMETHOD. + + + METHOD yif_ecb_style_changer~set_protection_locked. + + complete_style-protection-locked = value. + complete_stylex-protection-locked = 'X'. + + result = me. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_changer.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_style_changer.clas.testclasses.abap new file mode 100644 index 0000000..aef09e8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_changer.clas.testclasses.abap @@ -0,0 +1,41 @@ +CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. + + PRIVATE SECTION. + DATA mi_cut TYPE REF TO yif_ecb_style_changer. + DATA mo_excel TYPE REF TO ycl_ecb. + DATA mo_worksheet TYPE REF TO ycl_ecb_worksheet. + + METHODS setup RAISING cx_static_check. + METHODS apply FOR TESTING RAISING cx_static_check. +ENDCLASS. + + +CLASS ltcl_test IMPLEMENTATION. + + METHOD setup. + CREATE OBJECT mo_excel. + mo_worksheet = mo_excel->get_active_worksheet( ). + mi_cut = ycl_ecb_style_changer=>create( mo_excel ). + ENDMETHOD. + + METHOD apply. + + DATA lv_guid TYPE yecb_cell_style. + + mo_worksheet->set_cell( + ip_column = 'B' + ip_row = 2 + ip_value = 'Hello' ). + + mi_cut->set_font_bold( abap_true ). + + lv_guid = mi_cut->apply( + ip_worksheet = mo_worksheet + ip_column = 'B' + ip_row = 2 ). + + mo_excel->get_style_to_guid( lv_guid ). + + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_changer.clas.xml b/src/abap2xlsx/ycl_ecb_style_changer.clas.xml new file mode 100644 index 0000000..9891ef1 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_changer.clas.xml @@ -0,0 +1,17 @@ + + + + + + YCL_ECB_STYLE_CHANGER + E + Style changer + 1 + X + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_color.clas.abap b/src/abap2xlsx/ycl_ecb_style_color.clas.abap new file mode 100644 index 0000000..24932b5 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_color.clas.abap @@ -0,0 +1,102 @@ +CLASS ycl_ecb_style_color DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + +*"* public components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! + CONSTANTS c_black TYPE yecb_style_color_argb VALUE 'FF000000'. "#EC NOTEXT + CONSTANTS c_blue TYPE yecb_style_color_argb VALUE 'FF0000FF'. "#EC NOTEXT + CONSTANTS c_darkblue TYPE yecb_style_color_argb VALUE 'FF000080'. "#EC NOTEXT + CONSTANTS c_darkgreen TYPE yecb_style_color_argb VALUE 'FF008000'. "#EC NOTEXT + CONSTANTS c_darkred TYPE yecb_style_color_argb VALUE 'FF800000'. "#EC NOTEXT + CONSTANTS c_darkyellow TYPE yecb_style_color_argb VALUE 'FF808000'. "#EC NOTEXT + CONSTANTS c_gray TYPE yecb_style_color_argb VALUE 'FFCCCCCC'. "#EC NOTEXT + CONSTANTS c_green TYPE yecb_style_color_argb VALUE 'FF00FF00'. "#EC NOTEXT + CONSTANTS c_red TYPE yecb_style_color_argb VALUE 'FFFF0000'. "#EC NOTEXT + CONSTANTS c_white TYPE yecb_style_color_argb VALUE 'FFFFFFFF'. "#EC NOTEXT + CONSTANTS c_yellow TYPE yecb_style_color_argb VALUE 'FFFFFF00'. "#EC NOTEXT + CONSTANTS c_theme_dark1 TYPE yecb_style_color_theme VALUE 0. "#EC NOTEXT + CONSTANTS c_theme_light1 TYPE yecb_style_color_theme VALUE 1. "#EC NOTEXT + CONSTANTS c_theme_dark2 TYPE yecb_style_color_theme VALUE 2. "#EC NOTEXT + CONSTANTS c_theme_light2 TYPE yecb_style_color_theme VALUE 3. "#EC NOTEXT + CONSTANTS c_theme_accent1 TYPE yecb_style_color_theme VALUE 4. "#EC NOTEXT + CONSTANTS c_theme_accent2 TYPE yecb_style_color_theme VALUE 5. "#EC NOTEXT + CONSTANTS c_theme_accent3 TYPE yecb_style_color_theme VALUE 6. "#EC NOTEXT + CONSTANTS c_theme_accent4 TYPE yecb_style_color_theme VALUE 7. "#EC NOTEXT + CONSTANTS c_theme_accent5 TYPE yecb_style_color_theme VALUE 8. "#EC NOTEXT + CONSTANTS c_theme_accent6 TYPE yecb_style_color_theme VALUE 9. "#EC NOTEXT + CONSTANTS c_theme_hyperlink TYPE yecb_style_color_theme VALUE 10. "#EC NOTEXT + CONSTANTS c_theme_hyperlink_followed TYPE yecb_style_color_theme VALUE 11. "#EC NOTEXT + CONSTANTS c_theme_not_set TYPE yecb_style_color_theme VALUE -1. "#EC NOTEXT + CONSTANTS c_indexed_not_set TYPE yecb_style_color_indexed VALUE -1. "#EC NOTEXT + CONSTANTS c_indexed_sys_foreground TYPE yecb_style_color_indexed VALUE 64. "#EC NOTEXT + + CLASS-METHODS create_new_argb + IMPORTING + !ip_red TYPE yecb_style_color_component + !ip_green TYPE yecb_style_color_component + !ip_blu TYPE yecb_style_color_component + RETURNING + VALUE(ep_color_argb) TYPE yecb_style_color_argb . + CLASS-METHODS create_new_arbg_int + IMPORTING + !iv_red TYPE numeric + !iv_green TYPE numeric + !iv_blue TYPE numeric + RETURNING + VALUE(rv_color_argb) TYPE yecb_style_color_argb . +*"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + +*"* private components of class ZCL_EXCEL_STYLE_COLOR +*"* do not include other source files here!!! + CONSTANTS c_alpha TYPE c LENGTH 2 VALUE 'FF'. "#EC NOTEXT +ENDCLASS. + + + +CLASS ycl_ecb_style_color IMPLEMENTATION. + + + METHOD create_new_arbg_int. + DATA: lv_red TYPE int1, + lv_green TYPE int1, + lv_blue TYPE int1, + lv_hex TYPE x, + lv_char_red TYPE yecb_style_color_component, + lv_char_green TYPE yecb_style_color_component, + lv_char_blue TYPE yecb_style_color_component. + + lv_red = iv_red MOD 256. + lv_green = iv_green MOD 256. + lv_blue = iv_blue MOD 256. + + lv_hex = lv_red. + lv_char_red = lv_hex. + + lv_hex = lv_green. + lv_char_green = lv_hex. + + lv_hex = lv_blue. + lv_char_blue = lv_hex. + + + CONCATENATE ycl_ecb_style_color=>c_alpha lv_char_red lv_char_green lv_char_blue INTO rv_color_argb. + + + ENDMETHOD. + + + METHOD create_new_argb. + + CONCATENATE ycl_ecb_style_color=>c_alpha ip_red ip_green ip_blu INTO ep_color_argb. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_color.clas.xml b/src/abap2xlsx/ycl_ecb_style_color.clas.xml new file mode 100644 index 0000000..b34c580 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_color.clas.xml @@ -0,0 +1,303 @@ + + + + + + YCL_ECB_STYLE_COLOR + E + Excel Style Color + 1 + X + X + X + + + + CREATE_NEW_ARBG_INT + E + Create a custom ARGB color from RGB with integers + + + CREATE_NEW_ARGB + E + Create a custom ARGB color from RGB + + + CREATE_NEW_ARGB + I + Create a custom ARGB color from RGB + + + C_ALPHA + E + Color Alpha + + + C_ALPHA + I + Color Alpha + + + C_BLACK + E + Color ARGB + + + C_BLACK + I + Color ARGB + + + C_BLUE + E + Color ARGB + + + C_BLUE + I + Color ARGB + + + C_DARKBLUE + E + Color ARGB + + + C_DARKBLUE + I + Color ARGB + + + C_DARKGREEN + E + Color ARGB + + + C_DARKGREEN + I + Color ARGB + + + C_DARKRED + E + Color ARGB + + + C_DARKRED + I + Color ARGB + + + C_DARKYELLOW + E + Color ARGB + + + C_DARKYELLOW + I + Color ARGB + + + C_GRAY + E + Color ARGB + + + C_GRAY + I + Color ARGB + + + C_GREEN + E + Color ARGB + + + C_GREEN + I + Color ARGB + + + C_INDEXED_NOT_SET + E + Indexed color value - Not Set + + + C_INDEXED_NOT_SET + I + Indexed color value - Not Set + + + C_INDEXED_SYS_FOREGROUND + E + Indexed color value + + + C_INDEXED_SYS_FOREGROUND + I + Indexed color value + + + C_RED + E + Color ARGB + + + C_RED + I + Color ARGB + + + C_THEME_ACCENT1 + E + Theme Color + + + C_THEME_ACCENT1 + I + Theme Color + + + C_THEME_ACCENT2 + E + Theme Color + + + C_THEME_ACCENT2 + I + Theme Color + + + C_THEME_ACCENT3 + E + Theme Color + + + C_THEME_ACCENT3 + I + Theme Color + + + C_THEME_ACCENT4 + E + Theme Color + + + C_THEME_ACCENT4 + I + Theme Color + + + C_THEME_ACCENT5 + E + Theme Color + + + C_THEME_ACCENT5 + I + Theme Color + + + C_THEME_ACCENT6 + E + Theme Color + + + C_THEME_ACCENT6 + I + Theme Color + + + C_THEME_DARK1 + E + Theme Color + + + C_THEME_DARK1 + I + Theme Color + + + C_THEME_DARK2 + E + Theme Color + + + C_THEME_DARK2 + I + Theme Color + + + C_THEME_HYPERLINK + E + Theme Color + + + C_THEME_HYPERLINK + I + Theme Color + + + C_THEME_HYPERLINK_FOLLOWED + E + Theme Color + + + C_THEME_HYPERLINK_FOLLOWED + I + Theme Color + + + C_THEME_LIGHT1 + E + Theme Color + + + C_THEME_LIGHT1 + I + Theme Color + + + C_THEME_LIGHT2 + E + Theme Color + + + C_THEME_LIGHT2 + I + Theme Color + + + C_THEME_NOT_SET + E + Theme Color - Not Set + + + C_THEME_NOT_SET + I + Theme Color - Not Set + + + C_WHITE + E + Color ARGB + + + C_WHITE + I + Color ARGB + + + C_YELLOW + E + Color ARGB + + + C_YELLOW + I + Color ARGB + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_cond.clas.abap b/src/abap2xlsx/ycl_ecb_style_cond.clas.abap new file mode 100644 index 0000000..d2042af --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_cond.clas.abap @@ -0,0 +1,243 @@ +CLASS ycl_ecb_style_cond DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + CLASS zcl_excel_style_conditional DEFINITION LOAD . + +*"* public components of class ZCL_EXCEL_STYLE_COND +*"* do not include other source files here!!! + TYPES tv_conditional_show_value TYPE c LENGTH 1. + TYPES tv_textfunction TYPE string. + TYPES: BEGIN OF ts_conditional_textfunction, + text TYPE string, + textfunction TYPE tv_textfunction, + cell_style TYPE yecb_cell_style, + END OF ts_conditional_textfunction. + CONSTANTS c_cfvo_type_formula TYPE yecb_conditional_type VALUE 'formula'. "#EC NOTEXT + CONSTANTS c_cfvo_type_max TYPE yecb_conditional_type VALUE 'max'. "#EC NOTEXT + CONSTANTS c_cfvo_type_min TYPE yecb_conditional_type VALUE 'min'. "#EC NOTEXT + CONSTANTS c_cfvo_type_number TYPE yecb_conditional_type VALUE 'num'. "#EC NOTEXT + CONSTANTS c_cfvo_type_percent TYPE yecb_conditional_type VALUE 'percent'. "#EC NOTEXT + CONSTANTS c_cfvo_type_percentile TYPE yecb_conditional_type VALUE 'percentile'. "#EC NOTEXT + CONSTANTS c_iconset_3arrows TYPE yecb_condition_rule_iconset VALUE '3Arrows'. "#EC NOTEXT + CONSTANTS c_iconset_3arrowsgray TYPE yecb_condition_rule_iconset VALUE '3ArrowsGray'. "#EC NOTEXT + CONSTANTS c_iconset_3flags TYPE yecb_condition_rule_iconset VALUE '3Flags'. "#EC NOTEXT + CONSTANTS c_iconset_3signs TYPE yecb_condition_rule_iconset VALUE '3Signs'. "#EC NOTEXT + CONSTANTS c_iconset_3symbols TYPE yecb_condition_rule_iconset VALUE '3Symbols'. "#EC NOTEXT + CONSTANTS c_iconset_3symbols2 TYPE yecb_condition_rule_iconset VALUE '3Symbols2'. "#EC NOTEXT + CONSTANTS c_iconset_3trafficlights TYPE yecb_condition_rule_iconset VALUE ''. "#EC NOTEXT + CONSTANTS c_iconset_3trafficlights2 TYPE yecb_condition_rule_iconset VALUE '3TrafficLights2'. "#EC NOTEXT + CONSTANTS c_iconset_4arrows TYPE yecb_condition_rule_iconset VALUE '4Arrows'. "#EC NOTEXT + CONSTANTS c_iconset_4arrowsgray TYPE yecb_condition_rule_iconset VALUE '4ArrowsGray'. "#EC NOTEXT + CONSTANTS c_iconset_4rating TYPE yecb_condition_rule_iconset VALUE '4Rating'. "#EC NOTEXT + CONSTANTS c_iconset_4redtoblack TYPE yecb_condition_rule_iconset VALUE '4RedToBlack'. "#EC NOTEXT + CONSTANTS c_iconset_4trafficlights TYPE yecb_condition_rule_iconset VALUE '4TrafficLights'. "#EC NOTEXT + CONSTANTS c_iconset_5arrows TYPE yecb_condition_rule_iconset VALUE '5Arrows'. "#EC NOTEXT + CONSTANTS c_iconset_5arrowsgray TYPE yecb_condition_rule_iconset VALUE '5ArrowsGray'. "#EC NOTEXT + CONSTANTS c_iconset_5quarters TYPE yecb_condition_rule_iconset VALUE '5Quarters'. "#EC NOTEXT + CONSTANTS c_iconset_5rating TYPE yecb_condition_rule_iconset VALUE '5Rating'. "#EC NOTEXT + CONSTANTS c_operator_beginswith TYPE yecb_condition_operator VALUE 'beginsWith'. "#EC NOTEXT + CONSTANTS c_operator_between TYPE yecb_condition_operator VALUE 'between'. "#EC NOTEXT + CONSTANTS c_operator_containstext TYPE yecb_condition_operator VALUE 'containsText'. "#EC NOTEXT + CONSTANTS c_operator_endswith TYPE yecb_condition_operator VALUE 'endsWith'. "#EC NOTEXT + CONSTANTS c_operator_equal TYPE yecb_condition_operator VALUE 'equal'. "#EC NOTEXT + CONSTANTS c_operator_greaterthan TYPE yecb_condition_operator VALUE 'greaterThan'. "#EC NOTEXT + CONSTANTS c_operator_greaterthanorequal TYPE yecb_condition_operator VALUE 'greaterThanOrEqual'. "#EC NOTEXT + CONSTANTS c_operator_lessthan TYPE yecb_condition_operator VALUE 'lessThan'. "#EC NOTEXT + CONSTANTS c_operator_lessthanorequal TYPE yecb_condition_operator VALUE 'lessThanOrEqual'. "#EC NOTEXT + CONSTANTS c_operator_none TYPE yecb_condition_operator VALUE ''. "#EC NOTEXT + CONSTANTS c_operator_notcontains TYPE yecb_condition_operator VALUE 'notContains'. "#EC NOTEXT + CONSTANTS c_operator_notequal TYPE yecb_condition_operator VALUE 'notEqual'. "#EC NOTEXT + CONSTANTS c_textfunction_beginswith TYPE tv_textfunction VALUE 'beginsWith'. "#EC NOTEXT + CONSTANTS c_textfunction_containstext TYPE tv_textfunction VALUE 'containsText'. "#EC NOTEXT + CONSTANTS c_textfunction_endswith TYPE tv_textfunction VALUE 'endsWith'. "#EC NOTEXT + CONSTANTS c_textfunction_notcontains TYPE tv_textfunction VALUE 'notContains'. "#EC NOTEXT + CONSTANTS c_rule_cellis TYPE yecb_condition_rule VALUE 'cellIs'. "#EC NOTEXT + CONSTANTS c_rule_containstext TYPE yecb_condition_rule VALUE 'containsText'. "#EC NOTEXT + CONSTANTS c_rule_databar TYPE yecb_condition_rule VALUE 'dataBar'. "#EC NOTEXT + CONSTANTS c_rule_expression TYPE yecb_condition_rule VALUE 'expression'. "#EC NOTEXT + CONSTANTS c_rule_iconset TYPE yecb_condition_rule VALUE 'iconSet'. "#EC NOTEXT + CONSTANTS c_rule_colorscale TYPE yecb_condition_rule VALUE 'colorScale'. "#EC NOTEXT + CONSTANTS c_rule_none TYPE yecb_condition_rule VALUE 'none'. "#EC NOTEXT + CONSTANTS c_rule_textfunction TYPE yecb_condition_rule VALUE ''. "#EC NOTEXT + CONSTANTS c_rule_top10 TYPE yecb_condition_rule VALUE 'top10'. "#EC NOTEXT + CONSTANTS c_rule_above_average TYPE yecb_condition_rule VALUE 'aboveAverage'. "#EC NOTEXT + CONSTANTS c_showvalue_false TYPE tv_conditional_show_value VALUE 0. "#EC NOTEXT + CONSTANTS c_showvalue_true TYPE tv_conditional_show_value VALUE 1. "#EC NOTEXT + DATA mode_cellis TYPE yecb_conditional_cellis . + DATA mode_textfunction TYPE ts_conditional_textfunction . + DATA mode_colorscale TYPE yecb_conditional_colorscale . + DATA mode_databar TYPE yecb_conditional_databar . + DATA mode_expression TYPE yecb_conditional_expression . + DATA mode_iconset TYPE yecb_conditional_iconset . + DATA mode_top10 TYPE yecb_conditional_top10 . + DATA mode_above_average TYPE yecb_conditional_above_avg . + DATA priority TYPE yecb_style_priority VALUE 1. "#EC NOTEXT . . . . . . . . . . . . . . . . . . . . " . + DATA rule TYPE yecb_condition_rule . + + METHODS constructor + IMPORTING + !ip_guid TYPE yecb_cell_style OPTIONAL + !ip_dimension_range TYPE string. + METHODS get_dimension_range + RETURNING + VALUE(ep_dimension_range) TYPE string . + METHODS set_range + IMPORTING + !ip_start_row TYPE yecb_cell_row + !ip_start_column TYPE yecb_cell_column_alpha + !ip_stop_row TYPE yecb_cell_row + !ip_stop_column TYPE yecb_cell_column_alpha + RAISING + ycx_ecb . + METHODS add_range + IMPORTING + !ip_start_row TYPE yecb_cell_row + !ip_start_column TYPE yecb_cell_column_alpha + !ip_stop_row TYPE yecb_cell_row + !ip_stop_column TYPE yecb_cell_column_alpha + RAISING + ycx_ecb . + CLASS-METHODS factory_cond_style_iconset + IMPORTING + !io_worksheet TYPE REF TO ycl_ecb_worksheet + !iv_icon_type TYPE yecb_condition_rule_iconset DEFAULT c_iconset_3trafficlights2 + !iv_cfvo1_type TYPE yecb_conditional_type DEFAULT c_cfvo_type_percent + !iv_cfvo1_value TYPE yecb_conditional_value OPTIONAL + !iv_cfvo2_type TYPE yecb_conditional_type DEFAULT c_cfvo_type_percent + !iv_cfvo2_value TYPE yecb_conditional_value OPTIONAL + !iv_cfvo3_type TYPE yecb_conditional_type DEFAULT c_cfvo_type_percent + !iv_cfvo3_value TYPE yecb_conditional_value OPTIONAL + !iv_cfvo4_type TYPE yecb_conditional_type DEFAULT c_cfvo_type_percent + !iv_cfvo4_value TYPE yecb_conditional_value OPTIONAL + !iv_cfvo5_type TYPE yecb_conditional_type DEFAULT c_cfvo_type_percent + !iv_cfvo5_value TYPE yecb_conditional_value OPTIONAL + !iv_showvalue TYPE tv_conditional_show_value DEFAULT ycl_ecb_style_cond=>c_showvalue_true + RETURNING + VALUE(eo_style_cond) TYPE REF TO ycl_ecb_style_cond . + METHODS get_guid + RETURNING + VALUE(ep_guid) TYPE yecb_cell_style . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + DATA mv_rule_range TYPE string . + DATA guid TYPE yecb_cell_style . +ENDCLASS. + + + +CLASS ycl_ecb_style_cond IMPLEMENTATION. + + + METHOD add_range. + DATA: lv_column TYPE yecb_cell_column, + lv_row_alpha TYPE string, + lv_col_alpha TYPE string, + lv_coords1 TYPE string, + lv_coords2 TYPE string. + + + lv_column = ycl_ecb_common=>convert_column2int( ip_start_column ). + + lv_col_alpha = ip_start_column. + lv_row_alpha = ip_start_row. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_col_alpha lv_row_alpha INTO lv_coords1. + + IF ip_stop_column IS NOT INITIAL. + lv_column = ycl_ecb_common=>convert_column2int( ip_stop_column ). + ELSE. + lv_column = ycl_ecb_common=>convert_column2int( ip_start_column ). + ENDIF. + + IF ip_stop_row IS NOT INITIAL. " If we don't get explicitly a stop column use start column + lv_row_alpha = ip_stop_row. + ELSE. + lv_row_alpha = ip_start_row. + ENDIF. + IF ip_stop_column IS NOT INITIAL. " If we don't get explicitly a stop column use start column + lv_col_alpha = ip_stop_column. + ELSE. + lv_col_alpha = ip_start_column. + ENDIF. + SHIFT lv_row_alpha RIGHT DELETING TRAILING space. + SHIFT lv_row_alpha LEFT DELETING LEADING space. + CONCATENATE lv_col_alpha lv_row_alpha INTO lv_coords2. + IF lv_coords2 IS NOT INITIAL AND lv_coords2 <> lv_coords1. + CONCATENATE me->mv_rule_range ` ` lv_coords1 ':' lv_coords2 INTO me->mv_rule_range. + ELSE. + CONCATENATE me->mv_rule_range ` ` lv_coords1 INTO me->mv_rule_range. + ENDIF. + SHIFT me->mv_rule_range LEFT DELETING LEADING space. + + ENDMETHOD. + + + METHOD constructor. + + DATA: ls_iconset TYPE yecb_conditional_iconset. + ls_iconset-iconset = ycl_ecb_style_cond=>c_iconset_3trafficlights. + ls_iconset-cfvo1_type = ycl_ecb_style_cond=>c_cfvo_type_percent. + ls_iconset-cfvo1_value = '0'. + ls_iconset-cfvo2_type = ycl_ecb_style_cond=>c_cfvo_type_percent. + ls_iconset-cfvo2_value = '20'. + ls_iconset-cfvo3_type = ycl_ecb_style_cond=>c_cfvo_type_percent. + ls_iconset-cfvo3_value = '40'. + ls_iconset-cfvo4_type = ycl_ecb_style_cond=>c_cfvo_type_percent. + ls_iconset-cfvo4_value = '60'. + ls_iconset-cfvo5_type = ycl_ecb_style_cond=>c_cfvo_type_percent. + ls_iconset-cfvo5_value = '80'. + + + me->rule = ycl_ecb_style_cond=>c_rule_none. + me->mode_iconset = ls_iconset. + me->priority = 1. + +* inizialize dimension range + me->mv_rule_range = ip_dimension_range. + + IF ip_guid IS NOT INITIAL. + me->guid = ip_guid. + ELSE. + me->guid = ycl_ecb_obsolete_func_wrap=>guid_create( ). + ENDIF. + + ENDMETHOD. + + + METHOD factory_cond_style_iconset. + + ENDMETHOD. + + + METHOD get_dimension_range. + + ep_dimension_range = me->mv_rule_range. + + ENDMETHOD. + + + METHOD get_guid. + ep_guid = me->guid. + ENDMETHOD. + + + METHOD set_range. + + CLEAR: me->mv_rule_range. + + me->add_range( ip_start_row = ip_start_row + ip_start_column = ip_start_column + ip_stop_row = ip_stop_row + ip_stop_column = ip_stop_column ). + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_cond.clas.xml b/src/abap2xlsx/ycl_ecb_style_cond.clas.xml new file mode 100644 index 0000000..160a9ba --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_cond.clas.xml @@ -0,0 +1,333 @@ + + + + + + YCL_ECB_STYLE_COND + E + Font Style + 1 + X + X + X + + + + ADD_RANGE + E + Add range used in conditional formatting + + + CONSTRUCTOR + E + CONSTRUCTOR + + + C_CFVO_TYPE_FORMULA + E + Condition type + + + C_CFVO_TYPE_MAX + E + Condition type + + + C_CFVO_TYPE_MIN + E + Condition type + + + C_CFVO_TYPE_NUMBER + E + Condition type + + + C_CFVO_TYPE_PERCENT + E + Condition type + + + C_CFVO_TYPE_PERCENTILE + E + Condition type + + + C_ICONSET_3ARROWS + E + Condition rule iconset + + + C_ICONSET_3ARROWSGRAY + E + Condition rule iconset + + + C_ICONSET_3FLAGS + E + Condition rule iconset + + + C_ICONSET_3SIGNS + E + Condition rule iconset + + + C_ICONSET_3SYMBOLS + E + Condition rule iconset + + + C_ICONSET_3SYMBOLS2 + E + Condition rule iconset + + + C_ICONSET_3TRAFFICLIGHTS + E + Condition rule iconset + + + C_ICONSET_3TRAFFICLIGHTS2 + E + Condition rule iconset + + + C_ICONSET_4ARROWS + E + Condition rule iconset + + + C_ICONSET_4ARROWSGRAY + E + Condition rule iconset + + + C_ICONSET_4RATING + E + Condition rule iconset + + + C_ICONSET_4REDTOBLACK + E + Condition rule iconset + + + C_ICONSET_4TRAFFICLIGHTS + E + Condition rule iconset + + + C_ICONSET_5ARROWS + E + Condition rule iconset + + + C_ICONSET_5ARROWSGRAY + E + Condition rule iconset + + + C_ICONSET_5QUARTERS + E + Condition rule iconset + + + C_ICONSET_5RATING + E + Condition rule iconset + + + C_OPERATOR_BEGINSWITH + E + Condition operator + + + C_OPERATOR_BETWEEN + E + Condition operator + + + C_OPERATOR_CONTAINSTEXT + E + Condition operator + + + C_OPERATOR_ENDSWITH + E + Condition operator + + + C_OPERATOR_EQUAL + E + Condition operator + + + C_OPERATOR_GREATERTHAN + E + Condition operator + + + C_OPERATOR_GREATERTHANOREQUAL + E + Condition operator + + + C_OPERATOR_LESSTHAN + E + Condition operator + + + C_OPERATOR_LESSTHANOREQUAL + E + Condition operator + + + C_OPERATOR_NONE + E + Condition operator + + + C_OPERATOR_NOTCONTAINS + E + Condition operator + + + C_OPERATOR_NOTEQUAL + E + Condition operator + + + C_RULE_ABOVE_AVERAGE + E + Rule above avearge + + + C_RULE_CELLIS + E + Condition rule + + + C_RULE_COLORSCALE + E + Condition rule + + + C_RULE_CONTAINSTEXT + E + Condition rule + + + C_RULE_DATABAR + E + Condition rule + + + C_RULE_EXPRESSION + E + Condition rule + + + C_RULE_ICONSET + E + Condition rule + + + C_RULE_NONE + E + Condition rule + + + C_RULE_TOP10 + E + Rule top-10 + + + C_SHOWVALUE_FALSE + E + Condition type + + + C_SHOWVALUE_TRUE + E + Condition type + + + FACTORY_COND_STYLE_ICONSET + E + Add conditional style of type iconset + + + GET_DIMENSION_RANGE + E + Get used range dimension + + + GET_GUID + E + Get guid + + + GUID + E + Style identifier + + + MODE_ABOVE_AVERAGE + E + Top10 settings ( topxx_count determines top20,top50... ) + + + MODE_CELLIS + E + Iconset settings + + + MODE_COLORSCALE + E + Colorscale settings + + + MODE_DATABAR + E + Databar settings + + + MODE_EXPRESSION + E + Expression settings + + + MODE_ICONSET + E + Iconset settings + + + MODE_TOP10 + E + Top10 settings ( topxx_count determines top20,top50... ) + + + MV_RULE_RANGE + E + Rule range + + + PRIORITY + E + Style Priority + + + RULE + E + Condition rule + + + SET_RANGE + E + Set range used in conditional formatting + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_fill.clas.abap b/src/abap2xlsx/ycl_ecb_style_fill.clas.abap new file mode 100644 index 0000000..2d7906d --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_fill.clas.abap @@ -0,0 +1,186 @@ +CLASS ycl_ecb_style_fill DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + +*"* public components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! + CONSTANTS c_fill_none TYPE yecb_fill_type VALUE 'none'. "#EC NOTEXT + CONSTANTS c_fill_solid TYPE yecb_fill_type VALUE 'solid'. "#EC NOTEXT + CONSTANTS c_fill_gradient_linear TYPE yecb_fill_type VALUE 'linear'. "#EC NOTEXT + CONSTANTS c_fill_gradient_path TYPE yecb_fill_type VALUE 'path'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darkdown TYPE yecb_fill_type VALUE 'darkDown'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darkgray TYPE yecb_fill_type VALUE 'darkGray'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darkgrid TYPE yecb_fill_type VALUE 'darkGrid'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darkhorizontal TYPE yecb_fill_type VALUE 'darkHorizontal'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darktrellis TYPE yecb_fill_type VALUE 'darkTrellis'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darkup TYPE yecb_fill_type VALUE 'darkUp'. "#EC NOTEXT + CONSTANTS c_fill_pattern_darkvertical TYPE yecb_fill_type VALUE 'darkVertical'. "#EC NOTEXT + CONSTANTS c_fill_pattern_gray0625 TYPE yecb_fill_type VALUE 'gray0625'. "#EC NOTEXT + CONSTANTS c_fill_pattern_gray125 TYPE yecb_fill_type VALUE 'gray125'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lightdown TYPE yecb_fill_type VALUE 'lightDown'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lightgray TYPE yecb_fill_type VALUE 'lightGray'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lightgrid TYPE yecb_fill_type VALUE 'lightGrid'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lighthorizontal TYPE yecb_fill_type VALUE 'lightHorizontal'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lighttrellis TYPE yecb_fill_type VALUE 'lightTrellis'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lightup TYPE yecb_fill_type VALUE 'lightUp'. "#EC NOTEXT + CONSTANTS c_fill_pattern_lightvertical TYPE yecb_fill_type VALUE 'lightVertical'. "#EC NOTEXT + CONSTANTS c_fill_pattern_mediumgray TYPE yecb_fill_type VALUE 'mediumGray'. "#EC NOTEXT + CONSTANTS c_fill_gradient_horizontal90 TYPE yecb_fill_type VALUE 'horizontal90'. "#EC NOTEXT + CONSTANTS c_fill_gradient_horizontal270 TYPE yecb_fill_type VALUE 'horizontal270'. "#EC NOTEXT + CONSTANTS c_fill_gradient_horizontalb TYPE yecb_fill_type VALUE 'horizontalb'. "#EC NOTEXT + CONSTANTS c_fill_gradient_vertical TYPE yecb_fill_type VALUE 'vertical'. "#EC NOTEXT + CONSTANTS c_fill_gradient_fromcenter TYPE yecb_fill_type VALUE 'fromCenter'. "#EC NOTEXT + CONSTANTS c_fill_gradient_diagonal45 TYPE yecb_fill_type VALUE 'diagonal45'. "#EC NOTEXT + CONSTANTS c_fill_gradient_diagonal45b TYPE yecb_fill_type VALUE 'diagonal45b'. "#EC NOTEXT + CONSTANTS c_fill_gradient_diagonal135 TYPE yecb_fill_type VALUE 'diagonal135'. "#EC NOTEXT + CONSTANTS c_fill_gradient_diagonal135b TYPE yecb_fill_type VALUE 'diagonal135b'. "#EC NOTEXT + CONSTANTS c_fill_gradient_cornerlt TYPE yecb_fill_type VALUE 'cornerLT'. "#EC NOTEXT + CONSTANTS c_fill_gradient_cornerlb TYPE yecb_fill_type VALUE 'cornerLB'. "#EC NOTEXT + CONSTANTS c_fill_gradient_cornerrt TYPE yecb_fill_type VALUE 'cornerRT'. "#EC NOTEXT + CONSTANTS c_fill_gradient_cornerrb TYPE yecb_fill_type VALUE 'cornerRB'. "#EC NOTEXT + DATA gradtype TYPE yecb_s_gradient_type . + DATA filltype TYPE yecb_fill_type . + DATA rotation TYPE yecb_rotation . + DATA fgcolor TYPE yecb_s_style_color . + DATA bgcolor TYPE yecb_s_style_color . + + METHODS constructor . + METHODS get_structure + RETURNING + VALUE(es_fill) TYPE yecb_s_style_fill . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLE_FILL +*"* do not include other source files here!!! + PRIVATE SECTION. + + METHODS build_gradient . + METHODS check_filltype_is_gradient + RETURNING + VALUE(rv_is_gradient) TYPE abap_bool . +ENDCLASS. + + + +CLASS ycl_ecb_style_fill IMPLEMENTATION. + + + METHOD build_gradient. + CHECK check_filltype_is_gradient( ) EQ abap_true. + CLEAR gradtype. + CASE filltype. + WHEN c_fill_gradient_horizontal90. + gradtype-degree = '90'. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + WHEN c_fill_gradient_horizontal270. + gradtype-degree = '270'. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + WHEN c_fill_gradient_horizontalb. + gradtype-degree = '90'. + gradtype-position1 = '0'. + gradtype-position2 = '0.5'. + gradtype-position3 = '1'. + WHEN c_fill_gradient_vertical. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + WHEN c_fill_gradient_fromcenter. + 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'. + WHEN c_fill_gradient_diagonal45. + gradtype-degree = '45'. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + WHEN c_fill_gradient_diagonal45b. + gradtype-degree = '45'. + gradtype-position1 = '0'. + gradtype-position2 = '0.5'. + gradtype-position3 = '1'. + WHEN c_fill_gradient_diagonal135. + gradtype-degree = '135'. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + WHEN c_fill_gradient_diagonal135b. + gradtype-degree = '135'. + gradtype-position1 = '0'. + gradtype-position2 = '0.5'. + gradtype-position3 = '1'. + WHEN c_fill_gradient_cornerlt. + gradtype-type = c_fill_gradient_path. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + WHEN c_fill_gradient_cornerlb. + gradtype-type = c_fill_gradient_path. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + gradtype-bottom = '1'. + gradtype-top = '1'. + WHEN c_fill_gradient_cornerrt. + gradtype-type = c_fill_gradient_path. + gradtype-position1 = '0'. + gradtype-position2 = '1'. + gradtype-left = '1'. + gradtype-right = '1'. + WHEN c_fill_gradient_cornerrb. + 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'. + ENDCASE. + + ENDMETHOD. "build_gradient + + + METHOD check_filltype_is_gradient. + CASE filltype. + WHEN c_fill_gradient_horizontal90 OR + c_fill_gradient_horizontal270 OR + c_fill_gradient_horizontalb OR + c_fill_gradient_vertical OR + c_fill_gradient_fromcenter OR + c_fill_gradient_diagonal45 OR + c_fill_gradient_diagonal45b OR + c_fill_gradient_diagonal135 OR + c_fill_gradient_diagonal135b OR + c_fill_gradient_cornerlt OR + c_fill_gradient_cornerlb OR + c_fill_gradient_cornerrt OR + c_fill_gradient_cornerrb. + rv_is_gradient = abap_true. + ENDCASE. + ENDMETHOD. "check_filltype_is_gradient + + + METHOD constructor. + filltype = ycl_ecb_style_fill=>c_fill_none. + fgcolor-theme = ycl_ecb_style_color=>c_theme_not_set. + fgcolor-indexed = ycl_ecb_style_color=>c_indexed_not_set. + bgcolor-theme = ycl_ecb_style_color=>c_theme_not_set. + bgcolor-indexed = ycl_ecb_style_color=>c_indexed_sys_foreground. + rotation = 0. + + ENDMETHOD. "CONSTRUCTOR + + + METHOD get_structure. + es_fill-rotation = me->rotation. + es_fill-filltype = me->filltype. + es_fill-fgcolor = me->fgcolor. + es_fill-bgcolor = me->bgcolor. + me->build_gradient( ). + es_fill-gradtype = me->gradtype. + ENDMETHOD. "GET_STRUCTURE +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_fill.clas.xml b/src/abap2xlsx/ycl_ecb_style_fill.clas.xml new file mode 100644 index 0000000..6e6c823 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_fill.clas.xml @@ -0,0 +1,288 @@ + + + + + + YCL_ECB_STYLE_FILL + E + Fill Style + 1 + X + X + X + + + + BGCOLOR + E + Color + + + BGCOLOR + I + Color + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_FILL_GRADIENT_LINEAR + E + Fill Type + + + C_FILL_GRADIENT_LINEAR + I + Fill Type + + + C_FILL_GRADIENT_PATH + E + Fill Type + + + C_FILL_GRADIENT_PATH + I + Fill Type + + + C_FILL_NONE + E + Fill Type + + + C_FILL_NONE + I + Fill Type + + + C_FILL_PATTERN_DARKDOWN + E + Fill Type + + + C_FILL_PATTERN_DARKDOWN + I + Fill Type + + + C_FILL_PATTERN_DARKGRAY + E + Fill Type + + + C_FILL_PATTERN_DARKGRAY + I + Fill Type + + + C_FILL_PATTERN_DARKGRID + E + Fill Type + + + C_FILL_PATTERN_DARKGRID + I + Fill Type + + + C_FILL_PATTERN_DARKHORIZONTAL + E + Fill Type + + + C_FILL_PATTERN_DARKHORIZONTAL + I + Fill Type + + + C_FILL_PATTERN_DARKTRELLIS + E + Fill Type + + + C_FILL_PATTERN_DARKTRELLIS + I + Fill Type + + + C_FILL_PATTERN_DARKUP + E + Fill Type + + + C_FILL_PATTERN_DARKUP + I + Fill Type + + + C_FILL_PATTERN_DARKVERTICAL + E + Fill Type + + + C_FILL_PATTERN_DARKVERTICAL + I + Fill Type + + + C_FILL_PATTERN_GRAY0625 + E + Fill Type + + + C_FILL_PATTERN_GRAY0625 + I + Fill Type + + + C_FILL_PATTERN_GRAY125 + E + Fill Type + + + C_FILL_PATTERN_GRAY125 + I + Fill Type + + + C_FILL_PATTERN_LIGHTDOWN + E + Fill Type + + + C_FILL_PATTERN_LIGHTDOWN + I + Fill Type + + + C_FILL_PATTERN_LIGHTGRAY + E + Fill Type + + + C_FILL_PATTERN_LIGHTGRAY + I + Fill Type + + + C_FILL_PATTERN_LIGHTGRID + E + Fill Type + + + C_FILL_PATTERN_LIGHTGRID + I + Fill Type + + + C_FILL_PATTERN_LIGHTHORIZONTAL + E + Fill Type + + + C_FILL_PATTERN_LIGHTHORIZONTAL + I + Fill Type + + + C_FILL_PATTERN_LIGHTTRELLIS + E + Fill Type + + + C_FILL_PATTERN_LIGHTTRELLIS + I + Fill Type + + + C_FILL_PATTERN_LIGHTUP + E + Fill Type + + + C_FILL_PATTERN_LIGHTUP + I + Fill Type + + + C_FILL_PATTERN_LIGHTVERTICAL + E + Fill Type + + + C_FILL_PATTERN_LIGHTVERTICAL + I + Fill Type + + + C_FILL_PATTERN_MEDIUMGRAY + E + Fill Type + + + C_FILL_PATTERN_MEDIUMGRAY + I + Fill Type + + + C_FILL_SOLID + E + Fill Type + + + C_FILL_SOLID + I + Fill Type + + + FGCOLOR + E + Color + + + FGCOLOR + I + Color + + + FILLTYPE + E + Fill Type + + + FILLTYPE + I + Fill Type + + + GET_STRUCTURE + E + Get structure + + + GET_STRUCTURE + I + Get structure + + + ROTATION + E + Rotation + + + ROTATION + I + Rotation + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_font.clas.abap b/src/abap2xlsx/ycl_ecb_style_font.clas.abap new file mode 100644 index 0000000..40c6de2 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_font.clas.abap @@ -0,0 +1,95 @@ +CLASS ycl_ecb_style_font DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + + DATA bold TYPE flag . + DATA color TYPE yecb_s_style_color . + CONSTANTS c_family_decorative TYPE yecb_style_font_family VALUE 5. "#EC NOTEXT + CONSTANTS c_family_modern TYPE yecb_style_font_family VALUE 3. "#EC NOTEXT + CONSTANTS c_family_none TYPE yecb_style_font_family VALUE 0. "#EC NOTEXT + CONSTANTS c_family_roman TYPE yecb_style_font_family VALUE 1. "#EC NOTEXT + CONSTANTS c_family_script TYPE yecb_style_font_family VALUE 4. "#EC NOTEXT + CONSTANTS c_family_swiss TYPE yecb_style_font_family VALUE 2. "#EC NOTEXT + CONSTANTS c_name_arial TYPE yecb_style_font_name VALUE 'Arial'. "#EC NOTEXT + CONSTANTS c_name_calibri TYPE yecb_style_font_name VALUE 'Calibri'. "#EC NOTEXT + CONSTANTS c_name_cambria TYPE yecb_style_font_name VALUE 'Cambria'. "#EC NOTEXT + CONSTANTS c_name_roman TYPE yecb_style_font_name VALUE 'Times New Roman'. "#EC NOTEXT + CONSTANTS c_scheme_major TYPE yecb_style_font_scheme VALUE 'major'. "#EC NOTEXT + CONSTANTS c_scheme_none TYPE yecb_style_font_scheme VALUE ''. "#EC NOTEXT + CONSTANTS c_scheme_minor TYPE yecb_style_font_scheme VALUE 'minor'. "#EC NOTEXT + CONSTANTS c_underline_double TYPE yecb_style_font_underline VALUE 'double'. "#EC NOTEXT + CONSTANTS c_underline_doubleaccounting TYPE yecb_style_font_underline VALUE 'doubleAccounting'. "#EC NOTEXT + CONSTANTS c_underline_none TYPE yecb_style_font_underline VALUE 'none'. "#EC NOTEXT + CONSTANTS c_underline_single TYPE yecb_style_font_underline VALUE 'single'. "#EC NOTEXT + CONSTANTS c_underline_singleaccounting TYPE yecb_style_font_underline VALUE 'singleAccounting'. "#EC NOTEXT + DATA family TYPE yecb_style_font_family VALUE 2. "#EC NOTEXT . . . . . . . . . . . . " . + DATA italic TYPE flag . + DATA name TYPE yecb_style_font_name VALUE 'Calibri'. "#EC NOTEXT . . . . . . . . . . . . " . + DATA scheme TYPE yecb_style_font_scheme VALUE 'minor'. "#EC NOTEXT . . . . . . . . . . . . " . + DATA size TYPE yecb_style_font_size VALUE 11. "#EC NOTEXT . . . . . . . . . . . . " . + DATA strikethrough TYPE flag . + DATA underline TYPE flag . + DATA underline_mode TYPE yecb_style_font_underline . + + METHODS constructor . + METHODS get_structure + RETURNING + VALUE(es_font) TYPE yecb_s_style_font . + METHODS calculate_text_width + IMPORTING + !i_text TYPE yecb_cell_value + RETURNING + VALUE(r_width) TYPE i . +*"* protected components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. +*"* private components of class ZCL_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_style_font IMPLEMENTATION. + + + METHOD calculate_text_width. + " Addition to solve issue #120, contribution by Stefan Schmoecker + r_width = strlen( i_text ). + " use scale factor based on default 11 + " ( don't know where defaultsetting is stored currently ) + r_width = r_width * me->size / 11. + ENDMETHOD. + + + METHOD constructor. + me->color-rgb = ycl_ecb_style_color=>c_black. + me->color-theme = ycl_ecb_style_color=>c_theme_not_set. + me->color-indexed = ycl_ecb_style_color=>c_indexed_not_set. + me->scheme = ycl_ecb_style_font=>c_scheme_minor. + me->underline_mode = ycl_ecb_style_font=>c_underline_single. + ENDMETHOD. + + + METHOD get_structure. + + es_font-bold = me->bold. + es_font-italic = me->italic. + es_font-underline = me->underline. + es_font-underline_mode = me->underline_mode. + es_font-strikethrough = me->strikethrough. + es_font-size = me->size. + es_font-color = me->color. + es_font-name = me->name. + es_font-family = me->family. + es_font-scheme = me->scheme. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_font.clas.xml b/src/abap2xlsx/ycl_ecb_style_font.clas.xml new file mode 100644 index 0000000..33de875 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_font.clas.xml @@ -0,0 +1,328 @@ + + + + + + YCL_ECB_STYLE_FONT + E + Font Style + 1 + X + X + X + + + + BOLD + E + Bold + + + BOLD + I + Bold + + + CALCULATE_TEXT_WIDTH + E + Calculate text width based on font size + + + CALCULATE_TEXT_WIDTH + I + Calculate text width based on font size + + + COLOR + E + Color ARGB + + + COLOR + I + Color ARGB + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_FAMILY_DECORATIVE + E + Font family + + + C_FAMILY_DECORATIVE + I + Font family + + + C_FAMILY_MODERN + E + Font family + + + C_FAMILY_MODERN + I + Font family + + + C_FAMILY_NONE + E + Font family + + + C_FAMILY_NONE + I + Font family + + + C_FAMILY_ROMAN + E + Font family + + + C_FAMILY_ROMAN + I + Font family + + + C_FAMILY_SCRIPT + E + Font family + + + C_FAMILY_SCRIPT + I + Font family + + + C_FAMILY_SWISS + E + Font family + + + C_FAMILY_SWISS + I + Font family + + + C_NAME_ARIAL + E + Font name + + + C_NAME_ARIAL + I + Font name + + + C_NAME_CALIBRI + E + Font name + + + C_NAME_CALIBRI + I + Font name + + + C_NAME_CAMBRIA + E + Font name + + + C_NAME_CAMBRIA + I + Font name + + + C_NAME_ROMAN + E + Font name + + + C_NAME_ROMAN + I + Font name + + + C_SCHEME_MAJOR + E + Font scheme + + + C_SCHEME_MAJOR + I + Font scheme + + + C_SCHEME_MINOR + E + Font scheme + + + C_SCHEME_MINOR + I + Font scheme + + + C_SCHEME_NONE + E + Font scheme + + + C_SCHEME_NONE + I + Font scheme + + + C_UNDERLINE_DOUBLE + E + Font underline + + + C_UNDERLINE_DOUBLE + I + Font underline + + + C_UNDERLINE_DOUBLEACCOUNTING + E + Font underline + + + C_UNDERLINE_DOUBLEACCOUNTING + I + Font underline + + + C_UNDERLINE_NONE + E + Font underline + + + C_UNDERLINE_NONE + I + Font underline + + + C_UNDERLINE_SINGLE + E + Font underline + + + C_UNDERLINE_SINGLE + I + Font underline + + + C_UNDERLINE_SINGLEACCOUNTING + E + Font underline + + + C_UNDERLINE_SINGLEACCOUNTING + I + Font underline + + + FAMILY + E + Font family + + + FAMILY + I + Font family + + + GET_STRUCTURE + E + Get class as a structure + + + GET_STRUCTURE + I + Get class as a structure + + + ITALIC + E + Italic + + + ITALIC + I + Italic + + + NAME + E + Font name + + + NAME + I + Font name + + + SCHEME + E + Scheme code + + + SCHEME + I + Scheme code + + + SIZE + E + Font size + + + SIZE + I + Font size + + + STRIKETHROUGH + E + Strikethrough + + + STRIKETHROUGH + I + Strikethrough + + + UNDERLINE + E + Underline + + + UNDERLINE + I + Underline + + + UNDERLINE_MODE + E + Underline mode + + + UNDERLINE_MODE + I + Underline mode + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_number_format.clas.abap b/src/abap2xlsx/ycl_ecb_style_number_format.clas.abap new file mode 100644 index 0000000..798bf2d --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_number_format.clas.abap @@ -0,0 +1,166 @@ +CLASS ycl_ecb_style_number_format DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: + BEGIN OF t_num_format, + id TYPE string, + format TYPE REF TO ycl_ecb_style_number_format, + END OF t_num_format . + TYPES: + t_num_formats TYPE HASHED TABLE OF t_num_format WITH UNIQUE KEY id . + +*"* public components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! + CONSTANTS c_format_numc_std TYPE yecb_number_format VALUE 'STD_NDEC'. "#EC NOTEXT + CONSTANTS c_format_date_std TYPE yecb_number_format VALUE 'STD_DATE'. "#EC NOTEXT + CONSTANTS c_format_currency_eur_simple TYPE yecb_number_format VALUE '[$EUR ]#,##0.00_-'. "#EC NOTEXT + CONSTANTS c_format_currency_usd TYPE yecb_number_format VALUE '$#,##0_-'. "#EC NOTEXT + CONSTANTS c_format_currency_usd_simple TYPE yecb_number_format VALUE '"$"#,##0.00_-'. "#EC NOTEXT + CONSTANTS c_format_currency_simple TYPE yecb_number_format VALUE '$#,##0_);($#,##0)'. "#EC NOTEXT + CONSTANTS c_format_currency_simple_red TYPE yecb_number_format VALUE '$#,##0_);[Red]($#,##0)'. "#EC NOTEXT + CONSTANTS c_format_currency_simple2 TYPE yecb_number_format VALUE '$#,##0.00_);($#,##0.00)'. "#EC NOTEXT + CONSTANTS c_format_currency_simple_red2 TYPE yecb_number_format VALUE '$#,##0.00_);[Red]($#,##0.00)'. "#EC NOTEXT + CONSTANTS c_format_date_datetime TYPE yecb_number_format VALUE 'd/m/y h:mm'. "#EC NOTEXT + CONSTANTS c_format_date_ddmmyyyy TYPE yecb_number_format VALUE 'dd/mm/yy'. "#EC NOTEXT + CONSTANTS c_format_date_ddmmyyyydot TYPE yecb_number_format VALUE 'dd\.mm\.yyyy'. "#EC NOTEXT + CONSTANTS c_format_date_dmminus TYPE yecb_number_format VALUE 'd-m'. "#EC NOTEXT + CONSTANTS c_format_date_dmyminus TYPE yecb_number_format VALUE 'd-m-y'. "#EC NOTEXT + CONSTANTS c_format_date_dmyslash TYPE yecb_number_format VALUE 'd/m/y'. "#EC NOTEXT + CONSTANTS c_format_date_myminus TYPE yecb_number_format VALUE 'm-y'. "#EC NOTEXT + CONSTANTS c_format_date_time1 TYPE yecb_number_format VALUE 'h:mm AM/PM'. "#EC NOTEXT + CONSTANTS c_format_date_time2 TYPE yecb_number_format VALUE 'h:mm:ss AM/PM'. "#EC NOTEXT + CONSTANTS c_format_date_time3 TYPE yecb_number_format VALUE 'h:mm'. "#EC NOTEXT + CONSTANTS c_format_date_time4 TYPE yecb_number_format VALUE 'h:mm:ss'. "#EC NOTEXT + CONSTANTS c_format_date_time5 TYPE yecb_number_format VALUE 'mm:ss'. "#EC NOTEXT + CONSTANTS c_format_date_time6 TYPE yecb_number_format VALUE 'h:mm:ss'. "#EC NOTEXT + CONSTANTS c_format_date_time7 TYPE yecb_number_format VALUE 'i:s.S'. "#EC NOTEXT + CONSTANTS c_format_date_time8 TYPE yecb_number_format VALUE 'h:mm:ss@'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx14 TYPE yecb_number_format VALUE 'mm-dd-yy'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx15 TYPE yecb_number_format VALUE 'd-mmm-yy'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx16 TYPE yecb_number_format VALUE 'd-mmm'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx17 TYPE yecb_number_format VALUE 'mmm-yy'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx22 TYPE yecb_number_format VALUE 'm/d/yy h:mm'. "#EC NOTEXT + CONSTANTS c_format_date_yymmdd TYPE yecb_number_format VALUE 'yymmdd'. "#EC NOTEXT + CONSTANTS c_format_date_yymmddminus TYPE yecb_number_format VALUE 'yy-mm-dd'. "#EC NOTEXT + CONSTANTS c_format_date_yymmddslash TYPE yecb_number_format VALUE 'yy/mm/dd'. "#EC NOTEXT + CONSTANTS c_format_date_yyyymmdd TYPE yecb_number_format VALUE 'yyyymmdd'. "#EC NOTEXT + CONSTANTS c_format_date_yyyymmddminus TYPE yecb_number_format VALUE 'yyyy-mm-dd'. "#EC NOTEXT + CONSTANTS c_format_date_yyyymmddslash TYPE yecb_number_format VALUE 'yyyy/mm/dd'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx45 TYPE yecb_number_format VALUE 'mm:ss'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx46 TYPE yecb_number_format VALUE '[h]:mm:ss'. "#EC NOTEXT + CONSTANTS c_format_date_xlsx47 TYPE yecb_number_format VALUE 'mm:ss.0'. "#EC NOTEXT + CONSTANTS c_format_general TYPE yecb_number_format VALUE ''. "#EC NOTEXT + CONSTANTS c_format_number TYPE yecb_number_format VALUE '0'. "#EC NOTEXT + CONSTANTS c_format_number_00 TYPE yecb_number_format VALUE '0.00'. "#EC NOTEXT + CONSTANTS c_format_number_comma_sep0 TYPE yecb_number_format VALUE '#,##0'. "#EC NOTEXT + CONSTANTS c_format_number_comma_sep1 TYPE yecb_number_format VALUE '#,##0.00'. "#EC NOTEXT + CONSTANTS c_format_number_comma_sep2 TYPE yecb_number_format VALUE '#,##0.00_-'. "#EC NOTEXT + CONSTANTS c_format_percentage TYPE yecb_number_format VALUE '0%'. "#EC NOTEXT + CONSTANTS c_format_percentage_00 TYPE yecb_number_format VALUE '0.00%'. "#EC NOTEXT + CONSTANTS c_format_text TYPE yecb_number_format VALUE '@'. "#EC NOTEXT + CONSTANTS c_format_fraction_1 TYPE yecb_number_format VALUE '# ?/?'. "#EC NOTEXT + CONSTANTS c_format_fraction_2 TYPE yecb_number_format VALUE '# ??/??'. "#EC NOTEXT + CONSTANTS c_format_scientific TYPE yecb_number_format VALUE '0.00E+00'. "#EC NOTEXT + CONSTANTS c_format_special_01 TYPE yecb_number_format VALUE '##0.0E+0'. "#EC NOTEXT + DATA format_code TYPE yecb_number_format . + CLASS-DATA mt_built_in_num_formats TYPE t_num_formats READ-ONLY . + CONSTANTS c_format_xlsx37 TYPE yecb_number_format VALUE '#,##0_);(#,##0)'. "#EC NOTEXT + CONSTANTS c_format_xlsx38 TYPE yecb_number_format VALUE '#,##0_);[Red](#,##0)'. "#EC NOTEXT + CONSTANTS c_format_xlsx39 TYPE yecb_number_format VALUE '#,##0.00_);(#,##0.00)'. "#EC NOTEXT + CONSTANTS c_format_xlsx40 TYPE yecb_number_format VALUE '#,##0.00_);[Red](#,##0.00)'. "#EC NOTEXT + CONSTANTS c_format_xlsx41 TYPE yecb_number_format VALUE '_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)'. "#EC NOTEXT + CONSTANTS c_format_xlsx42 TYPE yecb_number_format VALUE '_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)'. "#EC NOTEXT + CONSTANTS c_format_xlsx43 TYPE yecb_number_format VALUE '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)'. "#EC NOTEXT + CONSTANTS c_format_xlsx44 TYPE yecb_number_format VALUE '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)'. "#EC NOTEXT + CONSTANTS c_format_currency_gbp_simple TYPE yecb_number_format VALUE '[$£-809]#,##0.00'. "#EC NOTEXT + CONSTANTS c_format_currency_pln_simple TYPE yecb_number_format VALUE '#,##0.00\ "zł"'. "#EC NOTEXT + + CLASS-METHODS class_constructor . + METHODS constructor . + METHODS get_structure + RETURNING + VALUE(ep_number_format) TYPE yecb_s_style_numfmt . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + CLASS-METHODS add_format + IMPORTING + id TYPE string + code TYPE yecb_number_format. +*"* private components of class ZCL_EXCEL_STYLE_NUMBER_FORMAT +*"* do not include other source files here!!! +ENDCLASS. + + + +CLASS ycl_ecb_style_number_format IMPLEMENTATION. + + METHOD add_format. + DATA ls_num_format LIKE LINE OF mt_built_in_num_formats. + ls_num_format-id = id. + CREATE OBJECT ls_num_format-format. + ls_num_format-format->format_code = code. + INSERT ls_num_format INTO TABLE mt_built_in_num_formats. + ENDMETHOD. + + METHOD class_constructor. + + CLEAR mt_built_in_num_formats. + + add_format( id = '1' code = ycl_ecb_style_number_format=>c_format_number ). " '0'. + add_format( id = '2' code = ycl_ecb_style_number_format=>c_format_number_00 ). " '0.00'. + add_format( id = '3' code = ycl_ecb_style_number_format=>c_format_number_comma_sep0 ). " '#,##0'. + add_format( id = '4' code = ycl_ecb_style_number_format=>c_format_number_comma_sep1 ). " '#,##0.00'. + add_format( id = '5' code = ycl_ecb_style_number_format=>c_format_currency_simple ). " '$#,##0_);($#,##0)'. + add_format( id = '6' code = ycl_ecb_style_number_format=>c_format_currency_simple_red ). " '$#,##0_);[Red]($#,##0)'. + add_format( id = '7' code = ycl_ecb_style_number_format=>c_format_currency_simple2 ). " '$#,##0.00_);($#,##0.00)'. + add_format( id = '8' code = ycl_ecb_style_number_format=>c_format_currency_simple_red2 ). " '$#,##0.00_);[Red]($#,##0.00)'. + add_format( id = '9' code = ycl_ecb_style_number_format=>c_format_percentage ). " '0%'. + add_format( id = '10' code = ycl_ecb_style_number_format=>c_format_percentage_00 ). " '0.00%'. + add_format( id = '11' code = ycl_ecb_style_number_format=>c_format_scientific ). " '0.00E+00'. + add_format( id = '12' code = ycl_ecb_style_number_format=>c_format_fraction_1 ). " '# ?/?'. + add_format( id = '13' code = ycl_ecb_style_number_format=>c_format_fraction_2 ). " '# ??/??'. + add_format( id = '14' code = ycl_ecb_style_number_format=>c_format_date_xlsx14 ). "'m/d/yyyy'. <-- should have been 'mm-dd-yy' like constant in zcl_excel_style_number_format + add_format( id = '15' code = ycl_ecb_style_number_format=>c_format_date_xlsx15 ). "'d-mmm-yy'. + add_format( id = '16' code = ycl_ecb_style_number_format=>c_format_date_xlsx16 ). "'d-mmm'. + add_format( id = '17' code = ycl_ecb_style_number_format=>c_format_date_xlsx17 ). "'mmm-yy'. + add_format( id = '18' code = ycl_ecb_style_number_format=>c_format_date_time1 ). " 'h:mm AM/PM'. + add_format( id = '19' code = ycl_ecb_style_number_format=>c_format_date_time2 ). " 'h:mm:ss AM/PM'. + add_format( id = '20' code = ycl_ecb_style_number_format=>c_format_date_time3 ). " 'h:mm'. + add_format( id = '21' code = ycl_ecb_style_number_format=>c_format_date_time4 ). " 'h:mm:ss'. + add_format( id = '22' code = ycl_ecb_style_number_format=>c_format_date_xlsx22 ). " 'm/d/yyyy h:mm'. + + + add_format( id = '37' code = ycl_ecb_style_number_format=>c_format_xlsx37 ). " '#,##0_);(#,##0)'. + add_format( id = '38' code = ycl_ecb_style_number_format=>c_format_xlsx38 ). " '#,##0_);[Red](#,##0)'. + add_format( id = '39' code = ycl_ecb_style_number_format=>c_format_xlsx39 ). " '#,##0.00_);(#,##0.00)'. + add_format( id = '40' code = ycl_ecb_style_number_format=>c_format_xlsx40 ). " '#,##0.00_);[Red](#,##0.00)'. + add_format( id = '41' code = ycl_ecb_style_number_format=>c_format_xlsx41 ). " '_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)'. + add_format( id = '42' code = ycl_ecb_style_number_format=>c_format_xlsx42 ). " '_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)'. + add_format( id = '43' code = ycl_ecb_style_number_format=>c_format_xlsx43 ). " '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)'. + add_format( id = '44' code = ycl_ecb_style_number_format=>c_format_xlsx44 ). " '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)'. + add_format( id = '45' code = ycl_ecb_style_number_format=>c_format_date_xlsx45 ). " 'mm:ss'. + add_format( id = '46' code = ycl_ecb_style_number_format=>c_format_date_xlsx46 ). " '[h]:mm:ss'. + add_format( id = '47' code = ycl_ecb_style_number_format=>c_format_date_xlsx47 ). " 'mm:ss.0'. + add_format( id = '48' code = ycl_ecb_style_number_format=>c_format_special_01 ). " '##0.0E+0'. + add_format( id = '49' code = ycl_ecb_style_number_format=>c_format_text ). " '@'. + + ENDMETHOD. + + + METHOD constructor. + format_code = me->c_format_general. + ENDMETHOD. + + + METHOD get_structure. + ep_number_format-numfmt = me->format_code. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_number_format.clas.xml b/src/abap2xlsx/ycl_ecb_style_number_format.clas.xml new file mode 100644 index 0000000..c98f342 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_number_format.clas.xml @@ -0,0 +1,543 @@ + + + + + + YCL_ECB_STYLE_NUMBER_FORMAT + E + Number Format Style + 1 + X + X + X + + + + CLASS_CONSTRUCTOR + E + CLASS_CONSTRUCTOR + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_FORMAT_CURRENCY_EUR_SIMPLE + E + Number format + + + C_FORMAT_CURRENCY_EUR_SIMPLE + I + Number format + + + C_FORMAT_CURRENCY_SIMPLE + E + Number format + + + C_FORMAT_CURRENCY_SIMPLE2 + E + Number format + + + C_FORMAT_CURRENCY_SIMPLE_RED + E + Number format + + + C_FORMAT_CURRENCY_SIMPLE_RED2 + E + Number format + + + C_FORMAT_CURRENCY_USD + E + Number format + + + C_FORMAT_CURRENCY_USD + I + Number format + + + C_FORMAT_CURRENCY_USD_SIMPLE + E + Number format + + + C_FORMAT_CURRENCY_USD_SIMPLE + I + Number format + + + C_FORMAT_DATE_DATETIME + E + Number format + + + C_FORMAT_DATE_DATETIME + I + Number format + + + C_FORMAT_DATE_DDMMYYYY + E + Number format + + + C_FORMAT_DATE_DDMMYYYY + I + Number format + + + C_FORMAT_DATE_DDMMYYYYDOT + E + Number format + + + C_FORMAT_DATE_DDMMYYYYDOT + I + Number format + + + C_FORMAT_DATE_DMMINUS + E + Number format + + + C_FORMAT_DATE_DMMINUS + I + Number format + + + C_FORMAT_DATE_DMYMINUS + E + Number format + + + C_FORMAT_DATE_DMYMINUS + I + Number format + + + C_FORMAT_DATE_DMYSLASH + E + Number format + + + C_FORMAT_DATE_DMYSLASH + I + Number format + + + C_FORMAT_DATE_MYMINUS + E + Number format + + + C_FORMAT_DATE_MYMINUS + I + Number format + + + C_FORMAT_DATE_STD + E + Number format + + + C_FORMAT_DATE_STD + I + Number format + + + C_FORMAT_DATE_TIME1 + E + Number format + + + C_FORMAT_DATE_TIME1 + I + Number format + + + C_FORMAT_DATE_TIME2 + E + Number format + + + C_FORMAT_DATE_TIME2 + I + Number format + + + C_FORMAT_DATE_TIME3 + E + Number format + + + C_FORMAT_DATE_TIME3 + I + Number format + + + C_FORMAT_DATE_TIME4 + E + Number format + + + C_FORMAT_DATE_TIME4 + I + Number format + + + C_FORMAT_DATE_TIME5 + E + Number format + + + C_FORMAT_DATE_TIME5 + I + Number format + + + C_FORMAT_DATE_TIME6 + E + Number format + + + C_FORMAT_DATE_TIME6 + I + Number format + + + C_FORMAT_DATE_TIME7 + E + Number format + + + C_FORMAT_DATE_TIME7 + I + Number format + + + C_FORMAT_DATE_TIME8 + E + Number format + + + C_FORMAT_DATE_TIME8 + I + Number format + + + C_FORMAT_DATE_XLSX14 + E + Number format + + + C_FORMAT_DATE_XLSX14 + I + Number format + + + C_FORMAT_DATE_XLSX15 + E + Number format + + + C_FORMAT_DATE_XLSX15 + I + Number format + + + C_FORMAT_DATE_XLSX16 + E + Number format + + + C_FORMAT_DATE_XLSX16 + I + Number format + + + C_FORMAT_DATE_XLSX17 + E + Number format + + + C_FORMAT_DATE_XLSX17 + I + Number format + + + C_FORMAT_DATE_XLSX22 + E + Number format + + + C_FORMAT_DATE_XLSX22 + I + Number format + + + C_FORMAT_DATE_XLSX45 + E + Number format + + + C_FORMAT_DATE_XLSX46 + E + Number format + + + C_FORMAT_DATE_XLSX47 + E + Number format + + + C_FORMAT_DATE_YYMMDD + E + Number format + + + C_FORMAT_DATE_YYMMDD + I + Number format + + + C_FORMAT_DATE_YYMMDDMINUS + E + Number format + + + C_FORMAT_DATE_YYMMDDMINUS + I + Number format + + + C_FORMAT_DATE_YYMMDDSLASH + E + Number format + + + C_FORMAT_DATE_YYMMDDSLASH + I + Number format + + + C_FORMAT_DATE_YYYYMMDD + E + Number format + + + C_FORMAT_DATE_YYYYMMDD + I + Number format + + + C_FORMAT_DATE_YYYYMMDDMINUS + E + Number format + + + C_FORMAT_DATE_YYYYMMDDMINUS + I + Number format + + + C_FORMAT_DATE_YYYYMMDDSLASH + E + Number format + + + C_FORMAT_DATE_YYYYMMDDSLASH + I + Number format + + + C_FORMAT_FRACTION_1 + E + Number format + + + C_FORMAT_FRACTION_2 + E + Number format + + + C_FORMAT_GENERAL + E + Number format + + + C_FORMAT_GENERAL + I + Number format + + + C_FORMAT_NUMBER + E + Number format + + + C_FORMAT_NUMBER + I + Number format + + + C_FORMAT_NUMBER_00 + E + Number format + + + C_FORMAT_NUMBER_00 + I + Number format + + + C_FORMAT_NUMBER_COMMA_SEP0 + E + Number format + + + C_FORMAT_NUMBER_COMMA_SEP1 + E + Number format + + + C_FORMAT_NUMBER_COMMA_SEP1 + I + Number format + + + C_FORMAT_NUMBER_COMMA_SEP2 + E + Number format + + + C_FORMAT_NUMBER_COMMA_SEP2 + I + Number format + + + C_FORMAT_NUMC_STD + E + Number format + + + C_FORMAT_NUMC_STD + I + Number format + + + C_FORMAT_PERCENTAGE + E + Number format + + + C_FORMAT_PERCENTAGE + I + Number format + + + C_FORMAT_PERCENTAGE_00 + E + Number format + + + C_FORMAT_PERCENTAGE_00 + I + Number format + + + C_FORMAT_SCIENTIFIC + E + Number format + + + C_FORMAT_SPECIAL_01 + E + Number format + + + C_FORMAT_TEXT + E + Number format + + + C_FORMAT_TEXT + I + Number format + + + C_FORMAT_XLSX37 + E + Number format + + + C_FORMAT_XLSX38 + E + Number format + + + C_FORMAT_XLSX39 + E + Number format + + + C_FORMAT_XLSX40 + E + Number format + + + C_FORMAT_XLSX41 + E + Number format + + + C_FORMAT_XLSX42 + E + Number format + + + C_FORMAT_XLSX43 + E + Number format + + + C_FORMAT_XLSX44 + E + Number format + + + FORMAT_CODE + E + Number format + + + FORMAT_CODE + I + Number format + + + MT_BUILT_IN_NUM_FORMATS + E + Built-in internal number formats + + + T_NUM_FORMATS + E + Number formats + index + + + + + diff --git a/src/abap2xlsx/ycl_ecb_style_protection.clas.abap b/src/abap2xlsx/ycl_ecb_style_protection.clas.abap new file mode 100644 index 0000000..7238533 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_protection.clas.abap @@ -0,0 +1,46 @@ +CLASS ycl_ecb_style_protection DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! + PUBLIC SECTION. + + CONSTANTS c_protection_hidden TYPE yecb_cell_protection VALUE '1'. "#EC NOTEXT + CONSTANTS c_protection_locked TYPE yecb_cell_protection VALUE '1'. "#EC NOTEXT + CONSTANTS c_protection_unhidden TYPE yecb_cell_protection VALUE '0'. "#EC NOTEXT + CONSTANTS c_protection_unlocked TYPE yecb_cell_protection VALUE '0'. "#EC NOTEXT + DATA hidden TYPE yecb_cell_protection . + DATA locked TYPE yecb_cell_protection . + + METHODS constructor . + METHODS get_structure + RETURNING + VALUE(ep_protection) TYPE yecb_s_style_protection . +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_STYLE_FONT +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLE_PROTECTION +*"* do not include other source files here!!! + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_style_protection IMPLEMENTATION. + + + METHOD constructor. + locked = me->c_protection_locked. + hidden = me->c_protection_unhidden. + ENDMETHOD. + + + METHOD get_structure. + ep_protection-locked = me->locked. + ep_protection-hidden = me->hidden. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_style_protection.clas.xml b/src/abap2xlsx/ycl_ecb_style_protection.clas.xml new file mode 100644 index 0000000..bdfc669 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_style_protection.clas.xml @@ -0,0 +1,88 @@ + + + + + + YCL_ECB_STYLE_PROTECTION + E + Protection Style + 1 + X + X + X + + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + C_PROTECTION_HIDDEN + E + Protection + + + C_PROTECTION_HIDDEN + I + Protection + + + C_PROTECTION_LOCKED + E + Protection + + + C_PROTECTION_LOCKED + I + Protection + + + C_PROTECTION_UNHIDDEN + E + Protection + + + C_PROTECTION_UNHIDDEN + I + Protection + + + C_PROTECTION_UNLOCKED + E + Protection + + + C_PROTECTION_UNLOCKED + I + Protection + + + HIDDEN + E + Protection + + + HIDDEN + I + Protection + + + LOCKED + E + Protection + + + LOCKED + I + Protection + + + + + diff --git a/src/abap2xlsx/ycl_ecb_styles.clas.abap b/src/abap2xlsx/ycl_ecb_styles.clas.abap new file mode 100644 index 0000000..08545a9 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_styles.clas.abap @@ -0,0 +1,116 @@ +CLASS ycl_ecb_styles DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_STYLES +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS add + IMPORTING + !ip_style TYPE REF TO ycl_ecb_style . + METHODS clear . + METHODS constructor . + METHODS get + IMPORTING + !ip_index TYPE i + RETURNING + VALUE(eo_style) TYPE REF TO ycl_ecb_style . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !ip_style TYPE REF TO ycl_ecb_style . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . + METHODS register_new_style + IMPORTING + !io_style TYPE REF TO ycl_ecb_style + RETURNING + VALUE(ep_style_code) TYPE i . +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + DATA styles TYPE REF TO ycl_ecb_collection . +ENDCLASS. + + + +CLASS ycl_ecb_styles IMPLEMENTATION. + + + METHOD add. + + + styles->add( ip_style ). + ENDMETHOD. + + + METHOD clear. + + + styles->clear( ). + ENDMETHOD. + + + METHOD constructor. + + + CREATE OBJECT styles. + ENDMETHOD. + + + METHOD get. + + + eo_style ?= styles->get( ip_index ). + ENDMETHOD. + + + METHOD get_iterator. + + + eo_iterator ?= styles->get_iterator( ). + ENDMETHOD. + + + METHOD is_empty. + + + is_empty = styles->is_empty( ). + ENDMETHOD. + + + METHOD register_new_style. + + + me->add( io_style ). + ep_style_code = me->size( ) - 1. "style count starts from 0 + ENDMETHOD. + + + METHOD remove. + + + styles->remove( ip_style ). + ENDMETHOD. + + + METHOD size. + + + ep_size = styles->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_styles.clas.xml b/src/abap2xlsx/ycl_ecb_styles.clas.xml new file mode 100644 index 0000000..86163b9 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_styles.clas.xml @@ -0,0 +1,108 @@ + + + + + + YCL_ECB_STYLES + E + Styles collection + 1 + X + X + X + + + + ADD + E + Adds an Element to the Collection + + + ADD + I + Adds an Element to the Collection + + + CLEAR + E + Initializes the Collection + + + CLEAR + I + Initializes the Collection + + + CONSTRUCTOR + E + CONSTRUCTOR + + + CONSTRUCTOR + I + CONSTRUCTOR + + + GET + E + Gets Element + + + GET + I + Gets Element + + + GET_ITERATOR + E + Returns an iterator + + + GET_ITERATOR + I + Returns an iterator + + + IS_EMPTY + E + Checks whether elements are contained + + + IS_EMPTY + I + Checks whether elements are contained + + + REGISTER_NEW_STYLE + E + Register a new style + + + REGISTER_NEW_STYLE + I + Register a new style + + + REMOVE + E + Deletes an Element from the Collection + + + REMOVE + I + Deletes an Element from the Collection + + + SIZE + E + Specifies number of contained elements + + + SIZE + I + Specifies number of contained elements + + + + + diff --git a/src/abap2xlsx/ycl_ecb_styles_cond.clas.abap b/src/abap2xlsx/ycl_ecb_styles_cond.clas.abap new file mode 100644 index 0000000..17b7268 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_styles_cond.clas.abap @@ -0,0 +1,89 @@ +CLASS ycl_ecb_styles_cond DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_STYLES_COND +*"* do not include other source files here!!! + PUBLIC SECTION. + + METHODS add + IMPORTING + !ip_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS clear . + METHODS constructor . + METHODS get + IMPORTING + !ip_index TYPE yecb_active_worksheet + RETURNING + VALUE(eo_style_cond) TYPE REF TO ycl_ecb_style_cond . + METHODS get_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS is_empty + RETURNING + VALUE(is_empty) TYPE flag . + METHODS remove + IMPORTING + !ip_style_cond TYPE REF TO ycl_ecb_style_cond . + METHODS size + RETURNING + VALUE(ep_size) TYPE i . +*"* protected components of class ZABAP_EXCEL_WORKSHEETS +*"* do not include other source files here!!! + PROTECTED SECTION. +*"* private components of class ZCL_EXCEL_STYLES_COND +*"* do not include other source files here!!! + PRIVATE SECTION. + + DATA styles_cond TYPE REF TO ycl_ecb_collection . +ENDCLASS. + + + +CLASS ycl_ecb_styles_cond IMPLEMENTATION. + + + METHOD add. + styles_cond->add( ip_style_cond ). + ENDMETHOD. + + + METHOD clear. + styles_cond->clear( ). + ENDMETHOD. + + + METHOD constructor. + + CREATE OBJECT styles_cond. + + ENDMETHOD. + + + METHOD get. + DATA lv_index TYPE i. + lv_index = ip_index. + eo_style_cond ?= styles_cond->get( lv_index ). + ENDMETHOD. + + + METHOD get_iterator. + eo_iterator ?= styles_cond->get_iterator( ). + ENDMETHOD. + + + METHOD is_empty. + is_empty = styles_cond->is_empty( ). + ENDMETHOD. + + + METHOD remove. + styles_cond->remove( ip_style_cond ). + ENDMETHOD. + + + METHOD size. + ep_size = styles_cond->size( ). + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_styles_cond.clas.xml b/src/abap2xlsx/ycl_ecb_styles_cond.clas.xml new file mode 100644 index 0000000..654a989 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_styles_cond.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_STYLES_COND + E + Styles conditional collection + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_table.clas.abap b/src/abap2xlsx/ycl_ecb_table.clas.abap new file mode 100644 index 0000000..bc3904d --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_table.clas.abap @@ -0,0 +1,304 @@ +CLASS ycl_ecb_table DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + +*"* public components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! + PUBLIC SECTION. + + CONSTANTS builtinstyle_dark1 TYPE yecb_table_style VALUE 'TableStyleDark1'. "#EC NOTEXT + CONSTANTS builtinstyle_dark2 TYPE yecb_table_style VALUE 'TableStyleDark2'. "#EC NOTEXT + CONSTANTS builtinstyle_dark3 TYPE yecb_table_style VALUE 'TableStyleDark3'. "#EC NOTEXT + CONSTANTS builtinstyle_dark4 TYPE yecb_table_style VALUE 'TableStyleDark4'. "#EC NOTEXT + CONSTANTS builtinstyle_dark5 TYPE yecb_table_style VALUE 'TableStyleDark5'. "#EC NOTEXT + CONSTANTS builtinstyle_dark6 TYPE yecb_table_style VALUE 'TableStyleDark6'. "#EC NOTEXT + CONSTANTS builtinstyle_dark7 TYPE yecb_table_style VALUE 'TableStyleDark7'. "#EC NOTEXT + CONSTANTS builtinstyle_dark8 TYPE yecb_table_style VALUE 'TableStyleDark8'. "#EC NOTEXT + CONSTANTS builtinstyle_dark9 TYPE yecb_table_style VALUE 'TableStyleDark9'. "#EC NOTEXT + CONSTANTS builtinstyle_dark10 TYPE yecb_table_style VALUE 'TableStyleDark10'. "#EC NOTEXT + CONSTANTS builtinstyle_dark11 TYPE yecb_table_style VALUE 'TableStyleDark11'. "#EC NOTEXT + CONSTANTS builtinstyle_light1 TYPE yecb_table_style VALUE 'TableStyleLight1'. "#EC NOTEXT + CONSTANTS builtinstyle_light2 TYPE yecb_table_style VALUE 'TableStyleLight2'. "#EC NOTEXT + CONSTANTS builtinstyle_light3 TYPE yecb_table_style VALUE 'TableStyleLight3'. "#EC NOTEXT + CONSTANTS builtinstyle_light4 TYPE yecb_table_style VALUE 'TableStyleLight4'. "#EC NOTEXT + CONSTANTS builtinstyle_light5 TYPE yecb_table_style VALUE 'TableStyleLight5'. "#EC NOTEXT + CONSTANTS builtinstyle_pivot_light16 TYPE yecb_table_style VALUE 'PivotStyleLight16'. "#EC NOTEXT + CONSTANTS builtinstyle_light6 TYPE yecb_table_style VALUE 'TableStyleLight6'. "#EC NOTEXT + CONSTANTS totals_function_average TYPE yecb_table_totals_function VALUE 'average'. "#EC NOTEXT + CONSTANTS builtinstyle_light7 TYPE yecb_table_style VALUE 'TableStyleLight7'. "#EC NOTEXT + CONSTANTS totals_function_count TYPE yecb_table_totals_function VALUE 'count'. "#EC NOTEXT + CONSTANTS builtinstyle_light8 TYPE yecb_table_style VALUE 'TableStyleLight8'. "#EC NOTEXT + CONSTANTS totals_function_custom TYPE yecb_table_totals_function VALUE 'custom'. "#EC NOTEXT + CONSTANTS builtinstyle_light9 TYPE yecb_table_style VALUE 'TableStyleLight9'. "#EC NOTEXT + CONSTANTS totals_function_max TYPE yecb_table_totals_function VALUE 'max'. "#EC NOTEXT + CONSTANTS builtinstyle_light10 TYPE yecb_table_style VALUE 'TableStyleLight10'. "#EC NOTEXT + CONSTANTS totals_function_min TYPE yecb_table_totals_function VALUE 'min'. "#EC NOTEXT + CONSTANTS builtinstyle_light11 TYPE yecb_table_style VALUE 'TableStyleLight11'. "#EC NOTEXT + CONSTANTS totals_function_sum TYPE yecb_table_totals_function VALUE 'sum'. "#EC NOTEXT + CONSTANTS builtinstyle_light12 TYPE yecb_table_style VALUE 'TableStyleLight12'. "#EC NOTEXT + DATA fieldcat TYPE yecb_t_fieldcatalog . + CONSTANTS builtinstyle_light13 TYPE yecb_table_style VALUE 'TableStyleLight13'. "#EC NOTEXT + CONSTANTS builtinstyle_light14 TYPE yecb_table_style VALUE 'TableStyleLight14'. "#EC NOTEXT + DATA settings TYPE yecb_s_table_settings . + CONSTANTS builtinstyle_light15 TYPE yecb_table_style VALUE 'TableStyleLight15'. "#EC NOTEXT + CONSTANTS builtinstyle_light16 TYPE yecb_table_style VALUE 'TableStyleLight16'. "#EC NOTEXT + CONSTANTS builtinstyle_light17 TYPE yecb_table_style VALUE 'TableStyleLight17'. "#EC NOTEXT + CONSTANTS builtinstyle_light18 TYPE yecb_table_style VALUE 'TableStyleLight18'. "#EC NOTEXT + CONSTANTS builtinstyle_light19 TYPE yecb_table_style VALUE 'TableStyleLight19'. "#EC NOTEXT + CONSTANTS builtinstyle_light20 TYPE yecb_table_style VALUE 'TableStyleLight20'. "#EC NOTEXT + CONSTANTS builtinstyle_light21 TYPE yecb_table_style VALUE 'TableStyleLight21'. "#EC NOTEXT + CONSTANTS builtinstyle_medium1 TYPE yecb_table_style VALUE 'TableStyleMedium1'. "#EC NOTEXT + CONSTANTS builtinstyle_medium2 TYPE yecb_table_style VALUE 'TableStyleMedium2'. "#EC NOTEXT + CONSTANTS builtinstyle_medium3 TYPE yecb_table_style VALUE 'TableStyleMedium3'. "#EC NOTEXT + CONSTANTS builtinstyle_medium4 TYPE yecb_table_style VALUE 'TableStyleMedium4'. "#EC NOTEXT + CONSTANTS builtinstyle_medium5 TYPE yecb_table_style VALUE 'TableStyleMedium5'. "#EC NOTEXT + CONSTANTS builtinstyle_medium6 TYPE yecb_table_style VALUE 'TableStyleMedium6'. "#EC NOTEXT + CONSTANTS builtinstyle_medium7 TYPE yecb_table_style VALUE 'TableStyleMedium7'. "#EC NOTEXT + CONSTANTS builtinstyle_medium8 TYPE yecb_table_style VALUE 'TableStyleMedium8'. "#EC NOTEXT + CONSTANTS builtinstyle_medium9 TYPE yecb_table_style VALUE 'TableStyleMedium9'. "#EC NOTEXT + CONSTANTS builtinstyle_medium10 TYPE yecb_table_style VALUE 'TableStyleMedium10'. "#EC NOTEXT + CONSTANTS builtinstyle_medium11 TYPE yecb_table_style VALUE 'TableStyleMedium11'. "#EC NOTEXT + CONSTANTS builtinstyle_medium12 TYPE yecb_table_style VALUE 'TableStyleMedium12'. "#EC NOTEXT + CONSTANTS builtinstyle_medium13 TYPE yecb_table_style VALUE 'TableStyleMedium13'. "#EC NOTEXT + CONSTANTS builtinstyle_medium14 TYPE yecb_table_style VALUE 'TableStyleMedium14'. "#EC NOTEXT + CONSTANTS builtinstyle_medium15 TYPE yecb_table_style VALUE 'TableStyleMedium15'. "#EC NOTEXT + CONSTANTS builtinstyle_medium16 TYPE yecb_table_style VALUE 'TableStyleMedium16'. "#EC NOTEXT + CONSTANTS builtinstyle_medium17 TYPE yecb_table_style VALUE 'TableStyleMedium17'. "#EC NOTEXT + CONSTANTS builtinstyle_medium18 TYPE yecb_table_style VALUE 'TableStyleMedium18'. "#EC NOTEXT + CONSTANTS builtinstyle_medium19 TYPE yecb_table_style VALUE 'TableStyleMedium19'. "#EC NOTEXT + CONSTANTS builtinstyle_medium20 TYPE yecb_table_style VALUE 'TableStyleMedium20'. "#EC NOTEXT + CONSTANTS builtinstyle_medium21 TYPE yecb_table_style VALUE 'TableStyleMedium21'. "#EC NOTEXT + CONSTANTS builtinstyle_medium22 TYPE yecb_table_style VALUE 'TableStyleMedium22'. "#EC NOTEXT + CONSTANTS builtinstyle_medium23 TYPE yecb_table_style VALUE 'TableStyleMedium23'. "#EC NOTEXT + CONSTANTS builtinstyle_medium24 TYPE yecb_table_style VALUE 'TableStyleMedium24'. "#EC NOTEXT + CONSTANTS builtinstyle_medium25 TYPE yecb_table_style VALUE 'TableStyleMedium26'. "#EC NOTEXT + CONSTANTS builtinstyle_medium27 TYPE yecb_table_style VALUE 'TableStyleMedium27'. "#EC NOTEXT + + METHODS get_totals_formula + IMPORTING + !ip_column TYPE clike + !ip_function TYPE yecb_table_totals_function + RETURNING + VALUE(ep_formula) TYPE string + RAISING + ycx_ecb . + METHODS has_totals + RETURNING + VALUE(ep_result) TYPE abap_bool . + METHODS set_data + IMPORTING + !ir_data TYPE STANDARD TABLE . + METHODS get_id + RETURNING + VALUE(ov_id) TYPE i . + METHODS set_id + IMPORTING + !iv_id TYPE i . + METHODS get_name + RETURNING + VALUE(ov_name) TYPE string . + METHODS get_reference + IMPORTING + !ip_include_totals_row TYPE abap_bool DEFAULT abap_true + RETURNING + VALUE(ov_reference) TYPE string + RAISING + ycx_ecb . + METHODS get_bottom_row_integer + RETURNING + VALUE(ev_row) TYPE i . + METHODS get_right_column_integer + RETURNING + VALUE(ev_column) TYPE i + RAISING + ycx_ecb . +*"* protected components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_TABLE +*"* do not include other source files here!!! + PROTECTED SECTION. + PRIVATE SECTION. + + DATA id TYPE i . + DATA name TYPE string . + DATA table_data TYPE REF TO data . + DATA builtinstyle_medium28 TYPE yecb_table_style VALUE 'TableStyleMedium28'. "#EC NOTEXT . . . " . +ENDCLASS. + + + +CLASS ycl_ecb_table IMPLEMENTATION. + + + METHOD get_bottom_row_integer. + DATA: lv_table_lines TYPE i. + FIELD-SYMBOLS: TYPE STANDARD TABLE. + + IF settings-bottom_right_row IS NOT INITIAL. +* ev_row = zcl_excel_common=>convert_column2int( settings-bottom_right_row ). " del issue #246 + ev_row = settings-bottom_right_row . " ins issue #246 + RETURN. + ENDIF. + + ASSIGN table_data->* TO . + DESCRIBE TABLE LINES lv_table_lines. + IF lv_table_lines = 0. + lv_table_lines = 1. "table needs at least 1 data row + ENDIF. + + ev_row = settings-top_left_row + lv_table_lines. + + IF me->has_totals( ) = abap_true." ???? AND ip_include_totals_row = abap_true. + ADD 1 TO ev_row. + ENDIF. + ENDMETHOD. + + + METHOD get_id. + ov_id = id. + ENDMETHOD. + + + METHOD get_name. + + IF me->name IS INITIAL. + me->name = ycl_ecb_common=>number_to_excel_string( ip_value = me->id ). + CONCATENATE 'table' me->name INTO me->name. + ENDIF. + + ov_name = me->name. + ENDMETHOD. + + + METHOD get_reference. + DATA: lv_column TYPE yecb_cell_column, + lv_table_lines TYPE i, + lv_right_column TYPE yecb_cell_column_alpha, + ls_field_catalog TYPE yecb_s_fieldcatalog, + lv_bottom_row TYPE yecb_cell_row, + lv_top_row_string(10) TYPE c, + lv_bottom_row_string(10) TYPE c. + + FIELD-SYMBOLS: TYPE STANDARD TABLE. + +*column + lv_column = ycl_ecb_common=>convert_column2int( settings-top_left_column ). + lv_table_lines = 0. + LOOP AT fieldcat INTO ls_field_catalog WHERE dynpfld EQ abap_true. + ADD 1 TO lv_table_lines. + ENDLOOP. + lv_column = lv_column + lv_table_lines - 1. + lv_right_column = ycl_ecb_common=>convert_column2alpha( lv_column ). + +*row + ASSIGN table_data->* TO . + DESCRIBE TABLE LINES lv_table_lines. + IF lv_table_lines = 0. + lv_table_lines = 1. "table needs at least 1 data row + ENDIF. + lv_bottom_row = settings-top_left_row + lv_table_lines . + + IF me->has_totals( ) = abap_true AND ip_include_totals_row = abap_true. + ADD 1 TO lv_bottom_row. + ENDIF. + + lv_top_row_string = ycl_ecb_common=>number_to_excel_string( settings-top_left_row ). + lv_bottom_row_string = ycl_ecb_common=>number_to_excel_string( lv_bottom_row ). + + CONCATENATE settings-top_left_column lv_top_row_string + ':' + lv_right_column lv_bottom_row_string INTO ov_reference. + + ENDMETHOD. + + + METHOD get_right_column_integer. + DATA: ls_field_catalog TYPE yecb_s_fieldcatalog. + + IF settings-bottom_right_column IS NOT INITIAL. + ev_column = ycl_ecb_common=>convert_column2int( settings-bottom_right_column ). + RETURN. + ENDIF. + + ev_column = ycl_ecb_common=>convert_column2int( settings-top_left_column ). + LOOP AT fieldcat INTO ls_field_catalog WHERE dynpfld EQ abap_true. + ADD 1 TO ev_column. + ENDLOOP. + + ENDMETHOD. + + + METHOD get_totals_formula. + CONSTANTS: lc_function_id_sum TYPE string VALUE '109', + lc_function_id_min TYPE string VALUE '105', + lc_function_id_max TYPE string VALUE '104', + lc_function_id_count TYPE string VALUE '103', + lc_function_id_average TYPE string VALUE '101'. + + DATA: lv_function_id TYPE string. + + CASE ip_function. + WHEN ycl_ecb_table=>totals_function_sum. + lv_function_id = lc_function_id_sum. + + WHEN ycl_ecb_table=>totals_function_min. + lv_function_id = lc_function_id_min. + + WHEN ycl_ecb_table=>totals_function_max. + lv_function_id = lc_function_id_max. + + WHEN ycl_ecb_table=>totals_function_count. + lv_function_id = lc_function_id_count. + + WHEN ycl_ecb_table=>totals_function_average. + lv_function_id = lc_function_id_average. + + WHEN ycl_ecb_table=>totals_function_custom. " issue #292 + RETURN. + + WHEN OTHERS. + ycx_ecb=>raise_text( 'Invalid totals formula. See ZCL_ for possible values' ). + ENDCASE. + + CONCATENATE 'SUBTOTAL(' lv_function_id ',[' ip_column '])' INTO ep_formula. + ENDMETHOD. + + + METHOD has_totals. + DATA: ls_field_catalog TYPE yecb_s_fieldcatalog. + + ep_result = abap_false. + + LOOP AT fieldcat INTO ls_field_catalog. + IF ls_field_catalog-totals_function IS NOT INITIAL. + ep_result = abap_true. + EXIT. + ENDIF. + ENDLOOP. + + ENDMETHOD. + + + METHOD set_data. + + DATA lr_temp TYPE REF TO data. + + FIELD-SYMBOLS: TYPE ANY TABLE, + TYPE ANY TABLE. + + GET REFERENCE OF ir_data INTO lr_temp. + ASSIGN lr_temp->* TO . + CREATE DATA table_data LIKE . + ASSIGN me->table_data->* TO . + = . + + ENDMETHOD. + + + METHOD set_id. + id = iv_id. + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_table.clas.xml b/src/abap2xlsx/ycl_ecb_table.clas.xml new file mode 100644 index 0000000..063243c --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_table.clas.xml @@ -0,0 +1,573 @@ + + + + + + YCL_ECB_TABLE + E + Represents Excel Table + 1 + X + X + X + + + + BUILTINSTYLE_DARK1 + E + Built in table style + + + BUILTINSTYLE_DARK1 + I + Built in table style + + + BUILTINSTYLE_DARK10 + E + Built in table style + + + BUILTINSTYLE_DARK11 + E + Built in table style + + + BUILTINSTYLE_DARK2 + E + Built in table style + + + BUILTINSTYLE_DARK2 + I + Built in table style + + + BUILTINSTYLE_DARK3 + E + Built in table style + + + BUILTINSTYLE_DARK3 + I + Built in table style + + + BUILTINSTYLE_DARK4 + E + Built in table style + + + BUILTINSTYLE_DARK4 + I + Built in table style + + + BUILTINSTYLE_DARK5 + E + Built in table style + + + BUILTINSTYLE_DARK5 + I + Built in table style + + + BUILTINSTYLE_DARK6 + E + Built in table style + + + BUILTINSTYLE_DARK7 + E + Built in table style + + + BUILTINSTYLE_DARK8 + E + Built in table style + + + BUILTINSTYLE_DARK9 + E + Built in table style + + + BUILTINSTYLE_LIGHT1 + E + Built in table style + + + BUILTINSTYLE_LIGHT1 + I + Built in table style + + + BUILTINSTYLE_LIGHT10 + E + Built in table style + + + BUILTINSTYLE_LIGHT11 + E + Built in table style + + + BUILTINSTYLE_LIGHT12 + E + Built in table style + + + BUILTINSTYLE_LIGHT13 + E + Built in table style + + + BUILTINSTYLE_LIGHT14 + E + Built in table style + + + BUILTINSTYLE_LIGHT15 + E + Built in table style + + + BUILTINSTYLE_LIGHT16 + E + Built in table style + + + BUILTINSTYLE_LIGHT17 + E + Built in table style + + + BUILTINSTYLE_LIGHT18 + E + Built in table style + + + BUILTINSTYLE_LIGHT19 + E + Built in table style + + + BUILTINSTYLE_LIGHT2 + E + Built in table style + + + BUILTINSTYLE_LIGHT2 + I + Built in table style + + + BUILTINSTYLE_LIGHT20 + E + Built in table style + + + BUILTINSTYLE_LIGHT21 + E + Built in table style + + + BUILTINSTYLE_LIGHT3 + E + Built in table style + + + BUILTINSTYLE_LIGHT3 + I + Built in table style + + + BUILTINSTYLE_LIGHT4 + E + Built in table style + + + BUILTINSTYLE_LIGHT4 + I + Built in table style + + + BUILTINSTYLE_LIGHT5 + E + Built in table style + + + BUILTINSTYLE_LIGHT5 + I + Built in table style + + + BUILTINSTYLE_LIGHT6 + E + Built in table style + + + BUILTINSTYLE_LIGHT7 + E + Built in table style + + + BUILTINSTYLE_LIGHT8 + E + Built in table style + + + BUILTINSTYLE_LIGHT9 + E + Built in table style + + + BUILTINSTYLE_MEDIUM1 + E + Built in table style + + + BUILTINSTYLE_MEDIUM1 + I + Built in table style + + + BUILTINSTYLE_MEDIUM10 + E + Built in table style + + + BUILTINSTYLE_MEDIUM11 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM12 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM13 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM14 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM15 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM16 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM17 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM18 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM19 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM2 + E + Built in table style + + + BUILTINSTYLE_MEDIUM2 + I + Built in table style + + + BUILTINSTYLE_MEDIUM20 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM21 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM22 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM23 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM24 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM25 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM27 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM28 + E + Built in table styel + + + BUILTINSTYLE_MEDIUM3 + E + Built in table style + + + BUILTINSTYLE_MEDIUM3 + I + Built in table style + + + BUILTINSTYLE_MEDIUM4 + E + Built in table style + + + BUILTINSTYLE_MEDIUM4 + I + Built in table style + + + BUILTINSTYLE_MEDIUM5 + E + Built in table style + + + BUILTINSTYLE_MEDIUM5 + I + Built in table style + + + BUILTINSTYLE_MEDIUM6 + E + Built in table style + + + BUILTINSTYLE_MEDIUM7 + E + Built in table style + + + BUILTINSTYLE_MEDIUM8 + E + Built in table style + + + BUILTINSTYLE_MEDIUM9 + E + Built in table style + + + BUILTINSTYLE_MEDIUM9 + I + Built in table style + + + BUILTINSTYLE_PIVOT_LIGHT16 + E + Built in table style + + + BUILTINSTYLE_PIVOT_LIGHT16 + I + Built in table style + + + FIELDCAT + E + field catalog + + + FIELDCAT + I + field catalog + + + GET_ID + E + Gets the ID + + + GET_ID + I + Gets the ID + + + GET_NAME + E + Gets the name + + + GET_NAME + I + Gets the name + + + GET_TOTALS_FORMULA + E + Returns formula for totals row based on column name and fun + + + GET_TOTALS_FORMULA + I + Returns formula for totals row based on column name and fun + + + HAS_TOTALS + E + Determines if any column has totals function + + + HAS_TOTALS + I + Determines if any column has totals function + + + ID + E + Table ID + + + ID + I + Table ID + + + NAME + E + A string representing the name of the table + + + NAME + I + A string representing the name of the table + + + SETTINGS + E + table settings + + + SETTINGS + I + table settings + + + SET_DATA + E + Sets the reference to table data + + + SET_DATA + I + Sets the reference to table data + + + SET_ID + E + Sets the ID + + + SET_ID + I + Sets the ID + + + TABLE_DATA + E + Ref to data + + + TABLE_DATA + I + Ref to data + + + TOTALS_FUNCTION_AVERAGE + E + Totals function + + + TOTALS_FUNCTION_AVERAGE + I + Totals function + + + TOTALS_FUNCTION_COUNT + E + Totals function + + + TOTALS_FUNCTION_COUNT + I + Totals function + + + TOTALS_FUNCTION_CUSTOM + E + Totals function + + + TOTALS_FUNCTION_CUSTOM + I + Totals function + + + TOTALS_FUNCTION_MAX + E + Totals function + + + TOTALS_FUNCTION_MAX + I + Totals function + + + TOTALS_FUNCTION_MIN + E + Totals function + + + TOTALS_FUNCTION_MIN + I + Totals function + + + TOTALS_FUNCTION_SUM + E + Totals function + + + TOTALS_FUNCTION_SUM + I + Totals function + + + + + diff --git a/src/abap2xlsx/ycl_ecb_template_data.clas.abap b/src/abap2xlsx/ycl_ecb_template_data.clas.abap new file mode 100644 index 0000000..a0c3cd2 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_template_data.clas.abap @@ -0,0 +1,42 @@ +CLASS ycl_ecb_template_data DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: tt_sheet_titles TYPE STANDARD TABLE OF yecb_sheet_title WITH DEFAULT KEY, + BEGIN OF ts_template_data_sheet, + sheet TYPE yecb_sheet_title, + data TYPE REF TO data, + END OF ts_template_data_sheet, + tt_template_data_sheets TYPE STANDARD TABLE OF ts_template_data_sheet WITH DEFAULT KEY. + + DATA mt_data TYPE tt_template_data_sheets READ-ONLY. + + METHODS add + IMPORTING + iv_sheet TYPE yecb_sheet_title + iv_data TYPE data . + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_template_data IMPLEMENTATION. + + + METHOD add. + FIELD-SYMBOLS: TYPE ts_template_data_sheet, + TYPE any. + + APPEND INITIAL LINE TO mt_data ASSIGNING . + -sheet = iv_sheet. + CREATE DATA -data LIKE iv_data. + + ASSIGN -data->* TO . + = iv_data. + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_template_data.clas.xml b/src/abap2xlsx/ycl_ecb_template_data.clas.xml new file mode 100644 index 0000000..a45eb41 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_template_data.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_TEMPLATE_DATA + E + Data for template + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme.clas.abap b/src/abap2xlsx/ycl_ecb_theme.clas.abap new file mode 100644 index 0000000..f45d14a --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme.clas.abap @@ -0,0 +1,233 @@ +CLASS ycl_ecb_theme DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + + CONSTANTS c_theme_elements TYPE string VALUE 'themeElements'. "#EC NOTEXT + CONSTANTS c_theme_object_def TYPE string VALUE 'objectDefaults'. "#EC NOTEXT + CONSTANTS c_theme_extra_color TYPE string VALUE 'extraClrSchemeLst'. "#EC NOTEXT + CONSTANTS c_theme_extlst TYPE string VALUE 'extLst'. "#EC NOTEXT + CONSTANTS c_theme TYPE string VALUE 'theme'. "#EC NOTEXT + CONSTANTS c_theme_name TYPE string VALUE 'name'. "#EC NOTEXT + CONSTANTS c_theme_xmlns TYPE string VALUE 'xmlns:a'. "#EC NOTEXT + CONSTANTS c_theme_prefix TYPE string VALUE 'a'. "#EC NOTEXT + CONSTANTS c_theme_prefix_write TYPE string VALUE 'a:'. "#EC NOTEXT + CONSTANTS c_theme_xmlns_val TYPE string VALUE 'http://schemas.openxmlformats.org/drawingml/2006/main'. "#EC NOTEXT + + METHODS constructor . + METHODS read_theme + IMPORTING + VALUE(io_theme_xml) TYPE REF TO if_ixml_document . + METHODS write_theme + RETURNING + VALUE(rv_xstring) TYPE xstring . + METHODS set_color + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_srgb) TYPE ycl_ecb_theme_color_scheme=>t_srgb OPTIONAL + VALUE(iv_syscolorname) TYPE string OPTIONAL + VALUE(iv_syscolorlast) TYPE ycl_ecb_theme_color_scheme=>t_srgb OPTIONAL . + METHODS set_color_scheme_name + IMPORTING + iv_name TYPE string . + METHODS set_font + IMPORTING + iv_type TYPE string + iv_script TYPE string + iv_typeface TYPE string . + METHODS set_latin_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + METHODS set_ea_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + METHODS set_cs_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + METHODS set_font_scheme_name + IMPORTING + VALUE(iv_name) TYPE string . + METHODS set_theme_name + IMPORTING + VALUE(iv_name) TYPE string . + PROTECTED SECTION. + + DATA elements TYPE REF TO ycl_ecb_theme_elements . + DATA objectdefaults TYPE REF TO ycl_ecb_theme_objectdefaults . + DATA extclrschemelst TYPE REF TO ycl_ecb_theme_eclrschemelst . + DATA extlst TYPE REF TO ycl_ecb_theme_extlst . + PRIVATE SECTION. + + DATA theme_changed TYPE abap_bool . + DATA theme_read TYPE abap_bool . + DATA name TYPE string . + DATA xmls_a TYPE string . +ENDCLASS. + + + +CLASS ycl_ecb_theme IMPLEMENTATION. + + + METHOD constructor. + CREATE OBJECT elements. + CREATE OBJECT objectdefaults. + CREATE OBJECT extclrschemelst. + CREATE OBJECT extlst. + ENDMETHOD. "class_constructor + + + METHOD read_theme. + DATA: lo_node_theme TYPE REF TO if_ixml_element. + DATA: lo_theme_children TYPE REF TO if_ixml_node_list. + DATA: lo_theme_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_theme_element TYPE REF TO if_ixml_element. + CHECK io_theme_xml IS NOT INITIAL. + + lo_node_theme = io_theme_xml->get_root_element( )." find_from_name( name = c_theme ). + IF lo_node_theme IS BOUND. + name = lo_node_theme->get_attribute( name = c_theme_name ). + xmls_a = lo_node_theme->get_attribute( name = c_theme_xmlns ). + lo_theme_children = lo_node_theme->get_children( ). + lo_theme_iterator = lo_theme_children->create_iterator( ). + lo_theme_element ?= lo_theme_iterator->get_next( ). + WHILE lo_theme_element IS BOUND. + CASE lo_theme_element->get_name( ). + WHEN c_theme_elements. + elements->load( io_elements = lo_theme_element ). + WHEN c_theme_object_def. + objectdefaults->load( io_object_def = lo_theme_element ). + WHEN c_theme_extra_color. + extclrschemelst->load( io_extra_color = lo_theme_element ). + WHEN c_theme_extlst. + extlst->load( io_extlst = lo_theme_element ). + ENDCASE. + lo_theme_element ?= lo_theme_iterator->get_next( ). + ENDWHILE. + ENDIF. + ENDMETHOD. "read_theme + + + METHOD set_color. + elements->color_scheme->set_color( + EXPORTING + iv_type = iv_type + iv_srgb = iv_srgb + iv_syscolorname = iv_syscolorname + iv_syscolorlast = iv_syscolorlast + ). + ENDMETHOD. "set_color + + + METHOD set_color_scheme_name. + elements->color_scheme->set_name( iv_name = iv_name ). + ENDMETHOD. "set_color_scheme_name + + + METHOD set_cs_font. + elements->font_scheme->modify_cs_font( + EXPORTING + iv_type = iv_type + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + ENDMETHOD. "set_cs_font + + + METHOD set_ea_font. + elements->font_scheme->modify_ea_font( + EXPORTING + iv_type = iv_type + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + ENDMETHOD. "set_ea_font + + + METHOD set_font. + elements->font_scheme->modify_font( + EXPORTING + iv_type = iv_type + iv_script = iv_script + iv_typeface = iv_typeface + ). + ENDMETHOD. "set_font + + + METHOD set_font_scheme_name. + elements->font_scheme->set_name( iv_name = iv_name ). + ENDMETHOD. "set_font_scheme_name + + + METHOD set_latin_font. + elements->font_scheme->modify_latin_font( + EXPORTING + iv_type = iv_type + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + ENDMETHOD. "set_latin_font + + + METHOD set_theme_name. + name = iv_name. + ENDMETHOD. + + + METHOD write_theme. + DATA: lo_ixml TYPE REF TO if_ixml, + lo_element_root TYPE REF TO if_ixml_element, + lo_encoding TYPE REF TO if_ixml_encoding. + DATA: lo_streamfactory TYPE REF TO if_ixml_stream_factory. + DATA: lo_ostream TYPE REF TO if_ixml_ostream. + DATA: lo_renderer TYPE REF TO if_ixml_renderer. + DATA: lo_document TYPE REF TO if_ixml_document. + lo_ixml = cl_ixml=>create( ). + + lo_encoding = lo_ixml->create_encoding( byte_order = if_ixml_encoding=>co_platform_endian + character_set = 'UTF-8' ). + lo_document = lo_ixml->create_document( ). + lo_document->set_encoding( lo_encoding ). + lo_document->set_standalone( abap_true ). + lo_document->set_namespace_prefix( prefix = 'a' ). + + lo_element_root = lo_document->create_simple_element_ns( prefix = c_theme_prefix + name = c_theme + parent = lo_document + ). + lo_element_root->set_attribute_ns( name = c_theme_xmlns + value = c_theme_xmlns_val ). + lo_element_root->set_attribute_ns( name = c_theme_name + value = name ). + + elements->build_xml( io_document = lo_document ). + objectdefaults->build_xml( io_document = lo_document ). + extclrschemelst->build_xml( io_document = lo_document ). + extlst->build_xml( io_document = lo_document ). + + lo_streamfactory = lo_ixml->create_stream_factory( ). + lo_ostream = lo_streamfactory->create_ostream_xstring( string = rv_xstring ). + lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). + lo_renderer->render( ). + + ENDMETHOD. "write_theme +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme.clas.xml b/src/abap2xlsx/ycl_ecb_theme.clas.xml new file mode 100644 index 0000000..e296a95 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME + E + Theme + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_color_scheme.clas.abap b/src/abap2xlsx/ycl_ecb_theme_color_scheme.clas.abap new file mode 100644 index 0000000..6e4c801 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_color_scheme.clas.abap @@ -0,0 +1,447 @@ +CLASS ycl_ecb_theme_color_scheme DEFINITION + PUBLIC + FINAL + CREATE PUBLIC + + GLOBAL FRIENDS ycl_ecb_theme + ycl_ecb_theme_elements . + + PUBLIC SECTION. + + TYPES t_srgb TYPE string . + TYPES: + BEGIN OF t_syscolor, + val TYPE string, + lastclr TYPE t_srgb, + END OF t_syscolor . + TYPES: + BEGIN OF t_color, + srgb TYPE t_srgb, + syscolor TYPE t_syscolor, + END OF t_color . + + CONSTANTS c_dark1 TYPE string VALUE 'dk1'. "#EC NOTEXT + CONSTANTS c_dark2 TYPE string VALUE 'dk2'. "#EC NOTEXT + CONSTANTS c_light1 TYPE string VALUE 'lt1'. "#EC NOTEXT + CONSTANTS c_light2 TYPE string VALUE 'lt2'. "#EC NOTEXT + CONSTANTS c_accent1 TYPE string VALUE 'accent1'. "#EC NOTEXT + CONSTANTS c_accent2 TYPE string VALUE 'accent2'. "#EC NOTEXT + CONSTANTS c_accent3 TYPE string VALUE 'accent3'. "#EC NOTEXT + CONSTANTS c_accent4 TYPE string VALUE 'accent4'. "#EC NOTEXT + CONSTANTS c_accent5 TYPE string VALUE 'accent5'. "#EC NOTEXT + CONSTANTS c_accent6 TYPE string VALUE 'accent6'. "#EC NOTEXT + CONSTANTS c_hlink TYPE string VALUE 'hlink'. "#EC NOTEXT + CONSTANTS c_folhlink TYPE string VALUE 'folHlink'. "#EC NOTEXT + CONSTANTS c_syscolor TYPE string VALUE 'sysClr'. "#EC NOTEXT + CONSTANTS c_srgbcolor TYPE string VALUE 'srgbClr'. "#EC NOTEXT + CONSTANTS c_val TYPE string VALUE 'val'. "#EC NOTEXT + CONSTANTS c_lastclr TYPE string VALUE 'lastClr'. "#EC NOTEXT + CONSTANTS c_name TYPE string VALUE 'name'. "#EC NOTEXT + CONSTANTS c_scheme TYPE string VALUE 'clrScheme'. "#EC NOTEXT + + METHODS load + IMPORTING + !io_color_scheme TYPE REF TO if_ixml_element . + METHODS set_color + IMPORTING + iv_type TYPE string + iv_srgb TYPE t_srgb OPTIONAL + iv_syscolorname TYPE string OPTIONAL + iv_syscolorlast TYPE t_srgb . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + METHODS constructor . + METHODS set_name + IMPORTING + VALUE(iv_name) TYPE string . + PROTECTED SECTION. + + DATA name TYPE string . + DATA dark1 TYPE t_color . + DATA dark2 TYPE t_color . + DATA light1 TYPE t_color . + DATA light2 TYPE t_color . + DATA accent1 TYPE t_color . + DATA accent2 TYPE t_color . + DATA accent3 TYPE t_color . + DATA accent4 TYPE t_color . + DATA accent5 TYPE t_color . + DATA accent6 TYPE t_color . + DATA hlink TYPE t_color . + DATA folhlink TYPE t_color . + PRIVATE SECTION. + + METHODS get_color + IMPORTING + !io_object TYPE REF TO if_ixml_element + RETURNING + VALUE(rv_color) TYPE t_color . + METHODS set_defaults . +ENDCLASS. + + + +CLASS ycl_ecb_theme_color_scheme IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_scheme_element TYPE REF TO if_ixml_element. + DATA: lo_color TYPE REF TO if_ixml_element. + DATA: lo_syscolor TYPE REF TO if_ixml_element. + DATA: lo_srgb TYPE REF TO if_ixml_element. + DATA: lo_elements TYPE REF TO if_ixml_element. + + CHECK io_document IS BOUND. + lo_elements ?= io_document->find_from_name_ns( name = ycl_ecb_theme=>c_theme_elements ). + IF lo_elements IS BOUND. + lo_scheme_element ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix + name = ycl_ecb_theme_elements=>c_color_scheme + parent = lo_elements ). + lo_scheme_element->set_attribute( name = c_name value = name ). + + " Adding colors to scheme + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix + name = c_dark1 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF dark1-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = dark1-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = dark1-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = dark1-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_light1 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF light1-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = light1-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = light1-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = light1-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_dark2 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF dark2-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = dark2-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = dark2-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = dark2-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_light2 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF light2-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = light2-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = light2-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = light2-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_accent1 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF accent1-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent1-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent1-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent1-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_accent2 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF accent2-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent2-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent2-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent2-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_accent3 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF accent3-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent3-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent3-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent3-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_accent4 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF accent4-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent4-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent4-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent4-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_accent5 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF accent5-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent5-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent5-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent5-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_accent6 + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF accent6-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = accent6-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = accent6-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = accent6-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_hlink + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF hlink-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = hlink-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = hlink-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = hlink-syscolor-lastclr ). + ENDIF. + CLEAR: lo_color, lo_srgb, lo_syscolor. + ENDIF. + + lo_color ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_folhlink + parent = lo_scheme_element ). + IF lo_color IS BOUND. + IF folhlink-srgb IS NOT INITIAL. + lo_srgb ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_srgbcolor + parent = lo_color ). + lo_srgb->set_attribute( name = c_val value = folhlink-srgb ). + ELSE. + lo_syscolor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_syscolor + parent = lo_color ). + lo_syscolor->set_attribute( name = c_val value = folhlink-syscolor-val ). + lo_syscolor->set_attribute( name = c_lastclr value = folhlink-syscolor-lastclr ). + ENDIF. + ENDIF. + + + ENDIF. + ENDMETHOD. "build_xml + + + METHOD constructor. + set_defaults( ). + ENDMETHOD. "constructor + + + METHOD get_color. + DATA: lo_color_children TYPE REF TO if_ixml_node_list. + DATA: lo_color_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_color_element TYPE REF TO if_ixml_element. + CHECK io_object IS NOT INITIAL. + + lo_color_children = io_object->get_children( ). + lo_color_iterator = lo_color_children->create_iterator( ). + lo_color_element ?= lo_color_iterator->get_next( ). + IF lo_color_element IS BOUND. + CASE lo_color_element->get_name( ). + WHEN c_srgbcolor. + rv_color-srgb = lo_color_element->get_attribute( name = c_val ). + WHEN c_syscolor. + rv_color-syscolor-val = lo_color_element->get_attribute( name = c_val ). + rv_color-syscolor-lastclr = lo_color_element->get_attribute( name = c_lastclr ). + ENDCASE. + ENDIF. + ENDMETHOD. "get_color + + + METHOD load. + DATA: lo_scheme_children TYPE REF TO if_ixml_node_list. + DATA: lo_scheme_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_scheme_element TYPE REF TO if_ixml_element. + CHECK io_color_scheme IS NOT INITIAL. + + name = io_color_scheme->get_attribute( name = c_name ). + lo_scheme_children = io_color_scheme->get_children( ). + lo_scheme_iterator = lo_scheme_children->create_iterator( ). + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + WHILE lo_scheme_element IS BOUND. + CASE lo_scheme_element->get_name( ). + WHEN c_dark1. + dark1 = me->get_color( lo_scheme_element ). + WHEN c_dark2. + dark2 = me->get_color( lo_scheme_element ). + WHEN c_light1. + light1 = me->get_color( lo_scheme_element ). + WHEN c_light2. + light2 = me->get_color( lo_scheme_element ). + WHEN c_accent1. + accent1 = me->get_color( lo_scheme_element ). + WHEN c_accent2. + accent2 = me->get_color( lo_scheme_element ). + WHEN c_accent3. + accent3 = me->get_color( lo_scheme_element ). + WHEN c_accent4. + accent4 = me->get_color( lo_scheme_element ). + WHEN c_accent5. + accent5 = me->get_color( lo_scheme_element ). + WHEN c_accent6. + accent6 = me->get_color( lo_scheme_element ). + WHEN c_hlink. + hlink = me->get_color( lo_scheme_element ). + WHEN c_folhlink. + folhlink = me->get_color( lo_scheme_element ). + ENDCASE. + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + ENDWHILE. + ENDMETHOD. "load + + + METHOD set_color. + FIELD-SYMBOLS: TYPE t_color. + CHECK iv_type IS NOT INITIAL. + CHECK iv_srgb IS NOT INITIAL OR iv_syscolorname IS NOT INITIAL. + CASE iv_type. + WHEN c_dark1. + ASSIGN dark1 TO . + WHEN c_dark2. + ASSIGN dark2 TO . + WHEN c_light1. + ASSIGN light1 TO . + WHEN c_light2. + ASSIGN light2 TO . + WHEN c_accent1. + ASSIGN accent1 TO . + WHEN c_accent2. + ASSIGN accent2 TO . + WHEN c_accent3. + ASSIGN accent3 TO . + WHEN c_accent4. + ASSIGN accent4 TO . + WHEN c_accent5. + ASSIGN accent5 TO . + WHEN c_accent6. + ASSIGN accent6 TO . + WHEN c_hlink. + ASSIGN hlink TO . + WHEN c_folhlink. + ASSIGN folhlink TO . + ENDCASE. + CHECK IS ASSIGNED. + CLEAR . + IF iv_srgb IS NOT INITIAL. + -srgb = iv_srgb. + ELSE. + -syscolor-val = iv_syscolorname. + IF iv_syscolorlast IS NOT INITIAL. + -syscolor-lastclr = iv_syscolorlast. + ELSE. + -syscolor-lastclr = '000000'. + ENDIF. + ENDIF. + ENDMETHOD. "set_color + + + METHOD set_defaults. + name = 'Office'. + dark1-syscolor-val = 'windowText'. + dark1-syscolor-lastclr = '000000'. + light1-syscolor-val = 'window'. + light1-syscolor-lastclr = 'FFFFFF'. + dark2-srgb = '44546A'. + light2-srgb = 'E7E6E6'. + accent1-srgb = '5B9BD5'. + accent2-srgb = 'ED7D31'. + accent3-srgb = 'A5A5A5'. + accent4-srgb = 'FFC000'. + accent5-srgb = '4472C4'. + accent6-srgb = '70AD47'. + hlink-srgb = '0563C1'. + folhlink-srgb = '954F72'. + ENDMETHOD. "set_defaults + + + METHOD set_name. + IF strlen( iv_name ) > 50. + name = iv_name(50). + ELSE. + name = iv_name. + ENDIF. + ENDMETHOD. "set_name +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_color_scheme.clas.xml b/src/abap2xlsx/ycl_ecb_theme_color_scheme.clas.xml new file mode 100644 index 0000000..aabefaa --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_color_scheme.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME_COLOR_SCHEME + E + Theme Color Scheme + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_eclrschemelst.clas.abap b/src/abap2xlsx/ycl_ecb_theme_eclrschemelst.clas.abap new file mode 100644 index 0000000..978225e --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_eclrschemelst.clas.abap @@ -0,0 +1,46 @@ +CLASS ycl_ecb_theme_eclrschemelst DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS load + IMPORTING + !io_extra_color TYPE REF TO if_ixml_element . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + PROTECTED SECTION. + PRIVATE SECTION. + + DATA extracolor TYPE REF TO if_ixml_element . +ENDCLASS. + + + +CLASS ycl_ecb_theme_eclrschemelst IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_theme TYPE REF TO if_ixml_element. + DATA: lo_theme_objdef TYPE REF TO if_ixml_element. + CHECK io_document IS BOUND. + lo_theme ?= io_document->get_root_element( ). + CHECK lo_theme IS BOUND. + IF extracolor IS INITIAL. + lo_theme_objdef ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix + name = ycl_ecb_theme=>c_theme_extra_color + parent = lo_theme ). + + ELSE. + lo_theme->append_child( new_child = extracolor ). + ENDIF. + + ENDMETHOD. "build_xml + + + METHOD load. + extracolor = ycl_ecb_common=>clone_ixml_with_namespaces( io_extra_color ). + ENDMETHOD. "load +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_eclrschemelst.clas.xml b/src/abap2xlsx/ycl_ecb_theme_eclrschemelst.clas.xml new file mode 100644 index 0000000..956d1f8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_eclrschemelst.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME_ECLRSCHEMELST + E + Theme Extra Color Scheme List + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_elements.clas.abap b/src/abap2xlsx/ycl_ecb_theme_elements.clas.abap new file mode 100644 index 0000000..d096da4 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_elements.clas.abap @@ -0,0 +1,80 @@ +CLASS ycl_ecb_theme_elements DEFINITION + PUBLIC + FINAL + CREATE PUBLIC + + GLOBAL FRIENDS ycl_ecb_theme . + + PUBLIC SECTION. + + CONSTANTS c_color_scheme TYPE string VALUE 'clrScheme'. "#EC NOTEXT + CONSTANTS c_font_scheme TYPE string VALUE 'fontScheme'. "#EC NOTEXT + CONSTANTS c_fmt_scheme TYPE string VALUE 'fmtScheme'. "#EC NOTEXT + CONSTANTS c_theme_elements TYPE string VALUE 'themeElements'. "#EC NOTEXT + + METHODS constructor . + METHODS load + IMPORTING + !io_elements TYPE REF TO if_ixml_element . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + PROTECTED SECTION. + + DATA color_scheme TYPE REF TO ycl_ecb_theme_color_scheme . + DATA font_scheme TYPE REF TO ycl_ecb_theme_font_scheme . + DATA fmt_scheme TYPE REF TO ycl_ecb_theme_fmt_scheme . + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ycl_ecb_theme_elements IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_theme_element TYPE REF TO if_ixml_element. + DATA: lo_theme TYPE REF TO if_ixml_element. + CHECK io_document IS BOUND. + lo_theme ?= io_document->get_root_element( ). + IF lo_theme IS BOUND. + lo_theme_element ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix + name = c_theme_elements + parent = lo_theme ). + + color_scheme->build_xml( io_document = io_document ). + font_scheme->build_xml( io_document = io_document ). + fmt_scheme->build_xml( io_document = io_document ). + ENDIF. + ENDMETHOD. + + + METHOD constructor. + CREATE OBJECT color_scheme. + CREATE OBJECT font_scheme. + CREATE OBJECT fmt_scheme. + ENDMETHOD. "constructor + + + METHOD load. + DATA: lo_elements_children TYPE REF TO if_ixml_node_list. + DATA: lo_elements_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_elements_element TYPE REF TO if_ixml_element. + CHECK io_elements IS NOT INITIAL. + + lo_elements_children = io_elements->get_children( ). + lo_elements_iterator = lo_elements_children->create_iterator( ). + lo_elements_element ?= lo_elements_iterator->get_next( ). + WHILE lo_elements_element IS BOUND. + CASE lo_elements_element->get_name( ). + WHEN c_color_scheme. + color_scheme->load( io_color_scheme = lo_elements_element ). + WHEN c_font_scheme. + font_scheme->load( io_font_scheme = lo_elements_element ). + WHEN c_fmt_scheme. + fmt_scheme->load( io_fmt_scheme = lo_elements_element ). + ENDCASE. + lo_elements_element ?= lo_elements_iterator->get_next( ). + ENDWHILE. + ENDMETHOD. "load +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_elements.clas.xml b/src/abap2xlsx/ycl_ecb_theme_elements.clas.xml new file mode 100644 index 0000000..edc596f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_elements.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME_ELEMENTS + E + Theme Elements + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_extlst.clas.abap b/src/abap2xlsx/ycl_ecb_theme_extlst.clas.abap new file mode 100644 index 0000000..55f3d6f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_extlst.clas.abap @@ -0,0 +1,46 @@ +CLASS ycl_ecb_theme_extlst DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS load + IMPORTING + !io_extlst TYPE REF TO if_ixml_element . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + PROTECTED SECTION. + PRIVATE SECTION. + + DATA extlst TYPE REF TO if_ixml_element . +ENDCLASS. + + + +CLASS ycl_ecb_theme_extlst IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_theme TYPE REF TO if_ixml_element. + DATA: lo_theme_objdef TYPE REF TO if_ixml_element. + CHECK io_document IS BOUND. + + lo_theme ?= io_document->get_root_element( ). + CHECK lo_theme IS BOUND. + IF extlst IS INITIAL. + lo_theme_objdef ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix + name = ycl_ecb_theme=>c_theme_extlst + parent = lo_theme ). + + ELSE. + lo_theme->append_child( new_child = extlst ). + ENDIF. + ENDMETHOD. "build_xml + + + METHOD load. + extlst = ycl_ecb_common=>clone_ixml_with_namespaces( io_extlst ). + ENDMETHOD. "load +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_extlst.clas.xml b/src/abap2xlsx/ycl_ecb_theme_extlst.clas.xml new file mode 100644 index 0000000..836f381 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_extlst.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME_EXTLST + E + Theme Ext List + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.abap b/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.abap new file mode 100644 index 0000000..d9c761f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.abap @@ -0,0 +1,219 @@ +CLASS ycl_ecb_theme_fmt_scheme DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS load + IMPORTING + !io_fmt_scheme TYPE REF TO if_ixml_element . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + PROTECTED SECTION. + PRIVATE SECTION. + + DATA fmt_scheme TYPE REF TO if_ixml_element . + + METHODS get_default_fmt + RETURNING + VALUE(rv_string) TYPE string . + + METHODS parse_string + IMPORTING iv_string TYPE string + RETURNING VALUE(ri_node) TYPE REF TO if_ixml_node. +ENDCLASS. + + + +CLASS ycl_ecb_theme_fmt_scheme IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_node TYPE REF TO if_ixml_node. + DATA: lo_elements TYPE REF TO if_ixml_element. + CHECK io_document IS BOUND. + lo_elements ?= io_document->find_from_name_ns( name = ycl_ecb_theme=>c_theme_elements ). + IF lo_elements IS BOUND. + + IF fmt_scheme IS INITIAL. + lo_node = parse_string( get_default_fmt( ) ). + lo_elements->append_child( new_child = lo_node ). + ELSE. + lo_elements->append_child( new_child = fmt_scheme ). + ENDIF. + ENDIF. + ENDMETHOD. "build_xml + + + METHOD get_default_fmt. + CONCATENATE '' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + INTO rv_string . + ENDMETHOD. "get_default_fmt + + + METHOD load. + fmt_scheme = ycl_ecb_common=>clone_ixml_with_namespaces( io_fmt_scheme ). + ENDMETHOD. "load + + + METHOD parse_string. + DATA li_stream TYPE REF TO if_ixml_istream. + DATA li_ixml TYPE REF TO if_ixml. + DATA li_document TYPE REF TO if_ixml_document. + DATA li_factory TYPE REF TO if_ixml_stream_factory. + DATA li_parser TYPE REF TO if_ixml_parser. + DATA li_istream TYPE REF TO if_ixml_istream. + + li_ixml = cl_ixml=>create( ). + li_document = li_ixml->create_document( ). + li_factory = li_ixml->create_stream_factory( ). + li_istream = li_factory->create_istream_string( iv_string ). + li_parser = li_ixml->create_parser( + stream_factory = li_factory + istream = li_istream + document = li_document ). + li_parser->add_strip_space_element( ). + li_parser->parse( ). + li_istream->close( ). + ri_node = li_document->get_first_child( ). + + ENDMETHOD. +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.testclasses.abap b/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.testclasses.abap new file mode 100644 index 0000000..d090386 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.testclasses.abap @@ -0,0 +1,54 @@ +CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. + PRIVATE SECTION. + METHODS build_xml FOR TESTING. + + DATA mi_ixml TYPE REF TO if_ixml. + DATA mi_document TYPE REF TO if_ixml_document. + METHODS setup. + METHODS render + RETURNING + VALUE(rv_xml) TYPE string. +ENDCLASS. + + +CLASS ltcl_test IMPLEMENTATION. + + METHOD setup. + mi_ixml = cl_ixml=>create( ). + mi_document = mi_ixml->create_document( ). + ENDMETHOD. + + METHOD render. + DATA li_ostream TYPE REF TO if_ixml_ostream. + DATA li_renderer TYPE REF TO if_ixml_renderer. + DATA li_factory TYPE REF TO if_ixml_stream_factory. + + li_factory = mi_ixml->create_stream_factory( ). + li_ostream = li_factory->create_ostream_cstring( rv_xml ). + li_renderer = mi_ixml->create_renderer( + ostream = li_ostream + document = mi_document ). + li_renderer->render( ). + ENDMETHOD. + + METHOD build_xml. + DATA lo_theme_fmt TYPE REF TO ycl_ecb_theme_fmt_scheme. + DATA li_ixml TYPE REF TO if_ixml. + DATA li_document TYPE REF TO if_ixml_document. + DATA lv_xml TYPE string. + + mi_document->create_simple_element( + name = ycl_ecb_theme=>c_theme_elements + parent = mi_document ). + + CREATE OBJECT lo_theme_fmt. + lo_theme_fmt->build_xml( mi_document ). + + lv_xml = render( ). + + cl_abap_unit_assert=>assert_char_cp( + act = lv_xml + exp = '**' ). + ENDMETHOD. + +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.xml b/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.xml new file mode 100644 index 0000000..d723bc8 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_fmt_scheme.clas.xml @@ -0,0 +1,17 @@ + + + + + + YCL_ECB_THEME_FMT_SCHEME + E + Theme FMT Scheme + 1 + X + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_font_scheme.clas.abap b/src/abap2xlsx/ycl_ecb_theme_font_scheme.clas.abap new file mode 100644 index 0000000..9c32d9f --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_font_scheme.clas.abap @@ -0,0 +1,504 @@ +CLASS ycl_ecb_theme_font_scheme DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: + BEGIN OF t_font, + script TYPE string, + typeface TYPE string, + END OF t_font . + TYPES: + tt_font TYPE SORTED TABLE OF t_font WITH UNIQUE KEY script . + TYPES: + BEGIN OF t_fonttype, + typeface TYPE string, + panose TYPE string, + pitchfamily TYPE string, + charset TYPE string, + END OF t_fonttype . + TYPES: + BEGIN OF t_fonts, + latin TYPE t_fonttype, + ea TYPE t_fonttype, + cs TYPE t_fonttype, + fonts TYPE tt_font, + END OF t_fonts . + TYPES: + BEGIN OF t_scheme, + name TYPE string, + major TYPE t_fonts, + minor TYPE t_fonts, + END OF t_scheme . + + CONSTANTS c_name TYPE string VALUE 'name'. "#EC NOTEXT + CONSTANTS c_scheme TYPE string VALUE 'fontScheme'. "#EC NOTEXT + CONSTANTS c_major TYPE string VALUE 'majorFont'. "#EC NOTEXT + CONSTANTS c_minor TYPE string VALUE 'minorFont'. "#EC NOTEXT + CONSTANTS c_font TYPE string VALUE 'font'. "#EC NOTEXT + CONSTANTS c_latin TYPE string VALUE 'latin'. "#EC NOTEXT + CONSTANTS c_ea TYPE string VALUE 'ea'. "#EC NOTEXT + CONSTANTS c_cs TYPE string VALUE 'cs'. "#EC NOTEXT + CONSTANTS c_typeface TYPE string VALUE 'typeface'. "#EC NOTEXT + CONSTANTS c_panose TYPE string VALUE 'panose'. "#EC NOTEXT + CONSTANTS c_pitchfamily TYPE string VALUE 'pitchFamily'. "#EC NOTEXT + CONSTANTS c_charset TYPE string VALUE 'charset'. "#EC NOTEXT + CONSTANTS c_script TYPE string VALUE 'script'. "#EC NOTEXT + + METHODS load + IMPORTING + !io_font_scheme TYPE REF TO if_ixml_element . + METHODS set_name + IMPORTING + iv_name TYPE string . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + METHODS modify_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_script) TYPE string + VALUE(iv_typeface) TYPE string . + METHODS modify_latin_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + METHODS modify_ea_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + METHODS modify_cs_font + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + METHODS constructor . + PROTECTED SECTION. + + METHODS modify_lec_fonts + IMPORTING + VALUE(iv_type) TYPE string + VALUE(iv_font_type) TYPE string + VALUE(iv_typeface) TYPE string + VALUE(iv_panose) TYPE string OPTIONAL + VALUE(iv_pitchfamily) TYPE string OPTIONAL + VALUE(iv_charset) TYPE string OPTIONAL . + PRIVATE SECTION. + + DATA font_scheme TYPE t_scheme . + + METHODS set_defaults . +ENDCLASS. + + + +CLASS ycl_ecb_theme_font_scheme IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_scheme_element TYPE REF TO if_ixml_element. + DATA: lo_font TYPE REF TO if_ixml_element. + DATA: lo_latin TYPE REF TO if_ixml_element. + DATA: lo_ea TYPE REF TO if_ixml_element. + DATA: lo_cs TYPE REF TO if_ixml_element. + DATA: lo_major TYPE REF TO if_ixml_element. + DATA: lo_minor TYPE REF TO if_ixml_element. + DATA: lo_elements TYPE REF TO if_ixml_element. + FIELD-SYMBOLS: TYPE t_font. + CHECK io_document IS BOUND. + lo_elements ?= io_document->find_from_name_ns( name = ycl_ecb_theme=>c_theme_elements ). + IF lo_elements IS BOUND. + lo_scheme_element ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = ycl_ecb_theme_elements=>c_font_scheme + parent = lo_elements ). + lo_scheme_element->set_attribute( name = c_name value = font_scheme-name ). + + lo_major ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_major + parent = lo_scheme_element ). + IF lo_major IS BOUND. + lo_latin ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_latin + parent = lo_major ). + lo_latin->set_attribute( name = c_typeface value = font_scheme-major-latin-typeface ). + IF font_scheme-major-latin-panose IS NOT INITIAL. + lo_latin->set_attribute( name = c_panose value = font_scheme-major-latin-panose ). + ENDIF. + IF font_scheme-major-latin-pitchfamily IS NOT INITIAL. + lo_latin->set_attribute( name = c_pitchfamily value = font_scheme-major-latin-pitchfamily ). + ENDIF. + IF font_scheme-major-latin-charset IS NOT INITIAL. + lo_latin->set_attribute( name = c_charset value = font_scheme-major-latin-charset ). + ENDIF. + + lo_ea ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_ea + parent = lo_major ). + lo_ea->set_attribute( name = c_typeface value = font_scheme-major-ea-typeface ). + IF font_scheme-major-ea-panose IS NOT INITIAL. + lo_ea->set_attribute( name = c_panose value = font_scheme-major-ea-panose ). + ENDIF. + IF font_scheme-major-ea-pitchfamily IS NOT INITIAL. + lo_ea->set_attribute( name = c_pitchfamily value = font_scheme-major-ea-pitchfamily ). + ENDIF. + IF font_scheme-major-ea-charset IS NOT INITIAL. + lo_ea->set_attribute( name = c_charset value = font_scheme-major-ea-charset ). + ENDIF. + + lo_cs ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_cs + parent = lo_major ). + lo_cs->set_attribute( name = c_typeface value = font_scheme-major-cs-typeface ). + IF font_scheme-major-cs-panose IS NOT INITIAL. + lo_cs->set_attribute( name = c_panose value = font_scheme-major-cs-panose ). + ENDIF. + IF font_scheme-major-cs-pitchfamily IS NOT INITIAL. + lo_cs->set_attribute( name = c_pitchfamily value = font_scheme-major-cs-pitchfamily ). + ENDIF. + IF font_scheme-major-cs-charset IS NOT INITIAL. + lo_cs->set_attribute( name = c_charset value = font_scheme-major-cs-charset ). + ENDIF. + + LOOP AT font_scheme-major-fonts ASSIGNING . + IF -script IS NOT INITIAL AND -typeface IS NOT INITIAL. + CLEAR lo_font. + lo_font ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_font + parent = lo_major ). + lo_font->set_attribute( name = c_script value = -script ). + lo_font->set_attribute( name = c_typeface value = -typeface ). + ENDIF. + ENDLOOP. + CLEAR: lo_latin, lo_ea, lo_cs, lo_font. + ENDIF. + + lo_minor ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_minor + parent = lo_scheme_element ). + IF lo_minor IS BOUND. + lo_latin ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_latin + parent = lo_minor ). + lo_latin->set_attribute( name = c_typeface value = font_scheme-minor-latin-typeface ). + IF font_scheme-minor-latin-panose IS NOT INITIAL. + lo_latin->set_attribute( name = c_panose value = font_scheme-minor-latin-panose ). + ENDIF. + IF font_scheme-minor-latin-pitchfamily IS NOT INITIAL. + lo_latin->set_attribute( name = c_pitchfamily value = font_scheme-minor-latin-pitchfamily ). + ENDIF. + IF font_scheme-minor-latin-charset IS NOT INITIAL. + lo_latin->set_attribute( name = c_charset value = font_scheme-minor-latin-charset ). + ENDIF. + + lo_ea ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_ea + parent = lo_minor ). + lo_ea->set_attribute( name = c_typeface value = font_scheme-minor-ea-typeface ). + IF font_scheme-minor-ea-panose IS NOT INITIAL. + lo_ea->set_attribute( name = c_panose value = font_scheme-minor-ea-panose ). + ENDIF. + IF font_scheme-minor-ea-pitchfamily IS NOT INITIAL. + lo_ea->set_attribute( name = c_pitchfamily value = font_scheme-minor-ea-pitchfamily ). + ENDIF. + IF font_scheme-minor-ea-charset IS NOT INITIAL. + lo_ea->set_attribute( name = c_charset value = font_scheme-minor-ea-charset ). + ENDIF. + + lo_cs ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_cs + parent = lo_minor ). + lo_cs->set_attribute( name = c_typeface value = font_scheme-minor-cs-typeface ). + IF font_scheme-minor-cs-panose IS NOT INITIAL. + lo_cs->set_attribute( name = c_panose value = font_scheme-minor-cs-panose ). + ENDIF. + IF font_scheme-minor-cs-pitchfamily IS NOT INITIAL. + lo_cs->set_attribute( name = c_pitchfamily value = font_scheme-minor-cs-pitchfamily ). + ENDIF. + IF font_scheme-minor-cs-charset IS NOT INITIAL. + lo_cs->set_attribute( name = c_charset value = font_scheme-minor-cs-charset ). + ENDIF. + + LOOP AT font_scheme-minor-fonts ASSIGNING . + IF -script IS NOT INITIAL AND -typeface IS NOT INITIAL. + CLEAR lo_font. + lo_font ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix name = c_font + parent = lo_minor ). + lo_font->set_attribute( name = c_script value = -script ). + lo_font->set_attribute( name = c_typeface value = -typeface ). + ENDIF. + ENDLOOP. + ENDIF. + + + ENDIF. + ENDMETHOD. "build_xml + + + METHOD constructor. + set_defaults( ). + ENDMETHOD. "constructor + + + METHOD load. + DATA: lo_scheme_children TYPE REF TO if_ixml_node_list. + DATA: lo_scheme_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_scheme_element TYPE REF TO if_ixml_element. + DATA: lo_major_children TYPE REF TO if_ixml_node_list. + DATA: lo_major_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_major_element TYPE REF TO if_ixml_element. + DATA: lo_minor_children TYPE REF TO if_ixml_node_list. + DATA: lo_minor_iterator TYPE REF TO if_ixml_node_iterator. + DATA: lo_minor_element TYPE REF TO if_ixml_element. + DATA: ls_font TYPE t_font. + CHECK io_font_scheme IS NOT INITIAL. + CLEAR font_scheme. + font_scheme-name = io_font_scheme->get_attribute( name = c_name ). + lo_scheme_children = io_font_scheme->get_children( ). + lo_scheme_iterator = lo_scheme_children->create_iterator( ). + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + WHILE lo_scheme_element IS BOUND. + CASE lo_scheme_element->get_name( ). + WHEN c_major. + lo_major_children = lo_scheme_element->get_children( ). + lo_major_iterator = lo_major_children->create_iterator( ). + lo_major_element ?= lo_major_iterator->get_next( ). + WHILE lo_major_element IS BOUND. + CASE lo_major_element->get_name( ). + WHEN c_latin. + font_scheme-major-latin-typeface = lo_major_element->get_attribute( name = c_typeface ). + font_scheme-major-latin-panose = lo_major_element->get_attribute( name = c_panose ). + font_scheme-major-latin-pitchfamily = lo_major_element->get_attribute( name = c_pitchfamily ). + font_scheme-major-latin-charset = lo_major_element->get_attribute( name = c_charset ). + WHEN c_ea. + font_scheme-major-ea-typeface = lo_major_element->get_attribute( name = c_typeface ). + font_scheme-major-ea-panose = lo_major_element->get_attribute( name = c_panose ). + font_scheme-major-ea-pitchfamily = lo_major_element->get_attribute( name = c_pitchfamily ). + font_scheme-major-ea-charset = lo_major_element->get_attribute( name = c_charset ). + WHEN c_cs. + font_scheme-major-cs-typeface = lo_major_element->get_attribute( name = c_typeface ). + font_scheme-major-cs-panose = lo_major_element->get_attribute( name = c_panose ). + font_scheme-major-cs-pitchfamily = lo_major_element->get_attribute( name = c_pitchfamily ). + font_scheme-major-cs-charset = lo_major_element->get_attribute( name = c_charset ). + WHEN c_font. + CLEAR ls_font. + ls_font-script = lo_major_element->get_attribute( name = c_script ). + ls_font-typeface = lo_major_element->get_attribute( name = c_typeface ). + TRY. + INSERT ls_font INTO TABLE font_scheme-major-fonts. + CATCH cx_root. "not the best but just to avoid duplicate lines dump + + ENDTRY. + ENDCASE. + lo_major_element ?= lo_major_iterator->get_next( ). + ENDWHILE. + WHEN c_minor. + lo_minor_children = lo_scheme_element->get_children( ). + lo_minor_iterator = lo_minor_children->create_iterator( ). + lo_minor_element ?= lo_minor_iterator->get_next( ). + WHILE lo_minor_element IS BOUND. + CASE lo_minor_element->get_name( ). + WHEN c_latin. + font_scheme-minor-latin-typeface = lo_minor_element->get_attribute( name = c_typeface ). + font_scheme-minor-latin-panose = lo_minor_element->get_attribute( name = c_panose ). + font_scheme-minor-latin-pitchfamily = lo_minor_element->get_attribute( name = c_pitchfamily ). + font_scheme-minor-latin-charset = lo_minor_element->get_attribute( name = c_charset ). + WHEN c_ea. + font_scheme-minor-ea-typeface = lo_minor_element->get_attribute( name = c_typeface ). + font_scheme-minor-ea-panose = lo_minor_element->get_attribute( name = c_panose ). + font_scheme-minor-ea-pitchfamily = lo_minor_element->get_attribute( name = c_pitchfamily ). + font_scheme-minor-ea-charset = lo_minor_element->get_attribute( name = c_charset ). + WHEN c_cs. + font_scheme-minor-cs-typeface = lo_minor_element->get_attribute( name = c_typeface ). + font_scheme-minor-cs-panose = lo_minor_element->get_attribute( name = c_panose ). + font_scheme-minor-cs-pitchfamily = lo_minor_element->get_attribute( name = c_pitchfamily ). + font_scheme-minor-cs-charset = lo_minor_element->get_attribute( name = c_charset ). + WHEN c_font. + CLEAR ls_font. + ls_font-script = lo_minor_element->get_attribute( name = c_script ). + ls_font-typeface = lo_minor_element->get_attribute( name = c_typeface ). + TRY. + INSERT ls_font INTO TABLE font_scheme-minor-fonts. + CATCH cx_root. "not the best but just to avoid duplicate lines dump + + ENDTRY. + ENDCASE. + lo_minor_element ?= lo_minor_iterator->get_next( ). + ENDWHILE. + ENDCASE. + lo_scheme_element ?= lo_scheme_iterator->get_next( ). + ENDWHILE. + ENDMETHOD. "load + + + METHOD modify_cs_font. + modify_lec_fonts( + EXPORTING + iv_type = iv_type + iv_font_type = c_cs + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + ENDMETHOD. "modify_latin_font + + + METHOD modify_ea_font. + modify_lec_fonts( + EXPORTING + iv_type = iv_type + iv_font_type = c_ea + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + ENDMETHOD. "modify_latin_font + + + METHOD modify_font. + DATA: ls_font TYPE t_font. + FIELD-SYMBOLS: TYPE t_font. + ls_font-script = iv_script. + ls_font-typeface = iv_typeface. + TRY. + CASE iv_type. + WHEN c_major. + READ TABLE font_scheme-major-fonts WITH KEY script = iv_script ASSIGNING . + IF sy-subrc EQ 0. + = ls_font. + ELSE. + INSERT ls_font INTO TABLE font_scheme-major-fonts. + ENDIF. + WHEN c_minor. + READ TABLE font_scheme-minor-fonts WITH KEY script = iv_script ASSIGNING . + IF sy-subrc EQ 0. + = ls_font. + ELSE. + INSERT ls_font INTO TABLE font_scheme-minor-fonts. + ENDIF. + ENDCASE. + CATCH cx_root. "not the best but just to avoid duplicate lines dump + ENDTRY. + ENDMETHOD. "add_font + + + METHOD modify_latin_font. + modify_lec_fonts( + EXPORTING + iv_type = iv_type + iv_font_type = c_latin + iv_typeface = iv_typeface + iv_panose = iv_panose + iv_pitchfamily = iv_pitchfamily + iv_charset = iv_charset + ). + ENDMETHOD. "modify_latin_font + + + METHOD modify_lec_fonts. + FIELD-SYMBOLS: TYPE t_fonts, + TYPE t_fonttype. + CASE iv_type. + WHEN c_minor. + ASSIGN font_scheme-minor TO . + WHEN c_major. + ASSIGN font_scheme-major TO . + WHEN OTHERS. + RETURN. + ENDCASE. + CHECK IS ASSIGNED. + CASE iv_font_type. + WHEN c_latin. + ASSIGN -latin TO . + WHEN c_ea. + ASSIGN -ea TO . + WHEN c_cs. + ASSIGN -cs TO . + WHEN OTHERS. + RETURN. + ENDCASE. + CHECK IS ASSIGNED. + -typeface = iv_typeface. + -panose = iv_panose. + -pitchfamily = iv_pitchfamily. + -charset = iv_charset. + ENDMETHOD. "modify_lec_fonts + + + METHOD set_defaults. + CLEAR font_scheme. + font_scheme-name = 'Office'. + font_scheme-major-latin-typeface = 'Calibri Light'. + font_scheme-major-latin-panose = '020F0302020204030204'. + modify_font( iv_type = c_major iv_script = 'Jpan' iv_typeface = 'MS Pゴシック' ). + modify_font( iv_type = c_major iv_script = 'Hang' iv_typeface = '맑은 고딕' ). + modify_font( iv_type = c_major iv_script = 'Hans' iv_typeface = '宋体' ). + modify_font( iv_type = c_major iv_script = 'Hant' iv_typeface = '新細明體' ). + modify_font( iv_type = c_major iv_script = 'Arab' iv_typeface = 'Times New Roman' ). + modify_font( iv_type = c_major iv_script = 'Hebr' iv_typeface = 'Times New Roman' ). + modify_font( iv_type = c_major iv_script = 'Thai' iv_typeface = 'Tahoma' ). + modify_font( iv_type = c_major iv_script = 'Ethi' iv_typeface = 'Nyala' ). + modify_font( iv_type = c_major iv_script = 'Beng' iv_typeface = 'Vrinda' ). + modify_font( iv_type = c_major iv_script = 'Gujr' iv_typeface = 'Shruti' ). + modify_font( iv_type = c_major iv_script = 'Khmr' iv_typeface = 'MoolBoran' ). + modify_font( iv_type = c_major iv_script = 'Knda' iv_typeface = 'Tunga' ). + modify_font( iv_type = c_major iv_script = 'Guru' iv_typeface = 'Raavi' ). + modify_font( iv_type = c_major iv_script = 'Cans' iv_typeface = 'Euphemia' ). + modify_font( iv_type = c_major iv_script = 'Cher' iv_typeface = 'Plantagenet Cherokee' ). + modify_font( iv_type = c_major iv_script = 'Yiii' iv_typeface = 'Microsoft Yi Baiti' ). + modify_font( iv_type = c_major iv_script = 'Tibt' iv_typeface = 'Microsoft Himalaya' ). + modify_font( iv_type = c_major iv_script = 'Thaa' iv_typeface = 'MV Boli' ). + modify_font( iv_type = c_major iv_script = 'Deva' iv_typeface = 'Mangal' ). + modify_font( iv_type = c_major iv_script = 'Telu' iv_typeface = 'Gautami' ). + modify_font( iv_type = c_major iv_script = 'Taml' iv_typeface = 'Latha' ). + modify_font( iv_type = c_major iv_script = 'Syrc' iv_typeface = 'Estrangelo Edessa' ). + modify_font( iv_type = c_major iv_script = 'Orya' iv_typeface = 'Kalinga' ). + modify_font( iv_type = c_major iv_script = 'Mlym' iv_typeface = 'Kartika' ). + modify_font( iv_type = c_major iv_script = 'Laoo' iv_typeface = 'DokChampa' ). + modify_font( iv_type = c_major iv_script = 'Sinh' iv_typeface = 'Iskoola Pota' ). + modify_font( iv_type = c_major iv_script = 'Mong' iv_typeface = 'Mongolian Baiti' ). + modify_font( iv_type = c_major iv_script = 'Viet' iv_typeface = 'Times New Roman' ). + modify_font( iv_type = c_major iv_script = 'Uigh' iv_typeface = 'Microsoft Uighur' ). + modify_font( iv_type = c_major iv_script = 'Geor' iv_typeface = 'Sylfaen' ). + + font_scheme-minor-latin-typeface = 'Calibri'. + font_scheme-minor-latin-panose = '020F0502020204030204'. + modify_font( iv_type = c_minor iv_script = 'Jpan' iv_typeface = 'MS Pゴシック' ). + modify_font( iv_type = c_minor iv_script = 'Hang' iv_typeface = '맑은 고딕' ). + modify_font( iv_type = c_minor iv_script = 'Hans' iv_typeface = '宋体' ). + modify_font( iv_type = c_minor iv_script = 'Hant' iv_typeface = '新細明體' ). + modify_font( iv_type = c_minor iv_script = 'Arab' iv_typeface = 'Arial' ). + modify_font( iv_type = c_minor iv_script = 'Hebr' iv_typeface = 'Arial' ). + modify_font( iv_type = c_minor iv_script = 'Thai' iv_typeface = 'Tahoma' ). + modify_font( iv_type = c_minor iv_script = 'Ethi' iv_typeface = 'Nyala' ). + modify_font( iv_type = c_minor iv_script = 'Beng' iv_typeface = 'Vrinda' ). + modify_font( iv_type = c_minor iv_script = 'Gujr' iv_typeface = 'Shruti' ). + modify_font( iv_type = c_minor iv_script = 'Khmr' iv_typeface = 'DaunPenh' ). + modify_font( iv_type = c_minor iv_script = 'Knda' iv_typeface = 'Tunga' ). + modify_font( iv_type = c_minor iv_script = 'Guru' iv_typeface = 'Raavi' ). + modify_font( iv_type = c_minor iv_script = 'Cans' iv_typeface = 'Euphemia' ). + modify_font( iv_type = c_minor iv_script = 'Cher' iv_typeface = 'Plantagenet Cherokee' ). + modify_font( iv_type = c_minor iv_script = 'Yiii' iv_typeface = 'Microsoft Yi Baiti' ). + modify_font( iv_type = c_minor iv_script = 'Tibt' iv_typeface = 'Microsoft Himalaya' ). + modify_font( iv_type = c_minor iv_script = 'Thaa' iv_typeface = 'MV Boli' ). + modify_font( iv_type = c_minor iv_script = 'Deva' iv_typeface = 'Mangal' ). + modify_font( iv_type = c_minor iv_script = 'Telu' iv_typeface = 'Gautami' ). + modify_font( iv_type = c_minor iv_script = 'Taml' iv_typeface = 'Latha' ). + modify_font( iv_type = c_minor iv_script = 'Syrc' iv_typeface = 'Estrangelo Edessa' ). + modify_font( iv_type = c_minor iv_script = 'Orya' iv_typeface = 'Kalinga' ). + modify_font( iv_type = c_minor iv_script = 'Mlym' iv_typeface = 'Kartika' ). + modify_font( iv_type = c_minor iv_script = 'Laoo' iv_typeface = 'DokChampa' ). + modify_font( iv_type = c_minor iv_script = 'Sinh' iv_typeface = 'Iskoola Pota' ). + modify_font( iv_type = c_minor iv_script = 'Mong' iv_typeface = 'Mongolian Baiti' ). + modify_font( iv_type = c_minor iv_script = 'Viet' iv_typeface = 'Arial' ). + modify_font( iv_type = c_minor iv_script = 'Uigh' iv_typeface = 'Microsoft Uighur' ). + modify_font( iv_type = c_minor iv_script = 'Geor' iv_typeface = 'Sylfaen' ). + + ENDMETHOD. "set_defaults + + + METHOD set_name. + font_scheme-name = iv_name. + ENDMETHOD. "set_name +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_font_scheme.clas.xml b/src/abap2xlsx/ycl_ecb_theme_font_scheme.clas.xml new file mode 100644 index 0000000..9215c92 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_font_scheme.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME_FONT_SCHEME + E + Theme Font Scheme + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_theme_objectdefaults.clas.abap b/src/abap2xlsx/ycl_ecb_theme_objectdefaults.clas.abap new file mode 100644 index 0000000..1eb24d3 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_objectdefaults.clas.abap @@ -0,0 +1,44 @@ +CLASS ycl_ecb_theme_objectdefaults DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + METHODS load + IMPORTING + !io_object_def TYPE REF TO if_ixml_element . + METHODS build_xml + IMPORTING + !io_document TYPE REF TO if_ixml_document . + PROTECTED SECTION. + PRIVATE SECTION. + + DATA objectdefaults TYPE REF TO if_ixml_element . +ENDCLASS. + + + +CLASS ycl_ecb_theme_objectdefaults IMPLEMENTATION. + + + METHOD build_xml. + DATA: lo_theme TYPE REF TO if_ixml_element. + DATA: lo_theme_objdef TYPE REF TO if_ixml_element. + CHECK io_document IS BOUND. + lo_theme ?= io_document->get_root_element( ). + CHECK lo_theme IS BOUND. + IF objectdefaults IS INITIAL. + lo_theme_objdef ?= io_document->create_simple_element_ns( prefix = ycl_ecb_theme=>c_theme_prefix + name = ycl_ecb_theme=>c_theme_object_def + parent = lo_theme ). + ELSE. + lo_theme->append_child( new_child = objectdefaults ). + ENDIF. + ENDMETHOD. "build_xml + + + METHOD load. + objectdefaults = ycl_ecb_common=>clone_ixml_with_namespaces( io_object_def ). + ENDMETHOD. "load +ENDCLASS. diff --git a/src/abap2xlsx/ycl_ecb_theme_objectdefaults.clas.xml b/src/abap2xlsx/ycl_ecb_theme_objectdefaults.clas.xml new file mode 100644 index 0000000..8344e48 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_theme_objectdefaults.clas.xml @@ -0,0 +1,16 @@ + + + + + + YCL_ECB_THEME_OBJECTDEFAULTS + E + Theme Object Defaults + 1 + X + X + X + + + + diff --git a/src/abap2xlsx/ycl_ecb_worksheet.clas.abap b/src/abap2xlsx/ycl_ecb_worksheet.clas.abap new file mode 100644 index 0000000..d82f509 --- /dev/null +++ b/src/abap2xlsx/ycl_ecb_worksheet.clas.abap @@ -0,0 +1,4789 @@ +CLASS ycl_ecb_worksheet DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. +*"* public components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! +*"* protected components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! + + INTERFACES yif_ecb_sheet_printsettings . + INTERFACES yif_ecb_sheet_properties . + INTERFACES yif_ecb_sheet_protection . + INTERFACES yif_ecb_sheet_vba_project . + + TYPES: + BEGIN OF mty_s_outline_row, + row_from TYPE i, + row_to TYPE i, + collapsed TYPE abap_bool, + END OF mty_s_outline_row . + TYPES: + mty_ts_outlines_row TYPE SORTED TABLE OF mty_s_outline_row WITH UNIQUE KEY row_from row_to . + TYPES: + BEGIN OF mty_s_ignored_errors, + "! Cell reference (e.g. "A1") or list like "A1 A2" or range "A1:G1" + cell_coords TYPE yecb_cell_coords, + "! Ignore errors when cells contain formulas that result in an error. + eval_error TYPE abap_bool, + "! Ignore errors when formulas contain text formatted cells with years represented as 2 digits. + two_digit_text_year TYPE abap_bool, + "! Ignore errors when numbers are formatted as text or are preceded by an apostrophe. + number_stored_as_text TYPE abap_bool, + "! Ignore errors when a formula in a region of your WorkSheet differs from other formulas in the same region. + formula TYPE abap_bool, + "! Ignore errors when formulas omit certain cells in a region. + formula_range TYPE abap_bool, + "! Ignore errors when unlocked cells contain formulas. + unlocked_formula TYPE abap_bool, + "! Ignore errors when formulas refer to empty cells. + empty_cell_reference TYPE abap_bool, + "! Ignore errors when a cell's value in a Table does not comply with the Data Validation rules specified. + list_data_validation TYPE abap_bool, + "! Ignore errors when cells contain a value different from a calculated column formula. + "! In other words, for a calculated column, a cell in that column is considered to have an error + "! if its formula is different from the calculated column formula, or doesn't contain a formula at all. + calculated_column TYPE abap_bool, + END OF mty_s_ignored_errors . + TYPES: + mty_th_ignored_errors TYPE HASHED TABLE OF mty_s_ignored_errors WITH UNIQUE KEY cell_coords . + TYPES: + BEGIN OF mty_s_column_formula, + id TYPE i, + column TYPE yecb_cell_column, + formula TYPE string, + table_top_left_row TYPE yecb_cell_row, + table_bottom_right_row TYPE yecb_cell_row, + table_left_column_int TYPE yecb_cell_column, + table_right_column_int TYPE yecb_cell_column, + END OF mty_s_column_formula . + TYPES: + mty_th_column_formula + TYPE HASHED TABLE OF mty_s_column_formula + WITH UNIQUE KEY id . + TYPES: + ty_doc_url TYPE c LENGTH 255 . + TYPES: + BEGIN OF mty_merge, + row_from TYPE i, + row_to TYPE i, + col_from TYPE i, + col_to TYPE i, + END OF mty_merge . + TYPES: + mty_ts_merge TYPE SORTED TABLE OF mty_merge WITH UNIQUE KEY table_line . + TYPES: + ty_area TYPE c LENGTH 1 . + + CONSTANTS c_break_column TYPE yecb_break VALUE 2 ##NO_TEXT. + CONSTANTS c_break_none TYPE yecb_break VALUE 0 ##NO_TEXT. + CONSTANTS c_break_row TYPE yecb_break VALUE 1 ##NO_TEXT. + CONSTANTS: + BEGIN OF c_area, + whole TYPE ty_area VALUE 'W', "#EC NOTEXT + topleft TYPE ty_area VALUE 'T', "#EC NOTEXT + END OF c_area . + DATA excel TYPE REF TO ycl_ecb READ-ONLY . + DATA print_gridlines TYPE yecb_print_gridlines READ-ONLY VALUE abap_false ##NO_TEXT. + DATA sheet_content TYPE yecb_t_cell_data . + DATA sheet_setup TYPE REF TO ycl_ecb_sheet_setup . + DATA show_gridlines TYPE yecb_show_gridlines READ-ONLY VALUE abap_true ##NO_TEXT. + DATA show_rowcolheaders TYPE yecb_show_gridlines READ-ONLY VALUE abap_true ##NO_TEXT. + DATA tabcolor TYPE yecb_s_tabcolor READ-ONLY . + DATA column_formulas TYPE mty_th_column_formula READ-ONLY . + CLASS-DATA: + BEGIN OF c_messages READ-ONLY, + formula_id_only_is_possible TYPE string, + column_formula_id_not_found TYPE string, + formula_not_in_this_table TYPE string, + formula_in_other_column TYPE string, + END OF c_messages . + DATA mt_merged_cells TYPE mty_ts_merge READ-ONLY . + + METHODS add_comment + IMPORTING + !ip_comment TYPE REF TO ycl_ecb_comment . + METHODS add_drawing + IMPORTING + !ip_drawing TYPE REF TO ycl_ecb_drawing . + METHODS add_new_column + IMPORTING + !ip_column TYPE simple + RETURNING + VALUE(eo_column) TYPE REF TO ycl_ecb_column + RAISING + ycx_ecb . + METHODS add_new_style_cond + IMPORTING + !ip_dimension_range TYPE string DEFAULT 'A1' + RETURNING + VALUE(eo_style_cond) TYPE REF TO ycl_ecb_style_cond . + METHODS add_new_data_validation + RETURNING + VALUE(eo_data_validation) TYPE REF TO ycl_ecb_data_validation . + METHODS add_new_range + RETURNING + VALUE(eo_range) TYPE REF TO ycl_ecb_range . + METHODS add_new_row + IMPORTING + !ip_row TYPE simple + RETURNING + VALUE(eo_row) TYPE REF TO ycl_ecb_row . + METHODS bind_alv + IMPORTING + !io_alv TYPE REF TO object + !it_table TYPE STANDARD TABLE + !i_top TYPE i DEFAULT 1 + !i_left TYPE i DEFAULT 1 + !table_style TYPE yecb_table_style OPTIONAL + !i_table TYPE abap_bool DEFAULT abap_true + RAISING + ycx_ecb . + METHODS bind_alv_ole2 + IMPORTING + !i_document_url TYPE ty_doc_url DEFAULT space + !i_xls TYPE c DEFAULT space + !i_save_path TYPE string + !io_alv TYPE REF TO cl_gui_alv_grid + !it_listheader TYPE slis_t_listheader OPTIONAL + !i_top TYPE i DEFAULT 1 + !i_left TYPE i DEFAULT 1 + !i_columns_header TYPE c DEFAULT 'X' + !i_columns_autofit TYPE c DEFAULT 'X' + !i_format_col_header TYPE soi_format_item OPTIONAL + !i_format_subtotal TYPE soi_format_item OPTIONAL + !i_format_total TYPE soi_format_item OPTIONAL + EXCEPTIONS + miss_guide + ex_transfer_kkblo_error + fatal_error + inv_data_range + dim_mismatch_vkey + dim_mismatch_sema + error_in_sema . + METHODS bind_table + IMPORTING + !ip_table TYPE STANDARD TABLE + !it_field_catalog TYPE yecb_t_fieldcatalog OPTIONAL + !is_table_settings TYPE yecb_s_table_settings OPTIONAL + VALUE(iv_default_descr) TYPE c OPTIONAL + !iv_no_line_if_empty TYPE abap_bool DEFAULT abap_false + !ip_conv_exit_length TYPE abap_bool DEFAULT abap_false + !ip_conv_curr_amt_ext TYPE abap_bool DEFAULT abap_false + EXPORTING + !es_table_settings TYPE yecb_s_table_settings + RAISING + ycx_ecb . + METHODS calculate_column_widths + RAISING + ycx_ecb . + METHODS change_area_style + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_style_changer TYPE REF TO yif_ecb_style_changer + RAISING + ycx_ecb . + METHODS change_cell_style + IMPORTING + !ip_columnrow TYPE csequence OPTIONAL + !ip_column TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_complete TYPE yecb_s_cstyle_complete OPTIONAL + !ip_xcomplete TYPE yecb_s_cstylex_complete OPTIONAL + !ip_font TYPE yecb_s_cstyle_font OPTIONAL + !ip_xfont TYPE yecb_s_cstylex_font OPTIONAL + !ip_fill TYPE yecb_s_cstyle_fill OPTIONAL + !ip_xfill TYPE yecb_s_cstylex_fill OPTIONAL + !ip_borders TYPE yecb_s_cstyle_borders OPTIONAL + !ip_xborders TYPE yecb_s_cstylex_borders OPTIONAL + !ip_alignment TYPE yecb_s_cstyle_alignment OPTIONAL + !ip_xalignment TYPE yecb_s_cstylex_alignment OPTIONAL + !ip_number_format_format_code TYPE yecb_number_format OPTIONAL + !ip_protection TYPE yecb_s_cstyle_protection OPTIONAL + !ip_xprotection TYPE yecb_s_cstylex_protection OPTIONAL + !ip_font_bold TYPE flag OPTIONAL + !ip_font_color TYPE yecb_s_style_color OPTIONAL + !ip_font_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_font_color_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_font_color_theme TYPE yecb_style_color_theme OPTIONAL + !ip_font_color_tint TYPE yecb_style_color_tint OPTIONAL + !ip_font_family TYPE yecb_style_font_family OPTIONAL + !ip_font_italic TYPE flag OPTIONAL + !ip_font_name TYPE yecb_style_font_name OPTIONAL + !ip_font_scheme TYPE yecb_style_font_scheme OPTIONAL + !ip_font_size TYPE yecb_style_font_size OPTIONAL + !ip_font_strikethrough TYPE flag OPTIONAL + !ip_font_underline TYPE flag OPTIONAL + !ip_font_underline_mode TYPE yecb_style_font_underline OPTIONAL + !ip_fill_filltype TYPE yecb_fill_type OPTIONAL + !ip_fill_rotation TYPE yecb_rotation OPTIONAL + !ip_fill_fgcolor TYPE yecb_s_style_color OPTIONAL + !ip_fill_fgcolor_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_fill_fgcolor_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_fill_fgcolor_theme TYPE yecb_style_color_theme OPTIONAL + !ip_fill_fgcolor_tint TYPE yecb_style_color_tint OPTIONAL + !ip_fill_bgcolor TYPE yecb_s_style_color OPTIONAL + !ip_fill_bgcolor_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_fill_bgcolor_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_fill_bgcolor_theme TYPE yecb_style_color_theme OPTIONAL + !ip_fill_bgcolor_tint TYPE yecb_style_color_tint OPTIONAL + !ip_borders_allborders TYPE yecb_s_cstyle_border OPTIONAL + !ip_fill_gradtype_type TYPE yecb_s_gradient_type-type OPTIONAL + !ip_fill_gradtype_degree TYPE yecb_s_gradient_type-degree OPTIONAL + !ip_xborders_allborders TYPE yecb_s_cstylex_border OPTIONAL + !ip_borders_diagonal TYPE yecb_s_cstyle_border OPTIONAL + !ip_fill_gradtype_bottom TYPE yecb_s_gradient_type-bottom OPTIONAL + !ip_fill_gradtype_top TYPE yecb_s_gradient_type-top OPTIONAL + !ip_xborders_diagonal TYPE yecb_s_cstylex_border OPTIONAL + !ip_borders_diagonal_mode TYPE yecb_diagonal OPTIONAL + !ip_fill_gradtype_right TYPE yecb_s_gradient_type-right OPTIONAL + !ip_borders_down TYPE yecb_s_cstyle_border OPTIONAL + !ip_fill_gradtype_left TYPE yecb_s_gradient_type-left OPTIONAL + !ip_fill_gradtype_position1 TYPE yecb_s_gradient_type-position1 OPTIONAL + !ip_xborders_down TYPE yecb_s_cstylex_border OPTIONAL + !ip_borders_left TYPE yecb_s_cstyle_border OPTIONAL + !ip_fill_gradtype_position2 TYPE yecb_s_gradient_type-position2 OPTIONAL + !ip_fill_gradtype_position3 TYPE yecb_s_gradient_type-position3 OPTIONAL + !ip_xborders_left TYPE yecb_s_cstylex_border OPTIONAL + !ip_borders_right TYPE yecb_s_cstyle_border OPTIONAL + !ip_xborders_right TYPE yecb_s_cstylex_border OPTIONAL + !ip_borders_top TYPE yecb_s_cstyle_border OPTIONAL + !ip_xborders_top TYPE yecb_s_cstylex_border OPTIONAL + !ip_alignment_horizontal TYPE yecb_alignment OPTIONAL + !ip_alignment_vertical TYPE yecb_alignment OPTIONAL + !ip_alignment_textrotation TYPE yecb_text_rotation OPTIONAL + !ip_alignment_wraptext TYPE flag OPTIONAL + !ip_alignment_shrinktofit TYPE flag OPTIONAL + !ip_alignment_indent TYPE yecb_indent OPTIONAL + !ip_protection_hidden TYPE yecb_cell_protection OPTIONAL + !ip_protection_locked TYPE yecb_cell_protection OPTIONAL + !ip_borders_allborders_style TYPE yecb_border OPTIONAL + !ip_borders_allborders_color TYPE yecb_s_style_color OPTIONAL + !ip_borders_allbo_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_borders_allbo_color_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_borders_allbo_color_theme TYPE yecb_style_color_theme OPTIONAL + !ip_borders_allbo_color_tint TYPE yecb_style_color_tint OPTIONAL + !ip_borders_diagonal_style TYPE yecb_border OPTIONAL + !ip_borders_diagonal_color TYPE yecb_s_style_color OPTIONAL + !ip_borders_diagonal_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_borders_diagonal_color_inde TYPE yecb_style_color_indexed OPTIONAL + !ip_borders_diagonal_color_them TYPE yecb_style_color_theme OPTIONAL + !ip_borders_diagonal_color_tint TYPE yecb_style_color_tint OPTIONAL + !ip_borders_down_style TYPE yecb_border OPTIONAL + !ip_borders_down_color TYPE yecb_s_style_color OPTIONAL + !ip_borders_down_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_borders_down_color_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_borders_down_color_theme TYPE yecb_style_color_theme OPTIONAL + !ip_borders_down_color_tint TYPE yecb_style_color_tint OPTIONAL + !ip_borders_left_style TYPE yecb_border OPTIONAL + !ip_borders_left_color TYPE yecb_s_style_color OPTIONAL + !ip_borders_left_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_borders_left_color_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_borders_left_color_theme TYPE yecb_style_color_theme OPTIONAL + !ip_borders_left_color_tint TYPE yecb_style_color_tint OPTIONAL + !ip_borders_right_style TYPE yecb_border OPTIONAL + !ip_borders_right_color TYPE yecb_s_style_color OPTIONAL + !ip_borders_right_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_borders_right_color_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_borders_right_color_theme TYPE yecb_style_color_theme OPTIONAL + !ip_borders_right_color_tint TYPE yecb_style_color_tint OPTIONAL + !ip_borders_top_style TYPE yecb_border OPTIONAL + !ip_borders_top_color TYPE yecb_s_style_color OPTIONAL + !ip_borders_top_color_rgb TYPE yecb_style_color_argb OPTIONAL + !ip_borders_top_color_indexed TYPE yecb_style_color_indexed OPTIONAL + !ip_borders_top_color_theme TYPE yecb_style_color_theme OPTIONAL + !ip_borders_top_color_tint TYPE yecb_style_color_tint OPTIONAL + RETURNING + VALUE(ep_guid) TYPE yecb_cell_style + RAISING + ycx_ecb . + CLASS-METHODS class_constructor . + METHODS constructor + IMPORTING + !ip_excel TYPE REF TO ycl_ecb + !ip_title TYPE yecb_sheet_title OPTIONAL + RAISING + ycx_ecb . + METHODS delete_merge + IMPORTING + !ip_cell_column TYPE simple OPTIONAL + !ip_cell_row TYPE yecb_cell_row OPTIONAL + RAISING + ycx_ecb . + METHODS delete_row_outline + IMPORTING + !iv_row_from TYPE i + !iv_row_to TYPE i + RAISING + ycx_ecb . + METHODS freeze_panes + IMPORTING + !ip_num_columns TYPE i OPTIONAL + !ip_num_rows TYPE i OPTIONAL + RAISING + ycx_ecb . + METHODS get_active_cell + RETURNING + VALUE(ep_active_cell) TYPE string + RAISING + ycx_ecb . + METHODS get_cell + IMPORTING + !ip_columnrow TYPE csequence OPTIONAL + !ip_column TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + EXPORTING + !ep_value TYPE yecb_cell_value + !ep_rc TYPE sysubrc + !ep_style TYPE REF TO ycl_ecb_style + !ep_guid TYPE yecb_cell_style + !ep_formula TYPE yecb_cell_formula + !et_rtf TYPE yecb_t_rtf + RAISING + ycx_ecb . + METHODS get_column + IMPORTING + !ip_column TYPE simple + RETURNING + VALUE(eo_column) TYPE REF TO ycl_ecb_column + RAISING + ycx_ecb . + METHODS get_columns + RETURNING + VALUE(eo_columns) TYPE REF TO ycl_ecb_columns + RAISING + ycx_ecb . + METHODS get_columns_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator + RAISING + ycx_ecb . + METHODS get_style_cond_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_data_validations_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_data_validations_size + RETURNING + VALUE(ep_size) TYPE i . + METHODS get_default_column + RETURNING + VALUE(eo_column) TYPE REF TO ycl_ecb_column + RAISING + ycx_ecb . + METHODS get_default_excel_date_format + RETURNING + VALUE(ep_default_excel_date_format) TYPE yecb_number_format . + METHODS get_default_excel_time_format + RETURNING + VALUE(ep_default_excel_time_format) TYPE yecb_number_format . + METHODS get_default_row + RETURNING + VALUE(eo_row) TYPE REF TO ycl_ecb_row . + METHODS get_dimension_range + RETURNING + VALUE(ep_dimension_range) TYPE string + RAISING + ycx_ecb . + METHODS get_comments + RETURNING + VALUE(r_comments) TYPE REF TO ycl_ecb_comments . + METHODS get_drawings + IMPORTING + !ip_type TYPE yecb_drawing_type OPTIONAL + RETURNING + VALUE(r_drawings) TYPE REF TO ycl_ecb_drawings . + METHODS get_comments_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_drawings_iterator + IMPORTING + !ip_type TYPE yecb_drawing_type + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_freeze_cell + EXPORTING + !ep_row TYPE yecb_cell_row + !ep_column TYPE yecb_cell_column . + METHODS get_guid + RETURNING + VALUE(ep_guid) TYPE sysuuid_x16 . + METHODS get_highest_column + RETURNING + VALUE(r_highest_column) TYPE yecb_cell_column + RAISING + ycx_ecb . + METHODS get_highest_row + RETURNING + VALUE(r_highest_row) TYPE int4 + RAISING + ycx_ecb . + METHODS get_hyperlinks_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_hyperlinks_size + RETURNING + VALUE(ep_size) TYPE i . + METHODS get_ignored_errors + RETURNING + VALUE(rt_ignored_errors) TYPE mty_th_ignored_errors . + METHODS get_merge + RETURNING + VALUE(merge_range) TYPE string_table + RAISING + ycx_ecb . + METHODS get_pagebreaks + RETURNING + VALUE(ro_pagebreaks) TYPE REF TO ycl_ecb_worksheet_pagebreaks + RAISING + ycx_ecb . + METHODS get_ranges_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_row + IMPORTING + !ip_row TYPE int4 + RETURNING + VALUE(eo_row) TYPE REF TO ycl_ecb_row . + METHODS get_rows + RETURNING + VALUE(eo_rows) TYPE REF TO ycl_ecb_rows . + METHODS get_rows_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_row_outlines + RETURNING + VALUE(rt_row_outlines) TYPE mty_ts_outlines_row . + METHODS get_style_cond + IMPORTING + !ip_guid TYPE yecb_cell_style + RETURNING + VALUE(eo_style_cond) TYPE REF TO ycl_ecb_style_cond . + METHODS get_tabcolor + RETURNING + VALUE(ev_tabcolor) TYPE yecb_s_tabcolor . + METHODS get_tables_iterator + RETURNING + VALUE(eo_iterator) TYPE REF TO ycl_ecb_collection_iterator . + METHODS get_tables_size + RETURNING + VALUE(ep_size) TYPE i . + METHODS get_title + IMPORTING + !ip_escaped TYPE flag DEFAULT '' + RETURNING + VALUE(ep_title) TYPE yecb_sheet_title . + METHODS is_cell_merged + IMPORTING + !ip_column TYPE simple + !ip_row TYPE yecb_cell_row + RETURNING + VALUE(rp_is_merged) TYPE abap_bool + RAISING + ycx_ecb . + METHODS set_cell + IMPORTING + !ip_columnrow TYPE csequence OPTIONAL + !ip_column TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_value TYPE simple OPTIONAL + !ip_formula TYPE yecb_cell_formula OPTIONAL + !ip_style TYPE any OPTIONAL + !ip_hyperlink TYPE REF TO ycl_ecb_hyperlink OPTIONAL + !ip_data_type TYPE yecb_cell_data_type OPTIONAL + !ip_abap_type TYPE abap_typekind OPTIONAL + !ip_currency TYPE waers_curc OPTIONAL + !it_rtf TYPE yecb_t_rtf OPTIONAL + !ip_column_formula_id TYPE mty_s_column_formula-id OPTIONAL + !ip_conv_exit_length TYPE abap_bool DEFAULT abap_false + RAISING + ycx_ecb . + METHODS set_cell_formula + IMPORTING + !ip_columnrow TYPE csequence OPTIONAL + !ip_column TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_formula TYPE yecb_cell_formula + RAISING + ycx_ecb . + METHODS set_cell_style + IMPORTING + !ip_columnrow TYPE csequence OPTIONAL + !ip_column TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_style TYPE any + RAISING + ycx_ecb . + METHODS set_column_width + IMPORTING + !ip_column TYPE simple + !ip_width_fix TYPE simple DEFAULT 0 + !ip_width_autosize TYPE flag DEFAULT 'X' + RAISING + ycx_ecb . + METHODS set_default_excel_date_format + IMPORTING + !ip_default_excel_date_format TYPE yecb_number_format + RAISING + ycx_ecb . + METHODS set_ignored_errors + IMPORTING + !it_ignored_errors TYPE mty_th_ignored_errors . + METHODS set_merge + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_style TYPE any OPTIONAL + !ip_value TYPE simple OPTIONAL "added parameter + !ip_formula TYPE yecb_cell_formula OPTIONAL "added parameter + RAISING + ycx_ecb . + METHODS set_print_gridlines + IMPORTING + !i_print_gridlines TYPE yecb_print_gridlines . + METHODS set_row_height + IMPORTING + !ip_row TYPE simple + !ip_height_fix TYPE simple + RAISING + ycx_ecb . + METHODS set_row_outline + IMPORTING + !iv_row_from TYPE i + !iv_row_to TYPE i + !iv_collapsed TYPE abap_bool + RAISING + ycx_ecb . + METHODS set_show_gridlines + IMPORTING + !i_show_gridlines TYPE yecb_show_gridlines . + METHODS set_show_rowcolheaders + IMPORTING + !i_show_rowcolheaders TYPE yecb_show_rowcolheader . + METHODS set_tabcolor + IMPORTING + !iv_tabcolor TYPE yecb_s_tabcolor . + METHODS set_table + IMPORTING + !ip_table TYPE STANDARD TABLE + !ip_hdr_style TYPE any OPTIONAL + !ip_body_style TYPE any OPTIONAL + !ip_table_title TYPE string + !ip_top_left_column TYPE yecb_cell_column_alpha DEFAULT 'B' + !ip_top_left_row TYPE yecb_cell_row DEFAULT 3 + !ip_transpose TYPE abap_bool OPTIONAL + !ip_no_header TYPE abap_bool OPTIONAL + RAISING + ycx_ecb . + METHODS set_title + IMPORTING + !ip_title TYPE yecb_sheet_title + RAISING + ycx_ecb . + METHODS get_table + IMPORTING + !iv_skipped_rows TYPE int4 DEFAULT 0 + !iv_skipped_cols TYPE int4 DEFAULT 0 + !iv_max_col TYPE int4 OPTIONAL + !iv_max_row TYPE int4 OPTIONAL + !iv_skip_bottom_empty_rows TYPE abap_bool DEFAULT abap_false + EXPORTING + !et_table TYPE STANDARD TABLE + RAISING + ycx_ecb . + METHODS set_merge_style + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_style TYPE any OPTIONAL + RAISING + ycx_ecb . + METHODS set_area_formula + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_formula TYPE yecb_cell_formula + !ip_merge TYPE abap_bool OPTIONAL + !ip_area TYPE ty_area DEFAULT c_area-topleft + RAISING + ycx_ecb . + METHODS set_area_style + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_style TYPE any + !ip_merge TYPE abap_bool OPTIONAL + RAISING + ycx_ecb . + METHODS set_area + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_value TYPE simple OPTIONAL + !ip_formula TYPE yecb_cell_formula OPTIONAL + !ip_style TYPE any OPTIONAL + !ip_hyperlink TYPE REF TO ycl_ecb_hyperlink OPTIONAL + !ip_data_type TYPE yecb_cell_data_type OPTIONAL + !ip_abap_type TYPE abap_typekind OPTIONAL + !ip_merge TYPE abap_bool OPTIONAL + !ip_area TYPE ty_area DEFAULT c_area-topleft + RAISING + ycx_ecb . + METHODS get_header_footer_drawings + RETURNING + VALUE(rt_drawings) TYPE yecb_t_drawings . + METHODS set_area_hyperlink + IMPORTING + !ip_range TYPE csequence OPTIONAL + !ip_column_start TYPE simple OPTIONAL + !ip_column_end TYPE simple OPTIONAL + !ip_row TYPE yecb_cell_row OPTIONAL + !ip_row_to TYPE yecb_cell_row OPTIONAL + !ip_url TYPE string + !ip_is_internal TYPE abap_bool + RAISING + ycx_ecb . + "! excel upload, counterpart to BIND_TABLE + "! @parameter it_field_catalog | field catalog, used to derive correct types + "! @parameter iv_begin_row | starting row, by default 2 to skip header + "! @parameter et_data | generic internal table, there may be conversion losses + "! @parameter er_data | ref to internal table of string columns, to get raw data without conversion losses. + METHODS convert_to_table + IMPORTING + !it_field_catalog TYPE yecb_t_fieldcatalog OPTIONAL + !iv_begin_row TYPE int4 DEFAULT 2 + !iv_end_row TYPE int4 DEFAULT 0 + EXPORTING + !et_data TYPE STANDARD TABLE + !er_data TYPE REF TO data + RAISING + ycx_ecb . + PROTECTED SECTION. + METHODS set_table_reference + IMPORTING + !ip_column TYPE yecb_cell_column + !ip_row TYPE yecb_cell_row + !ir_table TYPE REF TO ycl_ecb_table + !ip_fieldname TYPE yecb_fieldname + !ip_header TYPE abap_bool + RAISING + ycx_ecb . + PRIVATE SECTION. + +*"* private components of class ZCL_EXCEL_WORKSHEET +*"* do not include other source files here!!! + TYPES ty_table_settings TYPE STANDARD TABLE OF yecb_s_table_settings WITH DEFAULT KEY. + DATA active_cell TYPE yecb_s_cell_data . + DATA charts TYPE REF TO ycl_ecb_drawings . + DATA columns TYPE REF TO ycl_ecb_columns . + DATA row_default TYPE REF TO ycl_ecb_row . + DATA column_default TYPE REF TO ycl_ecb_column . + DATA styles_cond TYPE REF TO ycl_ecb_styles_cond . + DATA data_validations TYPE REF TO ycl_ecb_data_validations . + DATA default_excel_date_format TYPE yecb_number_format . + DATA default_excel_time_format TYPE yecb_number_format . + DATA comments TYPE REF TO ycl_ecb_comments . + DATA drawings TYPE REF TO ycl_ecb_drawings . + DATA freeze_pane_cell_column TYPE yecb_cell_column . + DATA freeze_pane_cell_row TYPE yecb_cell_row . + DATA guid TYPE sysuuid_x16 . + DATA hyperlinks TYPE REF TO ycl_ecb_collection . + DATA lower_cell TYPE yecb_s_cell_data . + DATA mo_pagebreaks TYPE REF TO ycl_ecb_worksheet_pagebreaks . + DATA mt_row_outlines TYPE mty_ts_outlines_row . + DATA print_title_col_from TYPE yecb_cell_column_alpha . + DATA print_title_col_to TYPE yecb_cell_column_alpha . + DATA print_title_row_from TYPE yecb_cell_row . + DATA print_title_row_to TYPE yecb_cell_row . + DATA ranges TYPE REF TO ycl_ecb_ranges . + DATA rows TYPE REF TO ycl_ecb_rows . + DATA tables TYPE REF TO ycl_ecb_collection . + DATA title TYPE yecb_sheet_title VALUE 'Worksheet'. "#EC NOTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . " . + DATA upper_cell TYPE yecb_s_cell_data . + DATA mt_ignored_errors TYPE mty_th_ignored_errors. + DATA right_to_left TYPE abap_bool. + + METHODS calculate_cell_width + IMPORTING + !ip_column TYPE simple + !ip_row TYPE yecb_cell_row + RETURNING + VALUE(ep_width) TYPE f + RAISING + ycx_ecb . + CLASS-METHODS calculate_table_bottom_right + IMPORTING + ip_table TYPE STANDARD TABLE + it_field_catalog TYPE yecb_t_fieldcatalog + CHANGING + cs_settings TYPE yecb_s_table_settings + RAISING + ycx_ecb. + CLASS-METHODS check_cell_column_formula + IMPORTING + it_column_formulas TYPE mty_th_column_formula + ip_column_formula_id TYPE mty_s_column_formula-id + ip_formula TYPE yecb_cell_formula + ip_value TYPE simple + ip_row TYPE yecb_cell_row + ip_column TYPE yecb_cell_column + RAISING + ycx_ecb. + METHODS check_rtf + IMPORTING + !ip_value TYPE simple + VALUE(ip_style) TYPE yecb_cell_style OPTIONAL + CHANGING + !ct_rtf TYPE yecb_t_rtf + RAISING + ycx_ecb . + CLASS-METHODS check_table_overlapping + IMPORTING + is_table_settings TYPE yecb_s_table_settings + it_other_table_settings TYPE ty_table_settings + RAISING + ycx_ecb. + METHODS clear_initial_colorxfields + IMPORTING + is_color TYPE yecb_s_style_color + CHANGING + cs_xcolor TYPE yecb_s_cstylex_color. + METHODS create_data_conv_exit_length + IMPORTING + !ip_value TYPE simple + RETURNING + VALUE(ep_value) TYPE REF TO data. + METHODS generate_title + RETURNING + VALUE(ep_title) TYPE yecb_sheet_title . + METHODS get_value_type + IMPORTING + !ip_value TYPE simple + EXPORTING + !ep_value TYPE simple + !ep_value_type TYPE abap_typekind . + METHODS move_supplied_borders + IMPORTING + iv_border_supplied TYPE abap_bool + is_border TYPE yecb_s_cstyle_border + iv_xborder_supplied TYPE abap_bool + is_xborder TYPE yecb_s_cstylex_border + CHANGING + cs_complete_style_border TYPE yecb_s_cstyle_border + cs_complete_stylex_border TYPE yecb_s_cstylex_border. + METHODS normalize_column_heading_texts + IMPORTING + iv_default_descr TYPE c + it_field_catalog TYPE yecb_t_fieldcatalog + RETURNING + VALUE(result) TYPE yecb_t_fieldcatalog. + METHODS normalize_columnrow_parameter + IMPORTING + ip_columnrow TYPE csequence OPTIONAL + ip_column TYPE simple OPTIONAL + ip_row TYPE yecb_cell_row OPTIONAL + EXPORTING + ep_column TYPE yecb_cell_column + ep_row TYPE yecb_cell_row + RAISING + ycx_ecb. + METHODS normalize_range_parameter + IMPORTING + ip_range TYPE csequence OPTIONAL + ip_column_start TYPE simple OPTIONAL + ip_column_end TYPE simple OPTIONAL + ip_row TYPE yecb_cell_row OPTIONAL + ip_row_to TYPE yecb_cell_row OPTIONAL + EXPORTING + ep_column_start TYPE yecb_cell_column + ep_column_end TYPE yecb_cell_column + ep_row TYPE yecb_cell_row + ep_row_to TYPE yecb_cell_row + RAISING + ycx_ecb. + CLASS-METHODS normalize_style_parameter + IMPORTING + !ip_style_or_guid TYPE any + RETURNING + VALUE(rv_guid) TYPE yecb_cell_style + RAISING + ycx_ecb . + METHODS print_title_set_range . + METHODS update_dimension_range + RAISING + ycx_ecb . +ENDCLASS. + + + +CLASS ycl_ecb_worksheet IMPLEMENTATION. + + + METHOD add_comment. + comments->include( ip_comment ). + ENDMETHOD. "add_comment + + + METHOD add_drawing. + CASE ip_drawing->get_type( ). + WHEN ycl_ecb_drawing=>type_image. + drawings->include( ip_drawing ). + WHEN ycl_ecb_drawing=>type_chart. + charts->include( ip_drawing ). + ENDCASE. + ENDMETHOD. "ADD_DRAWING + + + METHOD add_new_column. + DATA: lv_column_alpha TYPE yecb_cell_column_alpha. + + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( ip_column ). + + CREATE OBJECT eo_column + EXPORTING + ip_index = lv_column_alpha + ip_excel = me->excel + ip_worksheet = me. + columns->add( eo_column ). + ENDMETHOD. "ADD_NEW_COLUMN + + + METHOD add_new_data_validation. + + CREATE OBJECT eo_data_validation. + data_validations->add( eo_data_validation ). + ENDMETHOD. "ADD_NEW_DATA_VALIDATION + + + METHOD add_new_range. +* Create default blank range + CREATE OBJECT eo_range. + ranges->add( eo_range ). + ENDMETHOD. "ADD_NEW_RANGE + + + METHOD add_new_row. + CREATE OBJECT eo_row + EXPORTING + ip_index = ip_row. + rows->add( eo_row ). + ENDMETHOD. "ADD_NEW_ROW + + + METHOD add_new_style_cond. + CREATE OBJECT eo_style_cond EXPORTING ip_dimension_range = ip_dimension_range. + styles_cond->add( eo_style_cond ). + ENDMETHOD. "ADD_NEW_STYLE_COND + + + METHOD bind_alv. + DATA: lo_converter TYPE REF TO ycl_ecb_converter. + + CREATE OBJECT lo_converter. + + TRY. + lo_converter->convert( + EXPORTING + io_alv = io_alv + it_table = it_table + i_row_int = i_top + i_column_int = i_left + i_table = i_table + i_style_table = table_style + io_worksheet = me + CHANGING + co_excel = excel ). + CATCH ycx_ecb . + ENDTRY. + + ENDMETHOD. "BIND_ALV + + + METHOD bind_alv_ole2. + + CALL METHOD ('ZCL_EXCEL_OLE')=>('BIND_ALV_OLE2') + EXPORTING + i_document_url = i_document_url + i_xls = i_xls + i_save_path = i_save_path + io_alv = io_alv + it_listheader = it_listheader + i_top = i_top + i_left = i_left + i_columns_header = i_columns_header + i_columns_autofit = i_columns_autofit + i_format_col_header = i_format_col_header + i_format_subtotal = i_format_subtotal + i_format_total = i_format_total + EXCEPTIONS + miss_guide = 1 + ex_transfer_kkblo_error = 2 + fatal_error = 3 + inv_data_range = 4 + dim_mismatch_vkey = 5 + dim_mismatch_sema = 6 + error_in_sema = 7 + OTHERS = 8. + IF sy-subrc <> 0. + CASE sy-subrc. + WHEN 1. RAISE miss_guide. + WHEN 2. RAISE ex_transfer_kkblo_error. + WHEN 3. RAISE fatal_error. + WHEN 4. RAISE inv_data_range. + WHEN 5. RAISE dim_mismatch_vkey. + WHEN 6. RAISE dim_mismatch_sema. + WHEN 7. RAISE error_in_sema. + ENDCASE. + ENDIF. + + ENDMETHOD. "BIND_ALV_OLE2 + + + METHOD bind_table. +*--------------------------------------------------------------------* +* issue #230 - Pimp my Code +* - Stefan Schmöcker, (wi p) 2012-12-01 +* - ... +* aligning code +* message made to support multilinguality +*--------------------------------------------------------------------* +* issue #237 - Check if overlapping areas exist +* - Alessandro Iannacci 2012-12-01 +* changes: - Added raise if overlaps are detected +*--------------------------------------------------------------------* + + CONSTANTS: + lc_top_left_column TYPE yecb_cell_column_alpha VALUE 'A', + lc_top_left_row TYPE yecb_cell_row VALUE 1, + lc_no_currency TYPE waers_curc VALUE IS INITIAL. + + DATA: + lv_row_int TYPE yecb_cell_row, + lv_first_row TYPE yecb_cell_row, + lv_last_row TYPE yecb_cell_row, + lv_column_int TYPE yecb_cell_column, + lv_column_alpha TYPE yecb_cell_column_alpha, + lt_field_catalog TYPE yecb_t_fieldcatalog, + lv_id TYPE i, + lv_formula TYPE string, + ls_settings TYPE yecb_s_table_settings, + lo_table TYPE REF TO ycl_ecb_table, + lv_value_lowercase TYPE string, + lv_syindex TYPE c LENGTH 3, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_style_cond TYPE REF TO ycl_ecb_style_cond, + lo_curtable TYPE REF TO ycl_ecb_table, + lt_other_table_settings TYPE ty_table_settings. + DATA: ls_column_formula TYPE mty_s_column_formula, + lv_mincol TYPE i. + + FIELD-SYMBOLS: + TYPE yecb_s_fieldcatalog, + TYPE yecb_s_fieldcatalog, + TYPE any, + TYPE any, + TYPE waers. + + ls_settings = is_table_settings. + + IF ls_settings-top_left_column IS INITIAL. + ls_settings-top_left_column = lc_top_left_column. + ENDIF. + + IF ls_settings-table_style IS INITIAL. + ls_settings-table_style = ycl_ecb_table=>builtinstyle_medium2. + ENDIF. + + IF ls_settings-top_left_row IS INITIAL. + ls_settings-top_left_row = lc_top_left_row. + ENDIF. + + IF it_field_catalog IS NOT SUPPLIED. + lt_field_catalog = ycl_ecb_common=>get_fieldcatalog( ip_table = ip_table + ip_conv_exit_length = ip_conv_exit_length ). + ELSE. + lt_field_catalog = it_field_catalog. + ENDIF. + + SORT lt_field_catalog BY position. + + calculate_table_bottom_right( + EXPORTING + ip_table = ip_table + it_field_catalog = lt_field_catalog + CHANGING + cs_settings = ls_settings ). + +* Check if overlapping areas exist + + lo_iterator = me->tables->get_iterator( ). + WHILE lo_iterator->has_next( ) EQ abap_true. + lo_curtable ?= lo_iterator->get_next( ). + APPEND lo_curtable->settings TO lt_other_table_settings. + ENDWHILE. + + check_table_overlapping( + is_table_settings = ls_settings + it_other_table_settings = lt_other_table_settings ). + +* Start filling the table + + CREATE OBJECT lo_table. + lo_table->settings = ls_settings. + lo_table->set_data( ir_data = ip_table ). + lv_id = me->excel->get_next_table_id( ). + lo_table->set_id( iv_id = lv_id ). + + me->tables->add( lo_table ). + + lv_column_int = ycl_ecb_common=>convert_column2int( ls_settings-top_left_column ). + lv_row_int = ls_settings-top_left_row. + + lt_field_catalog = normalize_column_heading_texts( + iv_default_descr = iv_default_descr + it_field_catalog = lt_field_catalog ). + +* It is better to loop column by column (only visible column) + LOOP AT lt_field_catalog ASSIGNING WHERE dynpfld EQ abap_true. + + lv_column_alpha = ycl_ecb_common=>convert_column2alpha( lv_column_int ). + + " First of all write column header + IF -style_header IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = -column_name + ip_style = -style_header ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = -column_name ). + ENDIF. + + me->set_table_reference( ip_column = lv_column_int + ip_row = lv_row_int + ir_table = lo_table + ip_fieldname = -fieldname + ip_header = abap_true ). + + IF -column_formula IS NOT INITIAL. + ls_column_formula-id = lines( column_formulas ) + 1. + ls_column_formula-column = lv_column_int. + ls_column_formula-formula = -column_formula. + ls_column_formula-table_top_left_row = lo_table->settings-top_left_row. + ls_column_formula-table_bottom_right_row = lo_table->settings-bottom_right_row. + ls_column_formula-table_left_column_int = lv_mincol. + ls_column_formula-table_right_column_int = ycl_ecb_common=>convert_column2int( lo_table->settings-bottom_right_column ). + INSERT ls_column_formula INTO TABLE column_formulas. + ENDIF. + + ADD 1 TO lv_row_int. + LOOP AT ip_table ASSIGNING . + + ASSIGN COMPONENT -fieldname OF STRUCTURE TO . + + " issue #290 Add formula support in table + IF -formula EQ abap_true. + IF -style IS NOT INITIAL. + IF -abap_type IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = + ip_abap_type = -abap_type + ip_style = -style ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = + ip_style = -style ). + ENDIF. + ELSEIF -abap_type IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = + ip_abap_type = -abap_type ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = ). + ENDIF. + ELSEIF -column_formula IS NOT INITIAL. + " Column formulas + IF -style IS NOT INITIAL. + IF -abap_type IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_column_formula_id = ls_column_formula-id + ip_abap_type = -abap_type + ip_style = -style ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_column_formula_id = ls_column_formula-id + ip_style = -style ). + ENDIF. + ELSEIF -abap_type IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_column_formula_id = ls_column_formula-id + ip_abap_type = -abap_type ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_column_formula_id = ls_column_formula-id ). + ENDIF. + ELSE. + IF -currency_column IS INITIAL OR ip_conv_curr_amt_ext = abap_false. + ASSIGN lc_no_currency TO . + ELSE. + ASSIGN COMPONENT -currency_column OF STRUCTURE TO . + ENDIF. + + IF -style IS NOT INITIAL. + IF -abap_type IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = + ip_abap_type = -abap_type + ip_currency = + ip_style = -style + ip_conv_exit_length = ip_conv_exit_length ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = + ip_currency = + ip_style = -style + ip_conv_exit_length = ip_conv_exit_length ). + ENDIF. + ELSE. + IF -abap_type IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_abap_type = -abap_type + ip_currency = + ip_value = + ip_conv_exit_length = ip_conv_exit_length ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_currency = + ip_value = + ip_conv_exit_length = ip_conv_exit_length ). + ENDIF. + ENDIF. + ENDIF. + ADD 1 TO lv_row_int. + + ENDLOOP. + IF sy-subrc <> 0 AND iv_no_line_if_empty = abap_false. "create empty row if table has no data + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_value = space ). + ADD 1 TO lv_row_int. + ENDIF. + +*--------------------------------------------------------------------* + " totals +*--------------------------------------------------------------------* + IF -totals_function IS NOT INITIAL. + lv_formula = lo_table->get_totals_formula( ip_column = -column_name ip_function = -totals_function ). + IF -style_total IS NOT INITIAL. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = lv_formula + ip_style = -style_total ). + ELSE. + me->set_cell( ip_column = lv_column_alpha + ip_row = lv_row_int + ip_formula = lv_formula ). + ENDIF. + ENDIF. + + lv_row_int = ls_settings-top_left_row. + ADD 1 TO lv_column_int. + +*--------------------------------------------------------------------* + " conditional formatting +*--------------------------------------------------------------------* + IF -style_cond IS NOT INITIAL. + lv_first_row = ls_settings-top_left_row + 1. " +1 to exclude header + lv_last_row = ls_settings-bottom_right_row. + lo_style_cond = me->get_style_cond( -style_cond ). + lo_style_cond->set_range( ip_start_column = lv_column_alpha + ip_start_row = lv_first_row + ip_stop_column = lv_column_alpha + ip_stop_row = lv_last_row ). + ENDIF. + + ENDLOOP. + +*--------------------------------------------------------------------* + " Set field catalog +*--------------------------------------------------------------------* + lo_table->fieldcat = lt_field_catalog[]. + + es_table_settings = ls_settings. + es_table_settings-bottom_right_column = lv_column_alpha. + " >> Issue #291 + IF ip_table IS INITIAL. + es_table_settings-bottom_right_row = ls_settings-top_left_row + 2. "Last rows + ELSE. + es_table_settings-bottom_right_row = ls_settings-bottom_right_row + 1. "Last rows + ENDIF. + " << Issue #291 + + ENDMETHOD. "BIND_TABLE + + + METHOD calculate_cell_width. +*--------------------------------------------------------------------* +* issue #293 - Roberto Bianco +* - Christian Assig 2014-03-14 +* +* changes: - Calculate widths using SAPscript font metrics +* (transaction SE73) +* - Calculate the width of dates +* - Add additional width for auto filter buttons +* - Add cell padding to simulate Excel behavior +*--------------------------------------------------------------------* + + DATA: ld_cell_value TYPE yecb_cell_value, + ld_style_guid TYPE yecb_cell_style, + ls_stylemapping TYPE yecb_s_stylemapping, + lo_table_object TYPE REF TO object, + lo_table TYPE REF TO ycl_ecb_table, + ld_table_top_left_column TYPE yecb_cell_column, + ld_table_bottom_right_column TYPE yecb_cell_column, + ld_flag_contains_auto_filter TYPE abap_bool VALUE abap_false, + ld_flag_bold TYPE abap_bool VALUE abap_false, + 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 ycl_ecb_font=>lc_default_font_height, + ld_font_name TYPE yecb_style_font_name VALUE ycl_ecb_font=>lc_default_font_name. + + " Determine cell content and cell style + me->get_cell( EXPORTING ip_column = ip_column + ip_row = ip_row + IMPORTING ep_value = ld_cell_value + ep_guid = ld_style_guid ). + + " ABAP2XLSX uses tables to define areas containing headers and + " auto-filters. Find out if the current cell is in the header + " of one of these tables. + LOOP AT me->tables->collection INTO lo_table_object. + " Downcast: OBJECT -> ZCL_EXCEL_TABLE + lo_table ?= lo_table_object. + + " Convert column letters to corresponding integer values + ld_table_top_left_column = + ycl_ecb_common=>convert_column2int( + lo_table->settings-top_left_column ). + + ld_table_bottom_right_column = + ycl_ecb_common=>convert_column2int( + lo_table->settings-bottom_right_column ). + + " Is the current cell part of the table header? + IF ip_column BETWEEN ld_table_top_left_column AND + ld_table_bottom_right_column AND + ip_row EQ lo_table->settings-top_left_row. + " Current cell is part of the table header + " -> Assume that an auto filter is present and that the font is + " bold + ld_flag_contains_auto_filter = abap_true. + ld_flag_bold = abap_true. + ENDIF. + ENDLOOP. + + " If a style GUID is present, read style attributes + IF ld_style_guid IS NOT INITIAL. + TRY. + " Read style attributes + ls_stylemapping = me->excel->get_style_to_guid( ld_style_guid ). + + " If the current cell contains the default date format, + " convert the cell value to a date and calculate its length + IF ls_stylemapping-complete_style-number_format-format_code = + ycl_ecb_style_number_format=>c_format_date_std. + + " Convert excel date to ABAP date + ld_date = + ycl_ecb_common=>excel_string_to_date( ld_cell_value ). + + " Format ABAP date using user's formatting settings + WRITE ld_date TO ld_date_char. + + " Remember the formatted date to calculate the cell size + ld_cell_value = ld_date_char. + + ENDIF. + + " Read the font size and convert it to the font height + " used by SAPscript (multiplication by 10) + IF ls_stylemapping-complete_stylex-font-size = abap_true. + ld_font_height = ls_stylemapping-complete_style-font-size * 10. + ENDIF. + + " If set, remember the font name + IF ls_stylemapping-complete_stylex-font-name = abap_true. + ld_font_name = ls_stylemapping-complete_style-font-name. + ENDIF. + + " If set, remember whether font is bold and italic. + IF ls_stylemapping-complete_stylex-font-bold = abap_true. + ld_flag_bold = ls_stylemapping-complete_style-font-bold. + ENDIF. + + IF ls_stylemapping-complete_stylex-font-italic = abap_true. + ld_flag_italic = ls_stylemapping-complete_style-font-italic. + ENDIF. + + CATCH ycx_ecb. "#EC NO_HANDLER + " Style GUID is present, but style was not found + " Continue with default values + + ENDTRY. + ENDIF. + + ep_width = ycl_ecb_font=>calculate_text_width( + iv_font_name = ld_font_name + iv_font_height = ld_font_height + iv_flag_bold = ld_flag_bold + iv_flag_italic = ld_flag_italic + iv_cell_value = ld_cell_value ). + + " If the current cell contains an auto filter, make it a bit wider. + " The size used by the auto filter button does not depend on the font + " size. + IF ld_flag_contains_auto_filter = abap_true. + ADD 2 TO ep_width. + ENDIF. + + ENDMETHOD. + + + METHOD calculate_column_widths. + TYPES: + BEGIN OF t_auto_size, + col_index TYPE int4, + width TYPE f, + END OF t_auto_size. + TYPES: tt_auto_size TYPE TABLE OF t_auto_size. + + DATA: lo_column_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_column TYPE REF TO ycl_ecb_column. + + DATA: auto_size TYPE flag. + DATA: auto_sizes TYPE tt_auto_size. + DATA: count TYPE int4. + DATA: highest_row TYPE int4. + DATA: width TYPE f. + + FIELD-SYMBOLS: LIKE LINE OF auto_sizes. + + lo_column_iterator = me->get_columns_iterator( ). + WHILE lo_column_iterator->has_next( ) = abap_true. + lo_column ?= lo_column_iterator->get_next( ). + auto_size = lo_column->get_auto_size( ). + IF auto_size = abap_true. + APPEND INITIAL LINE TO auto_sizes ASSIGNING . + -col_index = lo_column->get_column_index( ). + -width = -1. + ENDIF. + ENDWHILE. + + " There is only something to do if there are some auto-size columns + IF NOT auto_sizes IS INITIAL. + highest_row = me->get_highest_row( ). + LOOP AT auto_sizes ASSIGNING . + count = 1. + WHILE count <= highest_row. +* Do not check merged cells + IF is_cell_merged( + ip_column = -col_index + ip_row = count ) = abap_false. + width = calculate_cell_width( ip_column = -col_index " issue #155 - less restrictive typing for ip_column + ip_row = count ). + IF width > -width. + -width = width. + ENDIF. + ENDIF. + count = count + 1. + ENDWHILE. + lo_column = me->get_column( -col_index ). " issue #155 - less restrictive typing for ip_column + lo_column->set_width( -width ). + ENDLOOP. + ENDIF. + + ENDMETHOD. "CALCULATE_COLUMN_WIDTHS + + + METHOD calculate_table_bottom_right. + + DATA: lv_errormessage TYPE string, + lv_columns TYPE i, + lt_columns TYPE yecb_t_fieldcatalog, + lv_maxrow TYPE i, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_curtable TYPE REF TO ycl_ecb_table, + lv_row_int TYPE yecb_cell_row, + lv_column_int TYPE yecb_cell_column, + lv_rows TYPE i, + lv_maxcol TYPE i. + + "Get the number of columns for the current table + lt_columns = it_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 = ycl_ecb_common=>convert_column2int( cs_settings-top_left_column ). + lv_row_int = cs_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. + cs_settings-bottom_right_column = ycl_ecb_common=>convert_column2alpha( lv_maxcol ). + cs_settings-bottom_right_row = lv_maxrow. + + ENDMETHOD. + + + METHOD change_area_style. + + DATA: lv_row TYPE yecb_cell_row, + lv_row_start TYPE yecb_cell_row, + lv_row_to TYPE yecb_cell_row, + lv_column_int TYPE yecb_cell_column, + lv_column_start_int TYPE yecb_cell_column, + lv_column_end_int TYPE yecb_cell_column. + + normalize_range_parameter( EXPORTING ip_range = ip_range + ip_column_start = ip_column_start ip_column_end = ip_column_end + ip_row = ip_row ip_row_to = ip_row_to + IMPORTING ep_column_start = lv_column_start_int ep_column_end = lv_column_end_int + ep_row = lv_row_start ep_row_to = lv_row_to ). + + lv_column_int = lv_column_start_int. + WHILE lv_column_int <= lv_column_end_int. + + lv_row = lv_row_start. + WHILE lv_row <= lv_row_to. + + ip_style_changer->apply( ip_worksheet = me + ip_column = lv_column_int + ip_row = lv_row ). + + ADD 1 TO lv_row. + ENDWHILE. + + ADD 1 TO lv_column_int. + ENDWHILE. + + ENDMETHOD. + + + METHOD change_cell_style. + + DATA: changer TYPE REF TO yif_ecb_style_changer, + column TYPE yecb_cell_column, + row TYPE yecb_cell_row. + + normalize_columnrow_parameter( EXPORTING ip_columnrow = ip_columnrow + ip_column = ip_column + ip_row = ip_row + IMPORTING ep_column = column + ep_row = row ). + + changer = ycl_ecb_style_changer=>create( excel = excel ). + + + IF ip_complete IS SUPPLIED. + IF ip_xcomplete IS NOT SUPPLIED. + ycx_ecb=>raise_text( 'Complete styleinfo has to be supplied with corresponding X-field' ). + ENDIF. + changer->set_complete( ip_complete = ip_complete ip_xcomplete = ip_xcomplete ). + ENDIF. + + + + IF ip_font IS SUPPLIED. + IF ip_xfont IS SUPPLIED. + changer->set_complete_font( ip_font = ip_font ip_xfont = ip_xfont ). + ELSE. + changer->set_complete_font( ip_font = ip_font ). + ENDIF. + ENDIF. + + IF ip_fill IS SUPPLIED. + IF ip_xfill IS SUPPLIED. + changer->set_complete_fill( ip_fill = ip_fill ip_xfill = ip_xfill ). + ELSE. + changer->set_complete_fill( ip_fill = ip_fill ). + ENDIF. + ENDIF. + + + IF ip_borders IS SUPPLIED. + IF ip_xborders IS SUPPLIED. + changer->set_complete_borders( ip_borders = ip_borders ip_xborders = ip_xborders ). + ELSE. + changer->set_complete_borders( ip_borders = ip_borders ). + ENDIF. + ENDIF. + + IF ip_alignment IS SUPPLIED. + IF ip_xalignment IS SUPPLIED. + changer->set_complete_alignment( ip_alignment = ip_alignment ip_xalignment = ip_xalignment ). + ELSE. + changer->set_complete_alignment( ip_alignment = ip_alignment ). + ENDIF. + ENDIF. + + IF ip_protection IS SUPPLIED. + IF ip_xprotection IS SUPPLIED. + changer->set_complete_protection( ip_protection = ip_protection ip_xprotection = ip_xprotection ). + ELSE. + changer->set_complete_protection( ip_protection = ip_protection ). + ENDIF. + ENDIF. + + + IF ip_borders_allborders IS SUPPLIED. + IF ip_xborders_allborders IS SUPPLIED. + changer->set_complete_borders_all( ip_borders_allborders = ip_borders_allborders ip_xborders_allborders = ip_xborders_allborders ). + ELSE. + changer->set_complete_borders_all( ip_borders_allborders = ip_borders_allborders ). + ENDIF. + ENDIF. + + IF ip_borders_diagonal IS SUPPLIED. + IF ip_xborders_diagonal IS SUPPLIED. + changer->set_complete_borders_diagonal( ip_borders_diagonal = ip_borders_diagonal ip_xborders_diagonal = ip_xborders_diagonal ). + ELSE. + changer->set_complete_borders_diagonal( ip_borders_diagonal = ip_borders_diagonal ). + ENDIF. + ENDIF. + + IF ip_borders_down IS SUPPLIED. + IF ip_xborders_down IS SUPPLIED. + changer->set_complete_borders_down( ip_borders_down = ip_borders_down ip_xborders_down = ip_xborders_down ). + ELSE. + changer->set_complete_borders_down( ip_borders_down = ip_borders_down ). + ENDIF. + ENDIF. + + IF ip_borders_left IS SUPPLIED. + IF ip_xborders_left IS SUPPLIED. + changer->set_complete_borders_left( ip_borders_left = ip_borders_left ip_xborders_left = ip_xborders_left ). + ELSE. + changer->set_complete_borders_left( ip_borders_left = ip_borders_left ). + ENDIF. + ENDIF. + + IF ip_borders_right IS SUPPLIED. + IF ip_xborders_right IS SUPPLIED. + changer->set_complete_borders_right( ip_borders_right = ip_borders_right ip_xborders_right = ip_xborders_right ). + ELSE. + changer->set_complete_borders_right( ip_borders_right = ip_borders_right ). + ENDIF. + ENDIF. + + IF ip_borders_top IS SUPPLIED. + IF ip_xborders_top IS SUPPLIED. + changer->set_complete_borders_top( ip_borders_top = ip_borders_top ip_xborders_top = ip_xborders_top ). + ELSE. + changer->set_complete_borders_top( ip_borders_top = ip_borders_top ). + ENDIF. + ENDIF. + + IF ip_number_format_format_code IS SUPPLIED. + changer->set_number_format( ip_number_format_format_code ). + ENDIF. + IF ip_font_bold IS SUPPLIED. + changer->set_font_bold( ip_font_bold ). + ENDIF. + IF ip_font_color IS SUPPLIED. + changer->set_font_color( ip_font_color ). + ENDIF. + IF ip_font_color_rgb IS SUPPLIED. + changer->set_font_color_rgb( ip_font_color_rgb ). + ENDIF. + IF ip_font_color_indexed IS SUPPLIED. + changer->set_font_color_indexed( ip_font_color_indexed ). + ENDIF. + IF ip_font_color_theme IS SUPPLIED. + changer->set_font_color_theme( ip_font_color_theme ). + ENDIF. + IF ip_font_color_tint IS SUPPLIED. + changer->set_font_color_tint( ip_font_color_tint ). + ENDIF. + + IF ip_font_family IS SUPPLIED. + changer->set_font_family( ip_font_family ). + ENDIF. + IF ip_font_italic IS SUPPLIED. + changer->set_font_italic( ip_font_italic ). + ENDIF. + IF ip_font_name IS SUPPLIED. + changer->set_font_name( ip_font_name ). + ENDIF. + IF ip_font_scheme IS SUPPLIED. + changer->set_font_scheme( ip_font_scheme ). + ENDIF. + IF ip_font_size IS SUPPLIED. + changer->set_font_size( ip_font_size ). + ENDIF. + IF ip_font_strikethrough IS SUPPLIED. + changer->set_font_strikethrough( ip_font_strikethrough ). + ENDIF. + IF ip_font_underline IS SUPPLIED. + changer->set_font_underline( ip_font_underline ). + ENDIF. + IF ip_font_underline_mode IS SUPPLIED. + changer->set_font_underline_mode( ip_font_underline_mode ). + ENDIF. + + IF ip_fill_filltype IS SUPPLIED. + changer->set_fill_filltype( ip_fill_filltype ). + ENDIF. + IF ip_fill_rotation IS SUPPLIED. + changer->set_fill_rotation( ip_fill_rotation ). + ENDIF. + IF ip_fill_fgcolor IS SUPPLIED. + changer->set_fill_fgcolor( ip_fill_fgcolor ). + ENDIF. + IF ip_fill_fgcolor_rgb IS SUPPLIED. + changer->set_fill_fgcolor_rgb( ip_fill_fgcolor_rgb ). + ENDIF. + IF ip_fill_fgcolor_indexed IS SUPPLIED. + changer->set_fill_fgcolor_indexed( ip_fill_fgcolor_indexed ). + ENDIF. + IF ip_fill_fgcolor_theme IS SUPPLIED. + changer->set_fill_fgcolor_theme( ip_fill_fgcolor_theme ). + ENDIF. + IF ip_fill_fgcolor_tint IS SUPPLIED. + changer->set_fill_fgcolor_tint( ip_fill_fgcolor_tint ). + ENDIF. + + IF ip_fill_bgcolor IS SUPPLIED. + changer->set_fill_bgcolor( ip_fill_bgcolor ). + ENDIF. + IF ip_fill_bgcolor_rgb IS SUPPLIED. + changer->set_fill_bgcolor_rgb( ip_fill_bgcolor_rgb ). + ENDIF. + IF ip_fill_bgcolor_indexed IS SUPPLIED. + changer->set_fill_bgcolor_indexed( ip_fill_bgcolor_indexed ). + ENDIF. + IF ip_fill_bgcolor_theme IS SUPPLIED. + changer->set_fill_bgcolor_theme( ip_fill_bgcolor_theme ). + ENDIF. + IF ip_fill_bgcolor_tint IS SUPPLIED. + changer->set_fill_bgcolor_tint( ip_fill_bgcolor_tint ). + ENDIF. + + IF ip_fill_gradtype_type IS SUPPLIED. + changer->set_fill_gradtype_type( ip_fill_gradtype_type ). + ENDIF. + IF ip_fill_gradtype_degree IS SUPPLIED. + changer->set_fill_gradtype_degree( ip_fill_gradtype_degree ). + ENDIF. + IF ip_fill_gradtype_bottom IS SUPPLIED. + changer->set_fill_gradtype_bottom( ip_fill_gradtype_bottom ). + ENDIF. + IF ip_fill_gradtype_left IS SUPPLIED. + changer->set_fill_gradtype_left( ip_fill_gradtype_left ). + ENDIF. + IF ip_fill_gradtype_top IS SUPPLIED. + changer->set_fill_gradtype_top( ip_fill_gradtype_top ). + ENDIF. + IF ip_fill_gradtype_right IS SUPPLIED. + changer->set_fill_gradtype_right( ip_fill_gradtype_right ). + ENDIF. + IF ip_fill_gradtype_position1 IS SUPPLIED. + changer->set_fill_gradtype_position1( ip_fill_gradtype_position1 ). + ENDIF. + IF ip_fill_gradtype_position2 IS SUPPLIED. + changer->set_fill_gradtype_position2( ip_fill_gradtype_position2 ). + ENDIF. + IF ip_fill_gradtype_position3 IS SUPPLIED. + changer->set_fill_gradtype_position3( ip_fill_gradtype_position3 ). + ENDIF. + + + + IF ip_borders_diagonal_mode IS SUPPLIED. + changer->set_borders_diagonal_mode( ip_borders_diagonal_mode ). + ENDIF. + IF ip_alignment_horizontal IS SUPPLIED. + changer->set_alignment_horizontal( ip_alignment_horizontal ). + ENDIF. + IF ip_alignment_vertical IS SUPPLIED. + changer->set_alignment_vertical( ip_alignment_vertical ). + ENDIF. + IF ip_alignment_textrotation IS SUPPLIED. + changer->set_alignment_textrotation( ip_alignment_textrotation ). + ENDIF. + IF ip_alignment_wraptext IS SUPPLIED. + changer->set_alignment_wraptext( ip_alignment_wraptext ). + ENDIF. + IF ip_alignment_shrinktofit IS SUPPLIED. + changer->set_alignment_shrinktofit( ip_alignment_shrinktofit ). + ENDIF. + IF ip_alignment_indent IS SUPPLIED. + changer->set_alignment_indent( ip_alignment_indent ). + ENDIF. + IF ip_protection_hidden IS SUPPLIED. + changer->set_protection_hidden( ip_protection_hidden ). + ENDIF. + IF ip_protection_locked IS SUPPLIED. + changer->set_protection_locked( ip_protection_locked ). + ENDIF. + + IF ip_borders_allborders_style IS SUPPLIED. + changer->set_borders_allborders_style( ip_borders_allborders_style ). + ENDIF. + IF ip_borders_allborders_color IS SUPPLIED. + changer->set_borders_allborders_color( ip_borders_allborders_color ). + ENDIF. + IF ip_borders_allbo_color_rgb IS SUPPLIED. + changer->set_borders_allbo_color_rgb( ip_borders_allbo_color_rgb ). + ENDIF. + IF ip_borders_allbo_color_indexed IS SUPPLIED. + changer->set_borders_allbo_color_indexe( ip_borders_allbo_color_indexed ). + ENDIF. + IF ip_borders_allbo_color_theme IS SUPPLIED. + changer->set_borders_allbo_color_theme( ip_borders_allbo_color_theme ). + ENDIF. + IF ip_borders_allbo_color_tint IS SUPPLIED. + changer->set_borders_allbo_color_tint( ip_borders_allbo_color_tint ). + ENDIF. + + IF ip_borders_diagonal_style IS SUPPLIED. + changer->set_borders_diagonal_style( ip_borders_diagonal_style ). + ENDIF. + IF ip_borders_diagonal_color IS SUPPLIED. + changer->set_borders_diagonal_color( ip_borders_diagonal_color ). + ENDIF. + IF ip_borders_diagonal_color_rgb IS SUPPLIED. + changer->set_borders_diagonal_color_rgb( ip_borders_diagonal_color_rgb ). + ENDIF. + IF ip_borders_diagonal_color_inde IS SUPPLIED. + changer->set_borders_diagonal_color_ind( ip_borders_diagonal_color_inde ). + ENDIF. + IF ip_borders_diagonal_color_them IS SUPPLIED. + changer->set_borders_diagonal_color_the( ip_borders_diagonal_color_them ). + ENDIF. + IF ip_borders_diagonal_color_tint IS SUPPLIED. + changer->set_borders_diagonal_color_tin( ip_borders_diagonal_color_tint ). + ENDIF. + + IF ip_borders_down_style IS SUPPLIED. + changer->set_borders_down_style( ip_borders_down_style ). + ENDIF. + IF ip_borders_down_color IS SUPPLIED. + changer->set_borders_down_color( ip_borders_down_color ). + ENDIF. + IF ip_borders_down_color_rgb IS SUPPLIED. + changer->set_borders_down_color_rgb( ip_borders_down_color_rgb ). + ENDIF. + IF ip_borders_down_color_indexed IS SUPPLIED. + changer->set_borders_down_color_indexed( ip_borders_down_color_indexed ). + ENDIF. + IF ip_borders_down_color_theme IS SUPPLIED. + changer->set_borders_down_color_theme( ip_borders_down_color_theme ). + ENDIF. + IF ip_borders_down_color_tint IS SUPPLIED. + changer->set_borders_down_color_tint( ip_borders_down_color_tint ). + ENDIF. + + IF ip_borders_left_style IS SUPPLIED. + changer->set_borders_left_style( ip_borders_left_style ). + ENDIF. + IF ip_borders_left_color IS SUPPLIED. + changer->set_borders_left_color( ip_borders_left_color ). + ENDIF. + IF ip_borders_left_color_rgb IS SUPPLIED. + changer->set_borders_left_color_rgb( ip_borders_left_color_rgb ). + ENDIF. + IF ip_borders_left_color_indexed IS SUPPLIED. + changer->set_borders_left_color_indexed( ip_borders_left_color_indexed ). + ENDIF. + IF ip_borders_left_color_theme IS SUPPLIED. + changer->set_borders_left_color_theme( ip_borders_left_color_theme ). + ENDIF. + IF ip_borders_left_color_tint IS SUPPLIED. + changer->set_borders_left_color_tint( ip_borders_left_color_tint ). + ENDIF. + + IF ip_borders_right_style IS SUPPLIED. + changer->set_borders_right_style( ip_borders_right_style ). + ENDIF. + IF ip_borders_right_color IS SUPPLIED. + changer->set_borders_right_color( ip_borders_right_color ). + ENDIF. + IF ip_borders_right_color_rgb IS SUPPLIED. + changer->set_borders_right_color_rgb( ip_borders_right_color_rgb ). + ENDIF. + IF ip_borders_right_color_indexed IS SUPPLIED. + changer->set_borders_right_color_indexe( ip_borders_right_color_indexed ). + ENDIF. + IF ip_borders_right_color_theme IS SUPPLIED. + changer->set_borders_right_color_theme( ip_borders_right_color_theme ). + ENDIF. + IF ip_borders_right_color_tint IS SUPPLIED. + changer->set_borders_right_color_tint( ip_borders_right_color_tint ). + ENDIF. + + IF ip_borders_top_style IS SUPPLIED. + changer->set_borders_top_style( ip_borders_top_style ). + ENDIF. + IF ip_borders_top_color IS SUPPLIED. + changer->set_borders_top_color( ip_borders_top_color ). + ENDIF. + IF ip_borders_top_color_rgb IS SUPPLIED. + changer->set_borders_top_color_rgb( ip_borders_top_color_rgb ). + ENDIF. + IF ip_borders_top_color_indexed IS SUPPLIED. + changer->set_borders_top_color_indexed( ip_borders_top_color_indexed ). + ENDIF. + IF ip_borders_top_color_theme IS SUPPLIED. + changer->set_borders_top_color_theme( ip_borders_top_color_theme ). + ENDIF. + IF ip_borders_top_color_tint IS SUPPLIED. + changer->set_borders_top_color_tint( ip_borders_top_color_tint ). + ENDIF. + + + ep_guid = changer->apply( ip_worksheet = me + ip_column = column + ip_row = row ). + + + ENDMETHOD. "CHANGE_CELL_STYLE + + + METHOD check_cell_column_formula. + + FIELD-SYMBOLS TYPE ycl_ecb_worksheet=>mty_s_column_formula. + + IF ip_value IS NOT INITIAL OR ip_formula IS NOT INITIAL. + ycx_ecb=>raise_text( c_messages-formula_id_only_is_possible ). + ENDIF. + READ TABLE it_column_formulas WITH TABLE KEY id = ip_column_formula_id ASSIGNING . + IF sy-subrc <> 0. + ycx_ecb=>raise_text( c_messages-column_formula_id_not_found ). + ENDIF. + IF ip_row < -table_top_left_row + 1 + OR ip_row > -table_bottom_right_row + 1 + OR ip_column < -table_left_column_int + OR ip_column > -table_right_column_int. + ycx_ecb=>raise_text( c_messages-formula_not_in_this_table ). + ENDIF. + IF ip_column <> -column. + ycx_ecb=>raise_text( c_messages-formula_in_other_column ). + ENDIF. + + ENDMETHOD. + + + METHOD check_rtf. + + DATA: lo_style TYPE REF TO ycl_ecb_style, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator, + lv_next_rtf_offset TYPE i, + lv_tabix TYPE i, + lv_value TYPE string, + lv_val_length TYPE i, + ls_rtf LIKE LINE OF ct_rtf. + FIELD-SYMBOLS: LIKE LINE OF ct_rtf. + + IF ip_style IS NOT SUPPLIED. + ip_style = excel->get_default_style( ). + ENDIF. + + lo_iterator = excel->get_styles_iterator( ). + WHILE lo_iterator->has_next( ) = abap_true. + lo_style ?= lo_iterator->get_next( ). + IF lo_style->get_guid( ) = ip_style. + EXIT. + ENDIF. + CLEAR lo_style. + ENDWHILE. + + lv_next_rtf_offset = 0. + LOOP AT ct_rtf ASSIGNING . + lv_tabix = sy-tabix. + IF lv_next_rtf_offset < -offset. + ls_rtf-offset = lv_next_rtf_offset. + ls_rtf-length = -offset - lv_next_rtf_offset. + ls_rtf-font = lo_style->font->get_structure( ). + INSERT ls_rtf INTO ct_rtf INDEX lv_tabix. + ELSEIF lv_next_rtf_offset > -offset. + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = 'Gaps or overlaps in RTF data offset/length specs'. + ENDIF. + lv_next_rtf_offset = -offset + -length. + ENDLOOP. + + lv_value = ip_value. + lv_val_length = strlen( lv_value ). + IF lv_val_length > lv_next_rtf_offset. + ls_rtf-offset = lv_next_rtf_offset. + ls_rtf-length = lv_val_length - lv_next_rtf_offset. + ls_rtf-font = lo_style->font->get_structure( ). + INSERT ls_rtf INTO TABLE ct_rtf. + ELSEIF lv_val_length > lv_next_rtf_offset. + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = 'RTF specs length is not equal to value length'. + ENDIF. + + ENDMETHOD. + + + METHOD check_table_overlapping. + + DATA: lv_errormessage TYPE string, + lv_column_int TYPE yecb_cell_column, + lv_maxcol TYPE i. + FIELD-SYMBOLS: + TYPE yecb_s_table_settings. + + lv_column_int = ycl_ecb_common=>convert_column2int( is_table_settings-top_left_column ). + lv_maxcol = ycl_ecb_common=>convert_column2int( is_table_settings-bottom_right_column ). + + LOOP AT it_other_table_settings ASSIGNING . + + IF ( ( is_table_settings-top_left_row GE -top_left_row + AND is_table_settings-top_left_row LE -bottom_right_row ) + OR + ( is_table_settings-bottom_right_row GE -top_left_row + AND is_table_settings-bottom_right_row LE -bottom_right_row ) + ) + AND + ( ( lv_column_int GE ycl_ecb_common=>convert_column2int( -top_left_column ) + AND lv_column_int LE ycl_ecb_common=>convert_column2int( -bottom_right_column ) ) + OR + ( lv_maxcol GE ycl_ecb_common=>convert_column2int( -top_left_column ) + AND lv_maxcol LE ycl_ecb_common=>convert_column2int( -bottom_right_column ) ) + ). + lv_errormessage = 'Table overlaps with previously bound table and will not be added to worksheet.'(400). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + + ENDLOOP. + + ENDMETHOD. + + + METHOD class_constructor. + + 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) }|. + + ENDMETHOD. + + + METHOD clear_initial_colorxfields. + + IF is_color-rgb IS INITIAL. + CLEAR cs_xcolor-rgb. + ENDIF. + IF is_color-indexed IS INITIAL. + CLEAR cs_xcolor-indexed. + ENDIF. + IF is_color-theme IS INITIAL. + CLEAR cs_xcolor-theme. + ENDIF. + IF is_color-tint IS INITIAL. + CLEAR cs_xcolor-tint. + ENDIF. + + ENDMETHOD. + + + METHOD constructor. + DATA: lv_title TYPE yecb_sheet_title. + + me->excel = ip_excel. + + me->guid = ycl_ecb_obsolete_func_wrap=>guid_create( ). " ins issue #379 - replacement for outdated function call + + IF ip_title IS NOT INITIAL. + lv_title = ip_title. + ELSE. + lv_title = me->generate_title( ). " ins issue #154 - Names of worksheets + ENDIF. + + me->set_title( ip_title = lv_title ). + + CREATE OBJECT sheet_setup. + CREATE OBJECT styles_cond. + CREATE OBJECT data_validations. + CREATE OBJECT tables. + CREATE OBJECT columns. + CREATE OBJECT rows. + CREATE OBJECT ranges. " issue #163 + CREATE OBJECT mo_pagebreaks. + CREATE OBJECT drawings + EXPORTING + ip_type = ycl_ecb_drawing=>type_image. + CREATE OBJECT charts + EXPORTING + ip_type = ycl_ecb_drawing=>type_chart. + me->yif_ecb_sheet_protection~initialize( ). + me->yif_ecb_sheet_properties~initialize( ). + CREATE OBJECT hyperlinks. + CREATE OBJECT comments. " (+) Issue #180 + +* initialize active cell coordinates + active_cell-cell_row = 1. + active_cell-cell_column = 1. + +* inizialize dimension range + lower_cell-cell_row = 1. + lower_cell-cell_column = 1. + upper_cell-cell_row = 1. + upper_cell-cell_column = 1. + + ENDMETHOD. "CONSTRUCTOR + + + METHOD convert_to_table. + + TYPES: + BEGIN OF ts_field_conv, + fieldname TYPE x031l-fieldname, + convexit TYPE x031l-convexit, + END OF ts_field_conv, + BEGIN OF ts_style_conv, + cell_style TYPE yecb_s_cell_data-cell_style, + abap_type TYPE abap_typekind, + END OF ts_style_conv. + + DATA: + lv_row_int TYPE yecb_cell_row, + lv_column_int TYPE yecb_cell_column, + lv_column_alpha TYPE yecb_cell_column_alpha, + lt_field_catalog TYPE yecb_t_fieldcatalog, + ls_field_catalog TYPE yecb_s_fieldcatalog, + lv_value TYPE string, + lv_maxcol TYPE i, + lv_maxrow TYPE i, + lt_field_conv TYPE TABLE OF ts_field_conv, + lt_comp TYPE abap_component_tab, + ls_comp TYPE abap_componentdescr, + lo_line_type TYPE REF TO cl_abap_structdescr, + lo_tab_type TYPE REF TO cl_abap_tabledescr, + lr_data TYPE REF TO data, + lt_comp_view TYPE abap_component_view_tab, + ls_comp_view TYPE abap_simple_componentdescr, + lt_ddic_object TYPE dd_x031l_table, + lt_ddic_object_comp TYPE dd_x031l_table, + ls_ddic_object TYPE x031l, + lt_style_conv TYPE TABLE OF ts_style_conv, + ls_style_conv TYPE ts_style_conv, + ls_stylemapping TYPE yecb_s_stylemapping, + lv_format_code TYPE yecb_number_format, + lv_float TYPE f, + lt_map_excel_row TYPE TABLE OF i, + lv_index TYPE i, + lv_index_col TYPE i. + + FIELD-SYMBOLS: + TYPE STANDARD TABLE, + TYPE data, + TYPE data, + TYPE STANDARD TABLE, + TYPE data, + TYPE data, + TYPE ts_field_conv, + TYPE x031l, + TYPE yecb_s_cell_data, + TYPE abap_typekind. + + CLEAR: et_data, er_data. + + lv_maxcol = get_highest_column( ). + lv_maxrow = get_highest_row( ). + + + " Field catalog + lt_field_catalog = it_field_catalog. + IF lt_field_catalog IS INITIAL. + IF et_data IS SUPPLIED. + lt_field_catalog = ycl_ecb_common=>get_fieldcatalog( ip_table = et_data ). + ELSE. + DO lv_maxcol TIMES. + ls_field_catalog-position = sy-index. + ls_field_catalog-fieldname = 'COL_' && sy-index. + ls_field_catalog-dynpfld = abap_true. + APPEND ls_field_catalog TO lt_field_catalog. + ENDDO. + ENDIF. + ENDIF. + + SORT lt_field_catalog BY position. + DELETE lt_field_catalog WHERE dynpfld NE abap_true. + CHECK: lt_field_catalog IS NOT INITIAL. + + + " Create dynamic table string columns + ls_comp-type = cl_abap_elemdescr=>get_string( ). + LOOP AT lt_field_catalog INTO ls_field_catalog. + ls_comp-name = ls_field_catalog-fieldname. + APPEND ls_comp TO lt_comp. + ENDLOOP. + lo_line_type = cl_abap_structdescr=>create( lt_comp ). + lo_tab_type = cl_abap_tabledescr=>create( lo_line_type ). + CREATE DATA er_data TYPE HANDLE lo_tab_type. + ASSIGN er_data->* TO . + + + " Collect field conversion rules + IF et_data IS SUPPLIED. +* lt_ddic_object = get_ddic_object( et_data ). + lo_tab_type ?= cl_abap_tabledescr=>describe_by_data( et_data ). + lo_line_type ?= lo_tab_type->get_table_line_type( ). + lo_line_type->get_ddic_object( + RECEIVING + p_object = lt_ddic_object + EXCEPTIONS + OTHERS = 3 + ). + IF lt_ddic_object IS INITIAL. + lt_comp_view = lo_line_type->get_included_view( ). + LOOP AT lt_comp_view INTO ls_comp_view. + ls_comp_view-type->get_ddic_object( + RECEIVING + p_object = lt_ddic_object_comp + EXCEPTIONS + OTHERS = 3 + ). + IF lt_ddic_object_comp IS NOT INITIAL. + READ TABLE lt_ddic_object_comp INTO ls_ddic_object INDEX 1. + ls_ddic_object-fieldname = ls_comp_view-name. + APPEND ls_ddic_object TO lt_ddic_object. + ENDIF. + ENDLOOP. + ENDIF. + + SORT lt_ddic_object BY fieldname. + LOOP AT lt_field_catalog INTO ls_field_catalog. + APPEND INITIAL LINE TO lt_field_conv ASSIGNING . + MOVE-CORRESPONDING ls_field_catalog TO . + READ TABLE lt_ddic_object ASSIGNING WITH KEY fieldname = -fieldname BINARY SEARCH. + CHECK: sy-subrc EQ 0. + + ASSIGN ('CL_ABAP_TYPEDESCR=>TYPEKIND_INT8') TO . + IF sy-subrc <> 0. + ASSIGN space TO . "not used as typekind! + ENDIF. + + CASE -exid. + WHEN cl_abap_typedescr=>typekind_int + OR cl_abap_typedescr=>typekind_int1 + OR + OR cl_abap_typedescr=>typekind_int2 + OR cl_abap_typedescr=>typekind_packed + OR cl_abap_typedescr=>typekind_decfloat + OR cl_abap_typedescr=>typekind_decfloat16 + OR cl_abap_typedescr=>typekind_decfloat34 + OR cl_abap_typedescr=>typekind_float. + " Numbers + -convexit = cl_abap_typedescr=>typekind_float. + WHEN OTHERS. + -convexit = -convexit. + ENDCASE. + ENDLOOP. + ENDIF. + + " Date & Time in excel style + LOOP AT me->sheet_content ASSIGNING WHERE cell_style IS NOT INITIAL AND data_type IS INITIAL. + ls_style_conv-cell_style = -cell_style. + APPEND ls_style_conv TO lt_style_conv. + ENDLOOP. + IF lt_style_conv IS NOT INITIAL. + SORT lt_style_conv BY cell_style. + DELETE ADJACENT DUPLICATES FROM lt_style_conv COMPARING cell_style. + + LOOP AT lt_style_conv INTO ls_style_conv. + + ls_stylemapping = me->excel->get_style_to_guid( ls_style_conv-cell_style ). + lv_format_code = ls_stylemapping-complete_style-number_format-format_code. + " https://support.microsoft.com/en-us/office/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68 + IF lv_format_code CS ';'. + lv_format_code = lv_format_code(sy-fdpos). + ENDIF. + CHECK: lv_format_code NA '#?'. + + " Remove color pattern + REPLACE ALL OCCURRENCES OF REGEX '\[\L[^]]*\]' IN lv_format_code WITH ''. + + IF lv_format_code CA 'yd' OR lv_format_code EQ ycl_ecb_style_number_format=>c_format_date_std. + " DATE = yyyymmdd + ls_style_conv-abap_type = cl_abap_typedescr=>typekind_date. + ELSEIF lv_format_code CA 'hs'. + " TIME = hhmmss + ls_style_conv-abap_type = cl_abap_typedescr=>typekind_time. + ELSE. + DELETE lt_style_conv. + CONTINUE. + ENDIF. + + MODIFY lt_style_conv FROM ls_style_conv TRANSPORTING abap_type. + + ENDLOOP. + ENDIF. + + +*--------------------------------------------------------------------* +* Start of convert content +*--------------------------------------------------------------------* + READ TABLE me->sheet_content TRANSPORTING NO FIELDS WITH KEY cell_row = iv_begin_row. + IF sy-subrc EQ 0. + lv_index = sy-tabix. + ENDIF. + + LOOP AT me->sheet_content ASSIGNING FROM lv_index. + AT NEW cell_row. + IF iv_end_row <> 0 + AND -cell_row > iv_end_row. + EXIT. + ENDIF. + " New line + APPEND INITIAL LINE TO ASSIGNING . + lv_index = sy-tabix. + ENDAT. + + IF -cell_value IS NOT INITIAL. + ASSIGN COMPONENT -cell_column OF STRUCTURE TO . + IF sy-subrc EQ 0. + " value + = -cell_value. + + " field conversion + READ TABLE lt_field_conv ASSIGNING INDEX -cell_column. + IF sy-subrc EQ 0 AND -convexit IS NOT INITIAL. + CASE -convexit. + WHEN cl_abap_typedescr=>typekind_float. + lv_float = ycl_ecb_common=>excel_string_to_number( -cell_value ). + = |{ lv_float NUMBER = RAW }|. + WHEN 'ALPHA'. + CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' + EXPORTING + input = -cell_value + IMPORTING + output = . + ENDCASE. + ENDIF. + + " style conversion + IF -cell_style IS NOT INITIAL. + READ TABLE lt_style_conv INTO ls_style_conv WITH KEY cell_style = -cell_style BINARY SEARCH. + IF sy-subrc EQ 0. + CASE ls_style_conv-abap_type. + WHEN cl_abap_typedescr=>typekind_date. + = ycl_ecb_common=>excel_string_to_date( -cell_value ). + WHEN cl_abap_typedescr=>typekind_time. + = ycl_ecb_common=>excel_string_to_time( -cell_value ). + ENDCASE. + ENDIF. + ENDIF. + + " condense + CONDENSE . + ENDIF. + ENDIF. + + AT END OF cell_row. + " Delete empty line + IF IS INITIAL. + DELETE INDEX lv_index. + ELSE. + APPEND -cell_row TO lt_map_excel_row. + ENDIF. + ENDAT. + ENDLOOP. +*--------------------------------------------------------------------* +* End of convert content +*--------------------------------------------------------------------* + + + IF et_data IS SUPPLIED. +* MOVE-CORRESPONDING TO et_data. + LOOP AT ASSIGNING . + APPEND INITIAL LINE TO et_data ASSIGNING . + MOVE-CORRESPONDING TO . + ENDLOOP. + ENDIF. + + " Apply conversion exit. + LOOP AT lt_field_conv ASSIGNING + WHERE convexit = 'ALPHA'. + LOOP AT et_data ASSIGNING . + ASSIGN COMPONENT -fieldname OF STRUCTURE TO . + CHECK: sy-subrc EQ 0 AND IS NOT INITIAL. + CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' + EXPORTING + input = + IMPORTING + output = . + ENDLOOP. + ENDLOOP. + + ENDMETHOD. + + + METHOD create_data_conv_exit_length. + DATA: lo_addit TYPE REF TO cl_abap_elemdescr, + ls_dfies TYPE dfies, + l_function TYPE funcname, + l_value(50) TYPE c. + + lo_addit ?= cl_abap_typedescr=>describe_by_data( ip_value ). + lo_addit->get_ddic_field( RECEIVING p_flddescr = ls_dfies + EXCEPTIONS not_found = 1 + no_ddic_type = 2 + OTHERS = 3 ) . + IF sy-subrc = 0 AND ls_dfies-convexit IS NOT INITIAL. + CREATE DATA ep_value TYPE c LENGTH ls_dfies-outputlen. + ELSE. + CREATE DATA ep_value LIKE ip_value. + ENDIF. + + ENDMETHOD. + + + METHOD delete_merge. + + DATA: lv_column TYPE i. +*--------------------------------------------------------------------* +* If cell information is passed delete merge including this cell, +* otherwise delete all merges +*--------------------------------------------------------------------* + IF ip_cell_column IS INITIAL + OR ip_cell_row IS INITIAL. + CLEAR me->mt_merged_cells. + ELSE. + lv_column = ycl_ecb_common=>convert_column2int( ip_cell_column ). + + LOOP AT me->mt_merged_cells TRANSPORTING NO FIELDS + WHERE row_from <= ip_cell_row AND row_to >= ip_cell_row + AND col_from <= lv_column AND col_to >= lv_column. + DELETE me->mt_merged_cells. + EXIT. + ENDLOOP. + ENDIF. + + ENDMETHOD. "DELETE_MERGE + + + METHOD delete_row_outline. + + DELETE me->mt_row_outlines WHERE row_from = iv_row_from + AND row_to = iv_row_to. + IF sy-subrc <> 0. " didn't find outline that was to be deleted + ycx_ecb=>raise_text( 'Row outline to be deleted does not exist' ). + ENDIF. + + ENDMETHOD. "DELETE_ROW_OUTLINE + + + METHOD freeze_panes. + + IF ip_num_columns IS NOT SUPPLIED AND ip_num_rows IS NOT SUPPLIED. + ycx_ecb=>raise_text( 'Pleas provide number of rows and/or columns to freeze' ). + ENDIF. + + IF ip_num_columns IS SUPPLIED AND ip_num_columns <= 0. + ycx_ecb=>raise_text( 'Number of columns to freeze should be positive' ). + ENDIF. + + IF ip_num_rows IS SUPPLIED AND ip_num_rows <= 0. + ycx_ecb=>raise_text( 'Number of rows to freeze should be positive' ). + ENDIF. + + freeze_pane_cell_column = ip_num_columns + 1. + freeze_pane_cell_row = ip_num_rows + 1. + ENDMETHOD. "FREEZE_PANES + + + METHOD generate_title. + DATA: lo_worksheets_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_worksheet TYPE REF TO ycl_ecb_worksheet. + + DATA: t_titles TYPE HASHED TABLE OF yecb_sheet_title WITH UNIQUE KEY table_line, + title TYPE yecb_sheet_title, + sheetnumber TYPE i. + +* Get list of currently used titles + lo_worksheets_iterator = me->excel->get_worksheets_iterator( ). + WHILE lo_worksheets_iterator->has_next( ) = abap_true. + lo_worksheet ?= lo_worksheets_iterator->get_next( ). + title = lo_worksheet->get_title( ). + INSERT title INTO TABLE t_titles. + ADD 1 TO sheetnumber. + ENDWHILE. + +* Now build sheetnumber. Increase counter until we hit a number that is not used so far + ADD 1 TO sheetnumber. " Start counting with next number + DO. + title = sheetnumber. + SHIFT title LEFT DELETING LEADING space. + CONCATENATE 'Sheet'(001) title INTO ep_title. + INSERT ep_title INTO TABLE t_titles. + IF sy-subrc = 0. " Title not used so far --> take it + EXIT. + ENDIF. + + ADD 1 TO sheetnumber. + ENDDO. + ENDMETHOD. "GENERATE_TITLE + + + METHOD get_active_cell. + + DATA: lv_active_column TYPE yecb_cell_column_alpha, + lv_active_row TYPE string. + + lv_active_column = ycl_ecb_common=>convert_column2alpha( active_cell-cell_column ). + lv_active_row = active_cell-cell_row. + SHIFT lv_active_row RIGHT DELETING TRAILING space. + SHIFT lv_active_row LEFT DELETING LEADING space. + CONCATENATE lv_active_column lv_active_row INTO ep_active_cell. + + ENDMETHOD. "GET_ACTIVE_CELL + + + METHOD get_cell. + + DATA: lv_column TYPE yecb_cell_column, + lv_row TYPE yecb_cell_row, + ls_sheet_content TYPE yecb_s_cell_data. + + normalize_columnrow_parameter( EXPORTING ip_columnrow = ip_columnrow + ip_column = ip_column + ip_row = ip_row + IMPORTING ep_column = lv_column + ep_row = lv_row ). + + READ TABLE sheet_content INTO ls_sheet_content WITH TABLE KEY cell_row = lv_row + cell_column = lv_column. + + ep_rc = sy-subrc. + ep_value = ls_sheet_content-cell_value. + ep_guid = ls_sheet_content-cell_style. " issue 139 - added this to be used for columnwidth calculation + ep_formula = ls_sheet_content-cell_formula. + IF et_rtf IS SUPPLIED AND ls_sheet_content-rtf_tab IS NOT INITIAL. + et_rtf = ls_sheet_content-rtf_tab. + ENDIF. + + " Addition to solve issue #120, contribution by Stefan Schmöcker + DATA: style_iterator TYPE REF TO ycl_ecb_collection_iterator, + style TYPE REF TO ycl_ecb_style. + IF ep_style IS SUPPLIED. + CLEAR ep_style. + style_iterator = me->excel->get_styles_iterator( ). + WHILE style_iterator->has_next( ) = abap_true. + style ?= style_iterator->get_next( ). + IF style->get_guid( ) = ls_sheet_content-cell_style. + ep_style = style. + EXIT. + ENDIF. + ENDWHILE. + ENDIF. + ENDMETHOD. "GET_CELL + + + METHOD get_column. + + DATA: lv_column TYPE yecb_cell_column. + + lv_column = ycl_ecb_common=>convert_column2int( ip_column ). + + eo_column = me->columns->get( ip_index = lv_column ). + + IF eo_column IS NOT BOUND. + eo_column = me->add_new_column( ip_column ). + ENDIF. + + ENDMETHOD. "GET_COLUMN + + + METHOD get_columns. + + DATA: columns TYPE TABLE OF i, + column TYPE i. + FIELD-SYMBOLS: + TYPE yecb_s_cell_data. + + LOOP AT sheet_content ASSIGNING . + COLLECT -cell_column INTO columns. + ENDLOOP. + + LOOP AT columns INTO column. + " This will create the column instance if it doesn't exist + get_column( column ). + ENDLOOP. + + eo_columns = me->columns. + ENDMETHOD. "GET_COLUMNS + + + METHOD get_columns_iterator. + + get_columns( ). + eo_iterator = me->columns->get_iterator( ). + + ENDMETHOD. "GET_COLUMNS_ITERATOR + + + METHOD get_comments. + DATA: lo_comment TYPE REF TO ycl_ecb_comment, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator. + + CREATE OBJECT r_comments. + + lo_iterator = comments->get_iterator( ). + WHILE lo_iterator->has_next( ) = abap_true. + lo_comment ?= lo_iterator->get_next( ). + r_comments->include( lo_comment ). + ENDWHILE. + + ENDMETHOD. "get_comments + + + METHOD get_comments_iterator. + eo_iterator = comments->get_iterator( ). + + ENDMETHOD. "get_comments_iterator + + + METHOD get_data_validations_iterator. + + eo_iterator = me->data_validations->get_iterator( ). + ENDMETHOD. "GET_DATA_VALIDATIONS_ITERATOR + + + METHOD get_data_validations_size. + ep_size = me->data_validations->size( ). + ENDMETHOD. "GET_DATA_VALIDATIONS_SIZE + + + METHOD get_default_column. + IF me->column_default IS NOT BOUND. + CREATE OBJECT me->column_default + EXPORTING + ip_index = 'A' " ???? + ip_worksheet = me + ip_excel = me->excel. + ENDIF. + + eo_column = me->column_default. + ENDMETHOD. "GET_DEFAULT_COLUMN + + + METHOD get_default_excel_date_format. + CONSTANTS: c_lang_e TYPE lang VALUE 'E'. + + IF default_excel_date_format IS NOT INITIAL. + ep_default_excel_date_format = default_excel_date_format. + RETURN. + ENDIF. + + "try to get defaults + TRY. + cl_abap_datfm=>get_date_format_des( EXPORTING im_langu = c_lang_e + IMPORTING ex_dateformat = default_excel_date_format ). + CATCH cx_abap_datfm_format_unknown. + + ENDTRY. + + " and fallback to fixed format + IF default_excel_date_format IS INITIAL. + default_excel_date_format = ycl_ecb_style_number_format=>c_format_date_ddmmyyyydot. + ENDIF. + + ep_default_excel_date_format = default_excel_date_format. + ENDMETHOD. "GET_DEFAULT_EXCEL_DATE_FORMAT + + + METHOD get_default_excel_time_format. + DATA: l_timefm TYPE xutimefm. + + IF default_excel_time_format IS NOT INITIAL. + ep_default_excel_time_format = default_excel_time_format. + RETURN. + ENDIF. + +* Let's get default + l_timefm = cl_abap_timefm=>get_environment_timefm( ). + CASE l_timefm. + WHEN 0. +*0 24 Hour Format (Example: 12:05:10) + default_excel_time_format = ycl_ecb_style_number_format=>c_format_date_time6. + WHEN 1. +*1 12 Hour Format (Example: 12:05:10 PM) + default_excel_time_format = ycl_ecb_style_number_format=>c_format_date_time2. + WHEN 2. +*2 12 Hour Format (Example: 12:05:10 pm) for now all the same. no chnage upper lower + default_excel_time_format = ycl_ecb_style_number_format=>c_format_date_time2. + WHEN 3. +*3 Hours from 0 to 11 (Example: 00:05:10 PM) for now all the same. no chnage upper lower + default_excel_time_format = ycl_ecb_style_number_format=>c_format_date_time2. + WHEN 4. +*4 Hours from 0 to 11 (Example: 00:05:10 pm) for now all the same. no chnage upper lower + default_excel_time_format = ycl_ecb_style_number_format=>c_format_date_time2. + WHEN OTHERS. + " and fallback to fixed format + default_excel_time_format = ycl_ecb_style_number_format=>c_format_date_time6. + ENDCASE. + + ep_default_excel_time_format = default_excel_time_format. + ENDMETHOD. "GET_DEFAULT_EXCEL_TIME_FORMAT + + + METHOD get_default_row. + IF me->row_default IS NOT BOUND. + CREATE OBJECT me->row_default. + ENDIF. + + eo_row = me->row_default. + ENDMETHOD. "GET_DEFAULT_ROW + + + METHOD get_dimension_range. + + me->update_dimension_range( ). + IF upper_cell EQ lower_cell. "only one cell + " Worksheet not filled + IF upper_cell-cell_coords IS INITIAL. + ep_dimension_range = 'A1'. + ELSE. + ep_dimension_range = upper_cell-cell_coords. + ENDIF. + ELSE. + CONCATENATE upper_cell-cell_coords ':' lower_cell-cell_coords INTO ep_dimension_range. + ENDIF. + + ENDMETHOD. "GET_DIMENSION_RANGE + + + METHOD get_drawings. + + DATA: lo_drawing TYPE REF TO ycl_ecb_drawing, + lo_iterator TYPE REF TO ycl_ecb_collection_iterator. + + CASE ip_type. + WHEN ycl_ecb_drawing=>type_image. + r_drawings = drawings. + WHEN ycl_ecb_drawing=>type_chart. + r_drawings = charts. + WHEN space. + CREATE OBJECT r_drawings + EXPORTING + ip_type = ''. + + lo_iterator = drawings->get_iterator( ). + WHILE lo_iterator->has_next( ) = abap_true. + lo_drawing ?= lo_iterator->get_next( ). + r_drawings->include( lo_drawing ). + ENDWHILE. + lo_iterator = charts->get_iterator( ). + WHILE lo_iterator->has_next( ) = abap_true. + lo_drawing ?= lo_iterator->get_next( ). + r_drawings->include( lo_drawing ). + ENDWHILE. + WHEN OTHERS. + ENDCASE. + ENDMETHOD. "GET_DRAWINGS + + + METHOD get_drawings_iterator. + CASE ip_type. + WHEN ycl_ecb_drawing=>type_image. + eo_iterator = drawings->get_iterator( ). + WHEN ycl_ecb_drawing=>type_chart. + eo_iterator = charts->get_iterator( ). + ENDCASE. + ENDMETHOD. "GET_DRAWINGS_ITERATOR + + + METHOD get_freeze_cell. + ep_row = me->freeze_pane_cell_row. + ep_column = me->freeze_pane_cell_column. + ENDMETHOD. "GET_FREEZE_CELL + + + METHOD get_guid. + + ep_guid = me->guid. + + ENDMETHOD. "GET_GUID + + + METHOD get_header_footer_drawings. + DATA: ls_odd_header TYPE yecb_s_worksheet_head_foot, + ls_odd_footer TYPE yecb_s_worksheet_head_foot, + ls_even_header TYPE yecb_s_worksheet_head_foot, + ls_even_footer TYPE yecb_s_worksheet_head_foot, + ls_hd_ft TYPE yecb_s_worksheet_head_foot. + + FIELD-SYMBOLS: TYPE yecb_s_drawings. + + me->sheet_setup->get_header_footer( IMPORTING ep_odd_header = ls_odd_header + ep_odd_footer = ls_odd_footer + ep_even_header = ls_even_header + ep_even_footer = ls_even_footer ). + +********************************************************************** +*** Odd header + ls_hd_ft = ls_odd_header. + IF ls_hd_ft-left_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-left_image. + ENDIF. + IF ls_hd_ft-right_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-right_image. + ENDIF. + IF ls_hd_ft-center_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-center_image. + ENDIF. + +********************************************************************** +*** Odd footer + ls_hd_ft = ls_odd_footer. + IF ls_hd_ft-left_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-left_image. + ENDIF. + IF ls_hd_ft-right_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-right_image. + ENDIF. + IF ls_hd_ft-center_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-center_image. + ENDIF. + +********************************************************************** +*** Even header + ls_hd_ft = ls_even_header. + IF ls_hd_ft-left_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-left_image. + ENDIF. + IF ls_hd_ft-right_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-right_image. + ENDIF. + IF ls_hd_ft-center_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-center_image. + ENDIF. + +********************************************************************** +*** Even footer + ls_hd_ft = ls_even_footer. + IF ls_hd_ft-left_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-left_image. + ENDIF. + IF ls_hd_ft-right_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-right_image. + ENDIF. + IF ls_hd_ft-center_image IS NOT INITIAL. + APPEND INITIAL LINE TO rt_drawings ASSIGNING . + -drawing = ls_hd_ft-center_image. + ENDIF. + + ENDMETHOD. "get_header_footer_drawings + + + METHOD get_highest_column. + me->update_dimension_range( ). + r_highest_column = me->lower_cell-cell_column. + ENDMETHOD. "GET_HIGHEST_COLUMN + + + METHOD get_highest_row. + me->update_dimension_range( ). + r_highest_row = me->lower_cell-cell_row. + ENDMETHOD. "GET_HIGHEST_ROW + + + METHOD get_hyperlinks_iterator. + eo_iterator = hyperlinks->get_iterator( ). + ENDMETHOD. "GET_HYPERLINKS_ITERATOR + + + METHOD get_hyperlinks_size. + ep_size = hyperlinks->size( ). + ENDMETHOD. "GET_HYPERLINKS_SIZE + + + METHOD get_ignored_errors. + rt_ignored_errors = mt_ignored_errors. + ENDMETHOD. + + + METHOD get_merge. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_merged_cells. + + DATA: lv_col_from TYPE string, + lv_col_to TYPE string, + lv_row_from TYPE string, + lv_row_to TYPE string, + lv_merge_range TYPE string. + + LOOP AT me->mt_merged_cells ASSIGNING . + + lv_col_from = ycl_ecb_common=>convert_column2alpha( -col_from ). + lv_col_to = ycl_ecb_common=>convert_column2alpha( -col_to ). + lv_row_from = -row_from. + lv_row_to = -row_to . + CONCATENATE lv_col_from lv_row_from ':' lv_col_to lv_row_to + INTO lv_merge_range. + CONDENSE lv_merge_range NO-GAPS. + APPEND lv_merge_range TO merge_range. + + ENDLOOP. + + ENDMETHOD. "GET_MERGE + + + METHOD get_pagebreaks. + ro_pagebreaks = mo_pagebreaks. + ENDMETHOD. "GET_PAGEBREAKS + + + METHOD get_ranges_iterator. + + eo_iterator = me->ranges->get_iterator( ). + + ENDMETHOD. "GET_RANGES_ITERATOR + + + METHOD get_row. + eo_row = me->rows->get( ip_index = ip_row ). + + IF eo_row IS NOT BOUND. + eo_row = me->add_new_row( ip_row ). + ENDIF. + ENDMETHOD. "GET_ROW + + + METHOD get_rows. + + DATA: row TYPE i. + FIELD-SYMBOLS: TYPE yecb_s_cell_data. + + IF sheet_content IS NOT INITIAL. + + row = 0. + DO. + " Find the next row + READ TABLE sheet_content ASSIGNING WITH KEY cell_row = row. + CASE sy-subrc. + WHEN 4. + " row doesn't exist, but it exists another row, SY-TABIX points to the first cell in this row. + READ TABLE sheet_content ASSIGNING INDEX sy-tabix. + ASSERT sy-subrc = 0. + row = -cell_row. + WHEN 8. + " it was the last available row + EXIT. + ENDCASE. + " This will create the row instance if it doesn't exist + get_row( row ). + row = row + 1. + ENDDO. + + ENDIF. + + eo_rows = me->rows. + ENDMETHOD. "GET_ROWS + + + METHOD get_rows_iterator. + + get_rows( ). + eo_iterator = me->rows->get_iterator( ). + + ENDMETHOD. "GET_ROWS_ITERATOR + + + METHOD get_row_outlines. + + rt_row_outlines = me->mt_row_outlines. + + ENDMETHOD. "GET_ROW_OUTLINES + + + METHOD get_style_cond. + + DATA: lo_style_iterator TYPE REF TO ycl_ecb_collection_iterator, + lo_style_cond TYPE REF TO ycl_ecb_style_cond. + + lo_style_iterator = me->get_style_cond_iterator( ). + WHILE lo_style_iterator->has_next( ) = abap_true. + lo_style_cond ?= lo_style_iterator->get_next( ). + IF lo_style_cond->get_guid( ) = ip_guid. + eo_style_cond = lo_style_cond. + EXIT. + ENDIF. + ENDWHILE. + + ENDMETHOD. "GET_STYLE_COND + + + METHOD get_style_cond_iterator. + + eo_iterator = styles_cond->get_iterator( ). + ENDMETHOD. "GET_STYLE_COND_ITERATOR + + + METHOD get_tabcolor. + ev_tabcolor = me->tabcolor. + ENDMETHOD. "GET_TABCOLOR + + + METHOD get_table. +*--------------------------------------------------------------------* +* Comment D. Rauchenstein +* With this method, we get a fully functional Excel Upload, which solves +* a few issues of the other excel upload tools +* ZBCABA_ALSM_EXCEL_UPLOAD_EXT: Reads only up to 50 signs per Cell, Limit +* in row-Numbers. Other have Limitations of Lines, or you are not able +* to ignore filters or choosing the right tab. +* +* To get a fully functional XLSX Upload, you can use it e.g. with method +* CL_EXCEL_READER_2007->ZIF_EXCEL_READER~LOAD_FILE() +*--------------------------------------------------------------------* + + FIELD-SYMBOLS: TYPE data. + FIELD-SYMBOLS: TYPE data. + + 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 yecb_cell_column. + DATA lv_max_row TYPE int4. + DATA lv_delta_col TYPE int4. + DATA lv_value TYPE yecb_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. + DATA lv_tabix TYPE i. + + lv_max_col = me->get_highest_column( ). + IF iv_max_col IS SUPPLIED AND iv_max_col < lv_max_col. + lv_max_col = iv_max_col. + ENDIF. + lv_max_row = me->get_highest_row( ). + IF iv_max_row IS SUPPLIED AND iv_max_row < lv_max_row. + lv_max_row = iv_max_row. + ENDIF. + +*--------------------------------------------------------------------* +* 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. + + + 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. + + lv_errormessage = 'Error at inserting new Line to internal Table'(002). + ycx_ecb=>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). + ycx_ecb=>raise_text( lv_errormessage ). + ELSE. +*--------------------------------------------------------------------* +*now we are ready for handle the table data +*--------------------------------------------------------------------* + CLEAR et_table. +*--------------------------------------------------------------------* +* Handle each Row until end on right side +*--------------------------------------------------------------------* + 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. + + 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). + ycx_ecb=>raise_text( lv_errormessage ). + 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_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. + ycx_ecb=>raise_text( lv_errormessage ). + 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 + ). + IF lv_rc <> 0 + AND lv_rc <> 4 "No found error means, zero/no value in cell + AND lv_rc <> 8. "rc is 8 when the last row contains cells with zero / no values + 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. + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + + TRY. + DESCRIBE FIELD TYPE lv_type. + IF lv_type = 'D'. + = ycl_ecb_common=>excel_string_to_date( ip_value = lv_value ). + ELSE. + = 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 + ENDIF. + CATCH cx_sy_conversion_error INTO lx_conversion_error. + "Another try with conversion to float... + 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. + ADD 1 TO lv_actual_row. + ENDWHILE. + + IF iv_skip_bottom_empty_rows = abap_true. + lv_tabix = lines( et_table ). + WHILE lv_tabix >= 1. + READ TABLE et_table INDEX lv_tabix ASSIGNING . + ASSERT sy-subrc = 0. + IF IS NOT INITIAL. + EXIT. + ENDIF. + DELETE et_table INDEX lv_tabix. + lv_tabix = lv_tabix - 1. + ENDWHILE. + ENDIF. + + ENDIF. + + + ENDIF. + + 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. + ycx_ecb=>raise_text( lv_errormessage ). + 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. + ycx_ecb=>raise_text( lv_errormessage ). + CATCH cx_sy_assign_out_of_range. + lv_errormessage = 'Internal table has less columns than excel'(003). + ycx_ecb=>raise_text( lv_errormessage ). + 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. + ycx_ecb=>raise_text( lv_errormessage ). + + ENDTRY. + ENDMETHOD. "get_table + + + METHOD get_tables_iterator. + eo_iterator = tables->get_iterator( ). + ENDMETHOD. "GET_TABLES_ITERATOR + + + METHOD get_tables_size. + ep_size = tables->size( ). + ENDMETHOD. "GET_TABLES_SIZE + + + METHOD get_title. + DATA lv_value TYPE string. + IF ip_escaped EQ abap_true. + lv_value = me->title. + ep_title = ycl_ecb_common=>escape_string( lv_value ). + ELSE. + ep_title = me->title. + ENDIF. + ENDMETHOD. "GET_TITLE + + + METHOD get_value_type. + DATA: lo_addit TYPE REF TO cl_abap_elemdescr, + ls_dfies TYPE dfies, + l_function TYPE funcname, + l_value(50) TYPE c. + + ep_value = ip_value. + ep_value_type = cl_abap_typedescr=>typekind_string. " Thats our default if something goes wrong. + + TRY. + lo_addit ?= cl_abap_typedescr=>describe_by_data( ip_value ). + CATCH cx_sy_move_cast_error. + CLEAR lo_addit. + ENDTRY. + IF lo_addit IS BOUND. + lo_addit->get_ddic_field( RECEIVING p_flddescr = ls_dfies + EXCEPTIONS not_found = 1 + no_ddic_type = 2 + OTHERS = 3 ) . + IF sy-subrc = 0. + ep_value_type = ls_dfies-inttype. + + IF ls_dfies-convexit IS NOT INITIAL. +* We need to convert with output conversion function + CONCATENATE 'CONVERSION_EXIT_' ls_dfies-convexit '_OUTPUT' INTO l_function. + SELECT SINGLE funcname INTO l_function + FROM tfdir + WHERE funcname = l_function. + IF sy-subrc = 0. + CALL FUNCTION l_function + EXPORTING + input = ip_value + IMPORTING + output = l_value + EXCEPTIONS + OTHERS = 1. + IF sy-subrc <> 0. + ELSE. + TRY. + ep_value = l_value. + CATCH cx_root. + ep_value = ip_value. + ENDTRY. + ENDIF. + ENDIF. + ENDIF. + ELSE. + ep_value_type = lo_addit->get_data_type_kind( ip_value ). + ENDIF. + ENDIF. + + ENDMETHOD. "GET_VALUE_TYPE + + + METHOD is_cell_merged. + + DATA: lv_column TYPE i. + + FIELD-SYMBOLS: LIKE LINE OF me->mt_merged_cells. + + lv_column = ycl_ecb_common=>convert_column2int( ip_column ). + + rp_is_merged = abap_false. " Assume not in merged area + + LOOP AT me->mt_merged_cells ASSIGNING . + + IF -col_from <= lv_column + AND -col_to >= lv_column + AND -row_from <= ip_row + AND -row_to >= ip_row. + rp_is_merged = abap_true. " until we are proven different + RETURN. + ENDIF. + + ENDLOOP. + + ENDMETHOD. "IS_CELL_MERGED + + + METHOD move_supplied_borders. + + DATA: ls_borderx TYPE yecb_s_cstylex_border. + + IF iv_border_supplied = abap_true. " only act if parameter was supplied + IF iv_xborder_supplied = abap_true. " + ls_borderx = is_xborder. " use supplied x-parameter + ELSE. + CLEAR ls_borderx WITH 'X'. " <============================== DDIC structure enh. category to set? + " clear in a way that would be expected to work easily + IF is_border-border_style IS INITIAL. + CLEAR ls_borderx-border_style. + ENDIF. + clear_initial_colorxfields( + EXPORTING + is_color = is_border-border_color + CHANGING + cs_xcolor = ls_borderx-border_color ). + ENDIF. + MOVE-CORRESPONDING is_border TO cs_complete_style_border. + MOVE-CORRESPONDING ls_borderx TO cs_complete_stylex_border. + ENDIF. + + ENDMETHOD. + + + METHOD normalize_column_heading_texts. + + DATA: lt_field_catalog TYPE yecb_t_fieldcatalog, + lv_value_lowercase TYPE string, + lv_scrtext_l_initial TYPE yecb_column_name, + lv_long_text TYPE string, + lv_max_length TYPE i, + lv_temp_length TYPE i, + lv_syindex TYPE c LENGTH 3, + lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line. + FIELD-SYMBOLS: TYPE yecb_s_fieldcatalog, + TYPE any, + TYPE any, + TYPE any. + + " Due to restrictions in new table object we cannot have two columns with the same name + " Check if a column with the same name exists, if exists add a counter + " If no medium description is provided we try to use small or long + + lt_field_catalog = it_field_catalog. + + LOOP AT lt_field_catalog ASSIGNING WHERE dynpfld EQ abap_true. + + IF -column_name IS INITIAL. + + CASE iv_default_descr. + WHEN 'M'. + ASSIGN -scrtext_m TO . + ASSIGN -scrtext_s TO . + ASSIGN -scrtext_l TO . + WHEN 'S'. + ASSIGN -scrtext_s TO . + ASSIGN -scrtext_m TO . + ASSIGN -scrtext_l TO . + WHEN 'L'. + ASSIGN -scrtext_l TO . + ASSIGN -scrtext_m TO . + ASSIGN -scrtext_s TO . + WHEN OTHERS. + ASSIGN -scrtext_m TO . + ASSIGN -scrtext_s TO . + ASSIGN -scrtext_l TO . + ENDCASE. + + IF IS NOT INITIAL. + -column_name = . + ELSEIF IS NOT INITIAL. + -column_name = . + ELSEIF IS NOT INITIAL. + -column_name = . + ELSE. + -column_name = 'Column'. " default value as Excel does + ENDIF. + ENDIF. + + lv_scrtext_l_initial = -column_name. + DESCRIBE FIELD -column_name LENGTH lv_max_length IN CHARACTER MODE. + DO. + lv_value_lowercase = -column_name. + TRANSLATE lv_value_lowercase TO LOWER CASE. + READ TABLE lt_column_name_buffer TRANSPORTING NO FIELDS WITH KEY table_line = lv_value_lowercase BINARY SEARCH. + IF sy-subrc <> 0. + INSERT lv_value_lowercase INTO TABLE lt_column_name_buffer. + EXIT. + ELSE. + lv_syindex = sy-index. + CONCATENATE lv_scrtext_l_initial lv_syindex INTO lv_long_text. + IF strlen( lv_long_text ) <= lv_max_length. + -column_name = lv_long_text. + ELSE. + lv_temp_length = strlen( lv_scrtext_l_initial ) - 1. + lv_scrtext_l_initial = substring( val = lv_scrtext_l_initial len = lv_temp_length ). + CONCATENATE lv_scrtext_l_initial lv_syindex INTO -column_name. + ENDIF. + ENDIF. + ENDDO. + + ENDLOOP. + + result = lt_field_catalog. + + ENDMETHOD. + + + METHOD normalize_columnrow_parameter. + + IF ( ( ip_column IS NOT INITIAL OR ip_row IS NOT INITIAL ) AND ip_columnrow IS NOT INITIAL ) + OR ( ip_column IS INITIAL AND ip_row IS INITIAL AND ip_columnrow IS INITIAL ). + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = 'Please provide either row and column, or cell reference'. + ENDIF. + + IF ip_columnrow IS NOT INITIAL. + ycl_ecb_common=>convert_columnrow2column_a_row( + EXPORTING + i_columnrow = ip_columnrow + IMPORTING + e_column_int = ep_column + e_row = ep_row ). + ELSE. + ep_column = ycl_ecb_common=>convert_column2int( ip_column ). + ep_row = ip_row. + ENDIF. + + ENDMETHOD. + + + METHOD normalize_range_parameter. + + DATA: lv_errormessage TYPE string. + + IF ( ( ip_column_start IS NOT INITIAL OR ip_column_end IS NOT INITIAL + OR ip_row IS NOT INITIAL OR ip_row_to IS NOT INITIAL ) AND ip_range IS NOT INITIAL ) + OR ( ip_column_start IS INITIAL AND ip_column_end IS INITIAL + AND ip_row IS INITIAL AND ip_row_to IS INITIAL AND ip_range IS INITIAL ). + RAISE EXCEPTION TYPE ycx_ecb + EXPORTING + error = 'Please provide either row and column interval, or range reference'. + ENDIF. + + IF ip_range IS NOT INITIAL. + ycl_ecb_common=>convert_range2column_a_row( + EXPORTING + i_range = ip_range + IMPORTING + e_column_start_int = ep_column_start + e_column_end_int = ep_column_end + e_row_start = ep_row + e_row_end = ep_row_to ). + ELSE. + IF ip_column_start IS INITIAL. + ep_column_start = ycl_ecb_common=>c_excel_sheet_min_col. + ELSE. + ep_column_start = ycl_ecb_common=>convert_column2int( ip_column_start ). + ENDIF. + IF ip_column_end IS INITIAL. + ep_column_end = ep_column_start. + ELSE. + ep_column_end = ycl_ecb_common=>convert_column2int( ip_column_end ). + ENDIF. + ep_row = ip_row. + IF ep_row IS INITIAL. + ep_row = ycl_ecb_common=>c_excel_sheet_min_row. + ENDIF. + ep_row_to = ip_row_to. + IF ep_row_to IS INITIAL. + ep_row_to = ep_row. + ENDIF. + ENDIF. + + IF ep_row > ep_row_to. + lv_errormessage = 'First row larger than last row'(405). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + + IF ep_column_start > ep_column_end. + lv_errormessage = 'First column larger than last column'(406). + ycx_ecb=>raise_text( lv_errormessage ). + ENDIF. + + ENDMETHOD. + + + METHOD normalize_style_parameter. + + DATA: lo_style_type TYPE REF TO cl_abap_typedescr. + FIELD-SYMBOLS: +