From ed0d3dd9ba1ea2c598b4193fd7065a6cf0b69968 Mon Sep 17 00:00:00 2001 From: Ivan Femia Date: Mon, 9 Apr 2012 12:57:24 +0000 Subject: [PATCH] Fix #159 git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@295 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL.slnk | 687 +++++------------------------------ ZA2X/PROG/ZDEMO_EXCEL.slnk | 3 +- ZA2X/PROG/ZDEMO_EXCEL36.slnk | 63 ++-- 3 files changed, 133 insertions(+), 620 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL.slnk b/ZA2X/CLAS/ZCL_EXCEL.slnk index e5c7584..06765c2 100644 --- a/ZA2X/CLAS/ZCL_EXCEL.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL.slnk @@ -1,17 +1,17 @@ - - + + - - - + + + class ZCL_EXCEL definition public final create public . +public section. *"* public components of class ZCL_EXCEL *"* do not include other source files here!!! -public section. interfaces ZIF_EXCEL_BOOK_PROPERTIES . interfaces ZIF_EXCEL_BOOK_PROTECTION . @@ -46,109 +46,6 @@ public section. raising ZCX_EXCEL . methods ADD_STATIC_STYLES . - methods BUILD_STYLE - importing - !IP_COPY_FROM_STYLE type ANY optional - !IP_COMPLETE type ZEXCEL_S_CSTYLE_COMPLETE optional - !IP_XCOMPLETE type ZEXCEL_S_CSTYLEX_COMPLETE optional - !IP_FONT type ZEXCEL_S_CSTYLE_FONT optional - !IP_XFONT type ZEXCEL_S_CSTYLEX_FONT optional - !IP_FILL type ZEXCEL_S_CSTYLE_FILL optional - !IP_XFILL type ZEXCEL_S_CSTYLEX_FILL optional - !IP_BORDERS type ZEXCEL_S_CSTYLE_BORDERS optional - !IP_XBORDERS type ZEXCEL_S_CSTYLEX_BORDERS optional - !IP_ALIGNMENT type ZEXCEL_S_CSTYLE_ALIGNMENT optional - !IP_XALIGNMENT type ZEXCEL_S_CSTYLEX_ALIGNMENT optional - !IP_NUMBER_FORMAT_FORMAT_CODE type ZEXCEL_NUMBER_FORMAT optional - !IP_PROTECTION type ZEXCEL_S_CSTYLE_PROTECTION optional - !IP_XPROTECTION type ZEXCEL_S_CSTYLEX_PROTECTION optional - !IP_FONT_BOLD type FLAG optional - !IP_FONT_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_FONT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_FONT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_FONT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_FONT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_FONT_FAMILY type ZEXCEL_STYLE_FONT_FAMILY optional - !IP_FONT_ITALIC type FLAG optional - !IP_FONT_NAME type ZEXCEL_STYLE_FONT_NAME optional - !IP_FONT_SCHEME type ZEXCEL_STYLE_FONT_SCHEME optional - !IP_FONT_SIZE type ZEXCEL_STYLE_FONT_SIZE optional - !IP_FONT_STRIKETHROUGH type FLAG optional - !IP_FONT_UNDERLINE type FLAG optional - !IP_FONT_UNDERLINE_MODE type ZEXCEL_STYLE_FONT_UNDERLINE optional - !IP_FILL_FILLTYPE type ZEXCEL_FILL_TYPE optional - !IP_FILL_ROTATION type ZEXCEL_ROTATION optional - !IP_FILL_FGCOLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_FILL_FGCOLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_FILL_FGCOLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_FILL_FGCOLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_FILL_FGCOLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_FILL_BGCOLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_FILL_BGCOLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_FILL_BGCOLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_FILL_BGCOLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_FILL_BGCOLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_ALLBORDERS type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_ALLBORDERS type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_DIAGONAL type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_DIAGONAL type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_DIAGONAL_MODE type ZEXCEL_DIAGONAL optional - !IP_BORDERS_DOWN type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_DOWN type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_LEFT type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_LEFT type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_RIGHT type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_RIGHT type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_BORDERS_TOP type ZEXCEL_S_CSTYLE_BORDER optional - !IP_XBORDERS_TOP type ZEXCEL_S_CSTYLEX_BORDER optional - !IP_ALIGNMENT_HORIZONTAL type ZEXCEL_ALIGNMENT optional - !IP_ALIGNMENT_VERTICAL type ZEXCEL_ALIGNMENT optional - !IP_ALIGNMENT_TEXTROTATION type ZEXCEL_TEXT_ROTATION optional - !IP_ALIGNMENT_WRAPTEXT type FLAG optional - !IP_ALIGNMENT_SHRINKTOFIT type FLAG optional - !IP_ALIGNMENT_INDENT type ZEXCEL_INDENT optional - !IP_PROTECTION_HIDDEN type ZEXCEL_CELL_PROTECTION optional - !IP_PROTECTION_LOCKED type ZEXCEL_CELL_PROTECTION optional - !IP_BORDERS_ALLBORDERS_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_ALLBORDERS_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_ALLBO_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_ALLBO_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_ALLBO_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_ALLBO_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_DIAGONAL_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_DIAGONAL_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_DIAGONAL_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_DIAGONAL_COLOR_INDE type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_DIAGONAL_COLOR_THEM type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_DIAGONAL_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_DOWN_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_DOWN_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_DOWN_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_DOWN_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_DOWN_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_DOWN_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_LEFT_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_LEFT_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_LEFT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_LEFT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_LEFT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_LEFT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_RIGHT_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_RIGHT_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_RIGHT_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_RIGHT_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_RIGHT_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_RIGHT_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - !IP_BORDERS_TOP_STYLE type ZEXCEL_BORDER optional - !IP_BORDERS_TOP_COLOR type ZEXCEL_S_STYLE_COLOR optional - !IP_BORDERS_TOP_COLOR_RGB type ZEXCEL_STYLE_COLOR_ARGB optional - !IP_BORDERS_TOP_COLOR_INDEXED type ZEXCEL_STYLE_COLOR_INDEXED optional - !IP_BORDERS_TOP_COLOR_THEME type ZEXCEL_STYLE_COLOR_THEME optional - !IP_BORDERS_TOP_COLOR_TINT type ZEXCEL_STYLE_COLOR_TINT optional - returning - value(EP_GUID) type ZEXCEL_CELL_STYLE - raising - ZCX_EXCEL . methods CONSTRUCTOR . methods GET_ACTIVE_SHEET_INDEX returning @@ -159,6 +56,9 @@ public section. methods GET_AUTOFILTERS_REFERENCE returning value(RO_AUTOFILTERS) type ref to ZCL_EXCEL_AUTOFILTERS . + methods GET_DEFAULT_STYLE + returning + value(EP_STYLE) type ZEXCEL_CELL_STYLE . methods GET_DRAWINGS_ITERATOR returning value(EO_ITERATOR) type ref to CL_OBJECT_COLLECTION_ITERATOR . @@ -210,16 +110,13 @@ public section. importing !IP_STYLE type ZEXCEL_CELL_STYLE raising - ZCX_EXCEL . - methods GET_DEFAULT_STYLE - returning - value(EP_STYLE) type ZEXCEL_CELL_STYLE . + ZCX_EXCEL . *"* protected components of class ZCL_EXCEL *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL + private section. +*"* private components of class ZCL_EXCEL *"* do not include other source files here!!! -private section. data DRAWINGS type ref to ZCL_EXCEL_DRAWINGS . data RANGES type ref to ZCL_EXCEL_RANGES . @@ -243,16 +140,16 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - - - - - - + + + + + + + + + + method ZIF_EXCEL_BOOK_PROPERTIES~INITIALIZE. DATA: lv_timestamp TYPE timestampl. @@ -292,17 +189,17 @@ endmethod. me->zif_excel_book_vba_project~vbaproject = ip_vbaproject. endmethod. - - - + + + method ADD_NEW_AUTOFILTER. * Check for autofilter reference: new or overwrite; only one per sheet ro_autofilter = autofilters->add( io_sheet = io_sheet ) . endmethod. - - - + + + method ADD_NEW_DRAWING. DATA: lv_guid TYPE guid_16. * Create default blank worksheet @@ -312,17 +209,17 @@ endmethod. drawings->add( eo_drawing ). 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. @@ -344,10 +241,10 @@ endmethod. endmethod. - - - - + + + + method ADD_NEW_WORKSHEET. DATA: lv_guid TYPE guid_16. * Create default blank worksheet @@ -359,14 +256,14 @@ endmethod. worksheets->active_worksheet = worksheets->size( ). endmethod. - + method ADD_STATIC_STYLES. " # issue 139 -* sp#ƒÂ¤ter hier noch die Worksheets abklappern, welche Styles #ƒÂ#berhaupt noch ben#ƒÂ#tigt werden -* und nur diese dann auch hier zur Verf#ƒÂ#gung stellen +* sp#ƒÂ¤ter hier noch die Worksheets abklappern, welche Styles #ƒÂ#berhaupt noch ben#ƒÂ#tigt werden +* und nur diese dann auch hier zur Verf#ƒÂ#gung stellen * Da muss ich noch mal nachfragen, ob die beiden ersten Styles, die scheinbar immer mit dem -* EXCEL-Objekt erzeugt werden evtl. immer ben#ƒÂ#tigt werden, egal ob verwendet oder nicht -* Aber als Start fange ich mal an einfach alle static styles der Reihe nach hinzuzuf#ƒÂ#gen +* EXCEL-Objekt erzeugt werden evtl. immer ben#ƒÂ#tigt werden, egal ob verwendet oder nicht +* Aber als Start fange ich mal an einfach alle static styles der Reihe nach hinzuzuf#ƒÂ#gen FIELD-SYMBOLS: <style1> LIKE LINE OF t_stylemapping1, <style2> LIKE LINE OF t_stylemapping2. DATA: style TYPE REF TO zcl_excel_style. @@ -384,405 +281,7 @@ endmethod. ENDLOOP. endmethod. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - method BUILD_STYLE. - DATA: stylemapping TYPE zexcel_s_stylemapping, - - complete_style TYPE zexcel_s_cstyle_complete, - complete_stylex TYPE zexcel_s_cstylex_complete, - - borderx TYPE zexcel_s_cstylex_border. - -* We have a lot of parameters. Use some macros to make the coding more structured - - DEFINE clear_initial_colorxfields. - if &1-rgb is initial. - clear &2-rgb. - endif. - if &1-indexed is initial. - clear &2-indexed. - endif. - if &1-theme is initial. - clear &2-theme. - endif. - if &1-tint is initial. - clear &2-tint. - endif. - END-OF-DEFINITION. - - DEFINE move_supplied_borders. - if ip_&1 is supplied. " only act if parameter was supplied - if ip_x&1 is supplied. " - borderx = ip_x&1. " use supplied x-parameter - else. - clear borderx with 'X'. -* clear in a way that would be expected to work easily - if ip_&1-border_style is initial. - clear borderx-border_style. - endif. - clear_initial_colorxfields ip_&1-border_color borderx-border_color. - endif. - move-corresponding ip_&1 to complete_style-&2. - move-corresponding borderx to complete_stylex-&2. - endif. - END-OF-DEFINITION. - -** First get current stylsettings -* TRY. -* me->get_cell( EXPORTING ip_column = ip_column " Cell Column -* ip_row = ip_row " Cell Row -* IMPORTING ep_guid = guid )." Cell Value ). -* -* -* stylemapping = me->excel->get_style_to_guid( guid ). -* complete_style = stylemapping-complete_style. -* complete_stylex = stylemapping-complete_stylex. -* CATCH zcx_excel. -** Error --> use submitted style -* ENDTRY. - if ip_copy_from_style is SUPPLIED. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Work in progress - copy from style not implemented yet'. - endif. - -* move_supplied_multistyles: complete. - IF ip_complete IS SUPPLIED. - IF ip_xcomplete IS NOT SUPPLIED. - RAISE EXCEPTION TYPE zcx_excel - EXPORTING - error = 'Complete styleinfo has to be supplied with corresponding X-field'. - ENDIF. - MOVE-CORRESPONDING ip_complete TO complete_style. - MOVE-CORRESPONDING ip_xcomplete TO complete_stylex. - ENDIF. - - - - IF ip_font IS SUPPLIED. - DATA: fontx LIKE ip_xfont. - IF ip_xfont IS SUPPLIED. - fontx = ip_xfont. - ELSE. -* Only supplied values should be used - exception: Flags bold and italic strikethrough underline - MOVE 'X' TO: fontx-bold, - fontx-italic, - fontx-strikethrough, - fontx-underline_mode. - CLEAR fontx-color WITH 'X'. - clear_initial_colorxfields ip_font-color 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. - MOVE-CORRESPONDING ip_font TO complete_style-font. - MOVE-CORRESPONDING fontx TO complete_stylex-font. -* Correction for undeline mode - ENDIF. - - IF ip_fill IS SUPPLIED. - 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 ip_fill-fgcolor fillx-fgcolor. - clear_initial_colorxfields ip_fill-bgcolor fillx-bgcolor. - - ENDIF. - MOVE-CORRESPONDING ip_fill TO complete_style-fill. - MOVE-CORRESPONDING fillx TO complete_stylex-fill. - ENDIF. - - - IF ip_borders IS SUPPLIED. - 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 ip_borders-allborders-border_color bordersx-allborders-border_color. - clear_initial_colorxfields ip_borders-diagonal-border_color bordersx-diagonal-border_color. - clear_initial_colorxfields ip_borders-down-border_color bordersx-down-border_color. - clear_initial_colorxfields ip_borders-left-border_color bordersx-left-border_color. - clear_initial_colorxfields ip_borders-right-border_color bordersx-right-border_color. - clear_initial_colorxfields ip_borders-top-border_color bordersx-top-border_color. - - ENDIF. - MOVE-CORRESPONDING ip_borders TO complete_style-borders. - MOVE-CORRESPONDING bordersx TO complete_stylex-borders. - ENDIF. - - IF ip_alignment IS SUPPLIED. - 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. - MOVE-CORRESPONDING ip_alignment TO complete_style-alignment. - MOVE-CORRESPONDING alignmentx TO complete_stylex-alignment. - ENDIF. - - IF ip_protection IS SUPPLIED. - MOVE-CORRESPONDING ip_alignment TO complete_style-alignment. - IF ip_xprotection IS SUPPLIED. - MOVE-CORRESPONDING ip_xprotection TO complete_stylex-protection. - ELSE. - IF ip_protection-hidden IS NOT INITIAL. - complete_style-protection-hidden = 'X'. - ENDIF. - IF ip_protection-locked IS NOT INITIAL. - complete_style-protection-locked = 'X'. - ENDIF. - ENDIF. - ENDIF. - - - move_supplied_borders : borders_allborders borders-allborders, - borders_diagonal borders-diagonal , - borders_down borders-down , - borders_left borders-left , - borders_right borders-right , - borders_top borders-top . - - DEFINE move_supplied_singlestyles. - if ip_&1 is supplied. - complete_style-&2 = ip_&1. - complete_stylex-&2 = 'X'. - endif. - END-OF-DEFINITION. - - move_supplied_singlestyles: number_format_format_code number_format-format_code, - font_bold font-bold, - font_color font-color, - font_color_rgb font-color-rgb, - font_color_indexed font-color-indexed, - font_color_theme font-color-theme, - font_color_tint font-color-tint, - - font_family font-family, - font_italic font-italic, - font_name font-name, - font_scheme font-scheme, - font_size font-size, - font_strikethrough font-strikethrough, - font_underline font-underline, - font_underline_mode font-underline_mode, - fill_filltype fill-filltype, - fill_rotation fill-rotation, - fill_fgcolor fill-fgcolor, - fill_fgcolor_rgb fill-fgcolor-rgb, - fill_fgcolor_indexed fill-fgcolor-indexed, - fill_fgcolor_theme fill-fgcolor-theme, - fill_fgcolor_tint fill-fgcolor-tint, - - fill_bgcolor fill-bgcolor, - fill_bgcolor_rgb fill-bgcolor-rgb, - fill_bgcolor_indexed fill-bgcolor-indexed, - fill_bgcolor_theme fill-bgcolor-theme, - fill_bgcolor_tint fill-bgcolor-tint, - - borders_diagonal_mode borders-diagonal_mode, - alignment_horizontal alignment-horizontal, - alignment_vertical alignment-vertical, - alignment_textrotation alignment-textrotation, - alignment_wraptext alignment-wraptext, - alignment_shrinktofit alignment-shrinktofit, - alignment_indent alignment-indent, - protection_hidden protection-hidden, - protection_locked protection-locked, - - borders_allborders_style borders-allborders-border_style, - borders_allborders_color borders-allborders-border_color, - borders_allbo_color_rgb borders-allborders-border_color-rgb, - borders_allbo_color_indexed borders-allborders-border_color-indexed, - borders_allbo_color_theme borders-allborders-border_color-theme, - borders_allbo_color_tint borders-allborders-border_color-tint, - - borders_diagonal_style borders-diagonal-border_style, - borders_diagonal_color borders-diagonal-border_color, - borders_diagonal_color_rgb borders-diagonal-border_color-rgb, - borders_diagonal_color_inde borders-diagonal-border_color-indexed, - borders_diagonal_color_them borders-diagonal-border_color-theme, - borders_diagonal_color_tint borders-diagonal-border_color-tint, - - borders_down_style borders-down-border_style, - borders_down_color borders-down-border_color, - borders_down_color_rgb borders-down-border_color-rgb, - borders_down_color_indexed borders-down-border_color-indexed, - borders_down_color_theme borders-down-border_color-theme, - borders_down_color_tint borders-down-border_color-tint, - - borders_left_style borders-left-border_style, - borders_left_color borders-left-border_color, - borders_left_color_rgb borders-left-border_color-rgb, - borders_left_color_indexed borders-left-border_color-indexed, - borders_left_color_theme borders-left-border_color-theme, - borders_left_color_tint borders-left-border_color-tint, - - borders_right_style borders-right-border_style, - borders_right_color borders-right-border_color, - borders_right_color_rgb borders-right-border_color-rgb, - borders_right_color_indexed borders-right-border_color-indexed, - borders_right_color_theme borders-right-border_color-theme, - borders_right_color_tint borders-right-border_color-tint, - - borders_top_style borders-top-border_style, - borders_top_color borders-top-border_color, - borders_top_color_rgb borders-top-border_color-rgb, - borders_top_color_indexed borders-top-border_color-indexed, - borders_top_color_theme borders-top-border_color-theme, - borders_top_color_tint borders-top-border_color-tint. - - -* 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->get_static_cellstyle_guid( ip_cstyle_complete = complete_style - ip_cstylex_complete = complete_stylex ). - -endmethod. - - + method CONSTRUCTOR. DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_style TYPE REF TO zcl_excel_style. @@ -806,44 +305,44 @@ endmethod. 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. + + + method GET_DEFAULT_STYLE. ep_style = me->default_style. -ENDMETHOD. +endmethod. - - + + method GET_DRAWINGS_ITERATOR. eo_iterator = me->drawings->get_iterator( ). endmethod. - - + + method GET_NEXT_TABLE_ID. DATA: lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_iterator TYPE REF TO cl_object_collection_iterator, @@ -862,18 +361,18 @@ endmethod. 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. @@ -896,19 +395,19 @@ endmethod. ep_guid = style-guid. endmethod. - - + + method GET_STYLES_ITERATOR. eo_iterator = me->styles->get_iterator( ). endmethod. - - - - - METHOD get_style_index_in_styles. + + + + + method GET_STYLE_INDEX_IN_STYLES. DATA: index TYPE syindex. DATA: lo_iterator TYPE REF TO cl_object_collection_iterator, lo_style TYPE REF TO zcl_excel_style. @@ -933,12 +432,12 @@ endmethod. else. SUBTRACT 1 from ep_index. " In excel list starts with "0" ENDIF. -ENDMETHOD. +endmethod. - - - - + + + + method GET_STYLE_TO_GUID. " # issue 139 @@ -958,38 +457,38 @@ ENDMETHOD. 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 SET_ACTIVE_SHEET_INDEX. me->worksheets->active_worksheet = i_active_worksheet. endmethod. - - + + method SET_ACTIVE_SHEET_INDEX_BY_NAME. DATA: ws_it TYPE REF TO cl_object_collection_iterator, @@ -1011,16 +510,16 @@ endmethod. endmethod. - - - - METHOD set_default_style. + + + + method SET_DEFAULT_STYLE. me->default_style = ip_style. -ENDMETHOD. +endmethod. - - - + + + method STYLEMAPPING_DYNAMIC_STYLE. " # issue 139 eo_style2-dynamic_style_guid = ip_style->get_guid( ). diff --git a/ZA2X/PROG/ZDEMO_EXCEL.slnk b/ZA2X/PROG/ZDEMO_EXCEL.slnk index 75c5c09..4e263c7 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL.slnk @@ -1,5 +1,5 @@ - + @@ -71,6 +71,7 @@ START-OF-SELECTION. SUBMIT zdemo_excel33 WITH p_path = p_path AND RETURN. " abap2xlsx Demo: Table autofilter SUBMIT zdemo_excel34 WITH p_path = p_path AND RETURN. " abap2xlsx Demo: Static Styles Chess SUBMIT zdemo_excel35 WITH p_path = p_path AND RETURN. " abap2xlsx Demo: Static Styles + SUBMIT zdemo_excel36 WITH p_path = p_path AND RETURN. " abap2xlsx Demo: Style applied to sheet, column and single cell " " Reader/Writer Demo must always run at the end " to make sure all documents where created diff --git a/ZA2X/PROG/ZDEMO_EXCEL36.slnk b/ZA2X/PROG/ZDEMO_EXCEL36.slnk index a7435e9..b67e3cd 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL36.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL36.slnk @@ -1,5 +1,5 @@ - - + + @@ -12,11 +12,15 @@ REPORT zdemo_excel36. DATA: lo_excel TYPE REF TO zcl_excel, lo_worksheet TYPE REF TO zcl_excel_worksheet, column_dimension TYPE REF TO zcl_excel_worksheet_columndime, - col type i. + col TYPE i. -DATA: guid_arial20 TYPE zexcel_cell_style, - gui_times11 TYPE zexcel_cell_style, - gui_cambria8red TYPE zexcel_cell_style. +DATA: lo_style_arial20 TYPE REF TO zcl_excel_style, + lo_style_times11 TYPE REF TO zcl_excel_style, + lo_style_cambria8red TYPE REF TO zcl_excel_style. + +DATA: lv_style_arial20_guid TYPE zexcel_cell_style, + lv_style_times11_guid TYPE zexcel_cell_style, + lv_style_cambria8red_guid TYPE zexcel_cell_style. CONSTANTS: gc_save_file_name TYPE string VALUE '36_DefaultStyles.xlsx'. @@ -27,18 +31,27 @@ START-OF-SELECTION. " Creates active sheet CREATE OBJECT lo_excel. - guid_arial20 = lo_excel->build_style( ip_font_name = zcl_excel_style_font=>c_name_arial - ip_font_scheme = zcl_excel_style_font=>c_scheme_none - ip_font_size = 20 ). - gui_times11 = lo_excel->build_style( ip_font_name = zcl_excel_style_font=>c_name_roman - ip_font_scheme = zcl_excel_style_font=>c_scheme_none - ip_font_size = 11 ). - gui_cambria8red = lo_excel->build_style( ip_font_name = zcl_excel_style_font=>C_NAME_CAMBRIA - ip_font_scheme = zcl_excel_style_font=>c_scheme_none - ip_font_size = 8 - ip_font_color_rgb = zcl_excel_style_color=>c_red ). + " Create a bold / italic style + lo_style_arial20 = lo_excel->add_new_style( ). + lo_style_arial20->font->name = zcl_excel_style_font=>c_name_arial. + lo_style_arial20->font->scheme = zcl_excel_style_font=>c_scheme_none. + lo_style_arial20->font->size = 20. + lv_style_arial20_guid = lo_style_arial20->get_guid( ). - lo_excel->set_default_style( guid_arial20 ). " Default for all new worksheets + lo_style_times11 = lo_excel->add_new_style( ). + lo_style_times11->font->name = zcl_excel_style_font=>c_name_roman. + lo_style_times11->font->scheme = zcl_excel_style_font=>c_scheme_none. + lo_style_times11->font->size = 11. + lv_style_times11_guid = lo_style_times11->get_guid( ). + + lo_style_cambria8red = lo_excel->add_new_style( ). + lo_style_cambria8red->font->name = zcl_excel_style_font=>c_name_cambria. + lo_style_cambria8red->font->scheme = zcl_excel_style_font=>c_scheme_none. + lo_style_cambria8red->font->size = 8. + lo_style_cambria8red->font->color-rgb = zcl_excel_style_color=>c_red. + lv_style_cambria8red_guid = lo_style_cambria8red->get_guid( ). + + lo_excel->set_default_style( lv_style_arial20_guid ). " Default for all new worksheets * 1st sheet - do not change anything --> defaultstyle from lo_excel should apply lo_worksheet = lo_excel->get_active_worksheet( ). @@ -52,7 +65,7 @@ START-OF-SELECTION. * 2nd sheet - defaultstyle for this sheet set explicitly ( set to Times New Roman 11 ) lo_worksheet = lo_excel->add_new_worksheet( ). lo_worksheet->set_title( 'Style for this sheet' ). - lo_worksheet->zif_excel_sheet_properties~set_style( gui_times11 ). + lo_worksheet->zif_excel_sheet_properties~set_style( lv_style_times11_guid ). lo_worksheet->set_cell( ip_column = 2 ip_row = 4 ip_value = 'All cells in this sheet are set to font Times New Roman, fontsize 11' ). lo_worksheet->set_cell( ip_column = 2 ip_row = 5 ip_value = 'because this style was passed for this sheet' ). @@ -64,21 +77,21 @@ START-OF-SELECTION. lo_worksheet = lo_excel->add_new_worksheet( ). lo_worksheet->set_title( 'Style for 3 columns' ). column_dimension = lo_worksheet->get_column_dimension( 'B' ). - column_dimension->set_column_style_by_guid( ip_style_guid = gui_times11 ). + column_dimension->set_column_style_by_guid( ip_style_guid = lv_style_times11_guid ). column_dimension = lo_worksheet->get_column_dimension( 'C' ). - column_dimension->set_column_style_by_guid( ip_style_guid = gui_times11 ). + column_dimension->set_column_style_by_guid( ip_style_guid = lv_style_times11_guid ). column_dimension = lo_worksheet->get_column_dimension( 'F' ). - column_dimension->set_column_style_by_guid( ip_style_guid = gui_times11 ). + column_dimension->set_column_style_by_guid( ip_style_guid = lv_style_times11_guid ). lo_worksheet->set_cell( ip_column = 2 ip_row = 4 ip_value = 'The columns B,C and F are set to Times New Roman' ). lo_worksheet->set_cell( ip_column = 2 ip_row = 10 ip_value = 'All other cells in this sheet are set to font Arial, fontsize 20' ). lo_worksheet->set_cell( ip_column = 2 ip_row = 11 ip_value = 'because no separate style was passed for this sheet' ). lo_worksheet->set_cell( ip_column = 2 ip_row = 12 ip_value = 'but a default style was set for the complete instance of zcl_excel' ). - lo_worksheet->set_cell( ip_column = 8 ip_row = 1 ip_value = 'Of course' ip_style = gui_cambria8red ). - lo_worksheet->set_cell( ip_column = 8 ip_row = 2 ip_value = 'setting a specific style to a cell' ip_style = gui_cambria8red ). - lo_worksheet->set_cell( ip_column = 8 ip_row = 3 ip_value = 'takes precedence over all defaults' ip_style = gui_cambria8red ). - lo_worksheet->set_cell( ip_column = 8 ip_row = 4 ip_value = 'Here: Cambria 8 in red' ip_style = gui_cambria8red ). + lo_worksheet->set_cell( ip_column = 8 ip_row = 1 ip_value = 'Of course' ip_style = lv_style_cambria8red_guid ). + lo_worksheet->set_cell( ip_column = 8 ip_row = 2 ip_value = 'setting a specific style to a cell' ip_style = lv_style_cambria8red_guid ). + lo_worksheet->set_cell( ip_column = 8 ip_row = 3 ip_value = 'takes precedence over all defaults' ip_style = lv_style_cambria8red_guid ). + lo_worksheet->set_cell( ip_column = 8 ip_row = 4 ip_value = 'Here: Cambria 8 in red' ip_style = lv_style_cambria8red_guid ). * Set entry into each of the first 10 columns