From dfe73c22ddfbfb6351cd5d447f9ae107d22d9dfe Mon Sep 17 00:00:00 2001 From: Tomek Mackowski Date: Wed, 4 May 2011 21:52:43 +0000 Subject: [PATCH] Fix #86 - add support for all Excel coloring options - standard color themes, indexed colors and tint Both writer and reader updated. git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@170 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk | 85 ++++-- ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk | 42 +-- ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk | 98 ++++--- ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk | 68 ++--- ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk | 50 ++-- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 300 ++++++++++++---------- ZA2X/DTEL/ZEXCEL_STYLE_COLOR_INDEXED.slnk | 4 + ZA2X/DTEL/ZEXCEL_STYLE_COLOR_THEME.slnk | 4 + ZA2X/DTEL/ZEXCEL_STYLE_COLOR_TINT.slnk | 4 + ZA2X/PROG/ZDEMO_EXCEL11.slnk | 8 +- ZA2X/PROG/ZDEMO_EXCEL13.slnk | 6 +- ZA2X/PROG/ZDEMO_EXCEL17.slnk | 4 +- ZA2X/PROG/ZDEMO_EXCEL2.slnk | 12 +- ZA2X/PROG/ZDEMO_EXCEL21.slnk | 4 +- ZA2X/PROG/ZDEMO_EXCEL22.slnk | 6 +- ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk | 42 ++- ZA2X/TABL/ZEXCEL_S_STYLE_COLOR.slnk | 8 + ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk | 18 +- ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk | 26 +- 19 files changed, 475 insertions(+), 314 deletions(-) create mode 100644 ZA2X/DTEL/ZEXCEL_STYLE_COLOR_INDEXED.slnk create mode 100644 ZA2X/DTEL/ZEXCEL_STYLE_COLOR_THEME.slnk create mode 100644 ZA2X/DTEL/ZEXCEL_STYLE_COLOR_TINT.slnk create mode 100644 ZA2X/TABL/ZEXCEL_S_STYLE_COLOR.slnk diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk index f8f2b73..90c97b7 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk @@ -437,13 +437,13 @@ ENDMETHOD. - METHOD LOAD_STYLE_BORDERS. -DATA: node TYPE REF TO if_ixml_element, - node2 TYPE REF TO if_ixml_element, - node3 TYPE REF TO if_ixml_element, - cell_border TYPE REF TO zcl_excel_style_borders, - border TYPE REF TO zcl_excel_style_border, - color TYPE t_color. + METHOD load_style_borders. + DATA: node TYPE REF TO if_ixml_element, + node2 TYPE REF TO if_ixml_element, + node3 TYPE REF TO if_ixml_element, + cell_border TYPE REF TO zcl_excel_style_borders, + border TYPE REF TO zcl_excel_style_border, + color TYPE t_color. node ?= ip_xml->find_from_name( 'border' ). WHILE node IS BOUND. @@ -475,7 +475,15 @@ DATA: node TYPE REF TO if_ixml_element, CHANGING cp_structure = color ). - border->border_color = color-rgb. + border->border_color-rgb = color-rgb. + IF color-indexed IS NOT INITIAL. + border->border_color-indexed = color-indexed. + ENDIF. + + IF color-theme IS NOT INITIAL. + border->border_color-theme = color-theme. + ENDIF. + border->border_color-tint = color-tint. ENDIF. node2 ?= node2->get_next( ). @@ -489,13 +497,13 @@ ENDMETHOD. - METHOD LOAD_STYLE_FILLS. - DATA: value TYPE string, - node TYPE REF TO if_ixml_element, - node2 TYPE REF TO if_ixml_element, - node3 TYPE REF TO if_ixml_element, - fill TYPE REF TO zcl_excel_style_fill, - color TYPE t_color. + METHOD load_style_fills. + DATA: value TYPE string, + node TYPE REF TO if_ixml_element, + node2 TYPE REF TO if_ixml_element, + node3 TYPE REF TO if_ixml_element, + fill TYPE REF TO zcl_excel_style_fill, + color TYPE t_color. node ?= ip_xml->find_from_name( 'fill' ). WHILE node IS BOUND. @@ -513,9 +521,16 @@ ENDMETHOD. ip_element = node3 CHANGING cp_structure = color ). + + fill->bgcolor-rgb = color-rgb. IF color-indexed IS NOT INITIAL. - fill->bgcolor = color-indexed. + fill->bgcolor-indexed = color-indexed. ENDIF. + + IF color-theme IS NOT INITIAL. + fill->bgcolor-theme = color-theme. + ENDIF. + fill->bgcolor-tint = color-tint. ENDIF. node3 = node->find_from_name( 'fgColor' ). @@ -526,9 +541,15 @@ ENDMETHOD. CHANGING cp_structure = color ). - fill->fgcolor = color-rgb. - "fill-> = color-theme. - "fill-> = color-tint. + fill->fgcolor-rgb = color-rgb. + IF color-indexed IS NOT INITIAL. + fill->fgcolor-indexed = color-indexed. + ENDIF. + + IF color-theme IS NOT INITIAL. + fill->fgcolor-theme = color-theme. + ENDIF. + fill->fgcolor-tint = color-tint. ENDIF. WHEN 'gradientFill'. "TODO @@ -602,7 +623,15 @@ ENDMETHOD. CHANGING cp_structure = color ). - font->color = color-rgb. + font->color-rgb = color-rgb. + IF color-indexed IS NOT INITIAL. + font->color-indexed = color-indexed. + ENDIF. + + IF color-theme IS NOT INITIAL. + font->color-theme = color-theme. + ENDIF. + font->color-tint = color-tint. ENDIF. INSERT font INTO TABLE ep_fonts. @@ -637,11 +666,11 @@ ENDMETHOD. METHOD load_workbook. -TYPES: BEGIN OF t_sheet, - name TYPE string, - sheetId TYPE string, - id TYPE string, - END OF t_sheet. + TYPES: BEGIN OF t_sheet, + name TYPE string, + sheetid TYPE string, + id TYPE string, + END OF t_sheet. CONSTANTS: lc_shared_strings TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', lc_worksheet TYPE string VALUE 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', @@ -679,7 +708,7 @@ TYPES: BEGIN OF t_sheet, rels_workbook = me->get_ixml_from_zip_archive( rels_workbook_path ). node ?= rels_workbook->find_from_name( 'Relationship' ). - WHILE node is BOUND. + WHILE node IS BOUND. fill_struct_from_attributes( EXPORTING ip_element = node CHANGING cp_structure = relationship ). CASE relationship-type. @@ -707,7 +736,8 @@ TYPES: BEGIN OF t_sheet, " Read Workbook workbook = me->get_ixml_from_zip_archive( ip_path ). node ?= workbook->find_from_name( 'sheet' ). - WHILE node is BOUND. + workbook_index = 1. + WHILE node IS BOUND. fill_struct_from_attributes( EXPORTING @@ -732,6 +762,7 @@ TYPES: BEGIN OF t_sheet, io_worksheet = lo_worksheet ). node ?= node->get_next( ). + ADD 1 TO workbook_index. ENDWHILE. ENDMETHOD. diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk index 4e48d2a..39f1868 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_BORDER.slnk @@ -1,16 +1,16 @@ - + class ZCL_EXCEL_STYLE_BORDER definition public final create public . +public section. *"* public components of class ZCL_EXCEL_STYLE_BORDER *"* do not include other source files here!!! -public section. data BORDER_STYLE type ZEXCEL_BORDER . - data BORDER_COLOR type ZEXCEL_STYLE_COLOR_ARGB . + data BORDER_COLOR type ZEXCEL_S_STYLE_COLOR . constants C_BORDER_NONE type ZEXCEL_BORDER value 'none'. "#EC NOTEXT constants C_BORDER_DASHDOT type ZEXCEL_BORDER value 'dashDot'. "#EC NOTEXT constants C_BORDER_DASHDOTDOT type ZEXCEL_BORDER value 'dashDotDot'. "#EC NOTEXT @@ -41,25 +41,27 @@ 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 CONSTRUCTOR. border_style = zcl_excel_style_border=>c_border_none. + border_color-theme = zcl_excel_style_color=>c_theme_not_set. + border_color-indexed = zcl_excel_style_color=>c_indexed_not_set. endmethod. diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk index 3b2ef61..e594806 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_COLOR.slnk @@ -1,25 +1,40 @@ - + class ZCL_EXCEL_STYLE_COLOR definition public final create public . +public section. *"* public components of class ZCL_EXCEL_STYLE_COLOR *"* do not include other source files here!!! -public section. - class-data C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT . - class-data C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT . - class-data C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT . - class-data C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT . - class-data C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT . - class-data C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT . - class-data C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT . - class-data C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT . - class-data C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT . - class-data C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT . - class-data C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT . + constants C_BLACK type ZEXCEL_STYLE_COLOR_ARGB value 'FF000000'. "#EC NOTEXT + constants C_BLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF0000FF'. "#EC NOTEXT + constants C_DARKBLUE type ZEXCEL_STYLE_COLOR_ARGB value 'FF000080'. "#EC NOTEXT + constants C_DARKGREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF008000'. "#EC NOTEXT + constants C_DARKRED type ZEXCEL_STYLE_COLOR_ARGB value 'FF800000'. "#EC NOTEXT + constants C_DARKYELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FF808000'. "#EC NOTEXT + constants C_GRAY type ZEXCEL_STYLE_COLOR_ARGB value 'FFCCCCCC'. "#EC NOTEXT + constants C_GREEN type ZEXCEL_STYLE_COLOR_ARGB value 'FF00FF00'. "#EC NOTEXT + constants C_RED type ZEXCEL_STYLE_COLOR_ARGB value 'FFFF0000'. "#EC NOTEXT + constants C_WHITE type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFFFF'. "#EC NOTEXT + constants C_YELLOW type ZEXCEL_STYLE_COLOR_ARGB value 'FFFFFF00'. "#EC NOTEXT + constants C_THEME_DARK1 type ZEXCEL_STYLE_COLOR_THEME value '0'. "#EC NOTEXT + constants C_THEME_LIGHT1 type ZEXCEL_STYLE_COLOR_THEME value '1'. "#EC NOTEXT + constants C_THEME_DARK2 type ZEXCEL_STYLE_COLOR_THEME value '2'. "#EC NOTEXT + constants C_THEME_LIGHT2 type ZEXCEL_STYLE_COLOR_THEME value '3'. "#EC NOTEXT + constants C_THEME_ACCENT1 type ZEXCEL_STYLE_COLOR_THEME value '4'. "#EC NOTEXT + constants C_THEME_ACCENT2 type ZEXCEL_STYLE_COLOR_THEME value '5'. "#EC NOTEXT + constants C_THEME_ACCENT3 type ZEXCEL_STYLE_COLOR_THEME value '6'. "#EC NOTEXT + constants C_THEME_ACCENT4 type ZEXCEL_STYLE_COLOR_THEME value '7'. "#EC NOTEXT + constants C_THEME_ACCENT5 type ZEXCEL_STYLE_COLOR_THEME value '8'. "#EC NOTEXT + constants C_THEME_ACCENT6 type ZEXCEL_STYLE_COLOR_THEME value '9'. "#EC NOTEXT + constants C_THEME_HYPERLINK type ZEXCEL_STYLE_COLOR_THEME value '10'. "#EC NOTEXT + constants C_THEME_HYPERLINK_FOLLOWED type ZEXCEL_STYLE_COLOR_THEME value '11'. "#EC NOTEXT + constants C_THEME_NOT_SET type ZEXCEL_STYLE_COLOR_THEME value -1. "#EC NOTEXT + constants C_INDEXED_NOT_SET type ZEXCEL_STYLE_COLOR_INDEXED value -1. "#EC NOTEXT + constants C_INDEXED_SYS_FOREGROUND type ZEXCEL_STYLE_COLOR_INDEXED value 64. "#EC NOTEXT methods CONSTRUCTOR . class-methods CREATE_NEW_ARGB @@ -32,11 +47,11 @@ public section. *"* protected components of class ZCL_EXCEL_STYLE_COLOR *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL_STYLE_COLOR + private section. +*"* private components of class ZCL_EXCEL_STYLE_COLOR *"* do not include other source files here!!! -private section. - class-data C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT . + constants C_ALPHA type CHAR2 value 'FF'. "#EC NOTEXT *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -45,29 +60,44 @@ 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 CONSTRUCTOR. endmethod. - - - - - + + + + + method CREATE_NEW_ARGB. diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk index b139647..1128a99 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FILL.slnk @@ -1,13 +1,13 @@ - + class ZCL_EXCEL_STYLE_FILL definition public final create public . +public section. *"* public components of class ZCL_EXCEL_STYLE_FILL *"* do not include other source files here!!! -public section. constants C_FILL_NONE type ZEXCEL_FILL_TYPE value 'none'. "#EC NOTEXT constants C_FILL_SOLID type ZEXCEL_FILL_TYPE value 'solid'. "#EC NOTEXT @@ -32,8 +32,8 @@ public section. constants C_FILL_PATTERN_MEDIUMGRAY type ZEXCEL_FILL_TYPE value 'mediumGray'. "#EC NOTEXT data FILLTYPE type ZEXCEL_FILL_TYPE . data ROTATION type ZEXCEL_ROTATION . - data FGCOLOR type ZEXCEL_STYLE_COLOR_ARGB . - data BGCOLOR type ZEXCEL_STYLE_COLOR_ARGB value '64'. "#EC NOTEXT . + data FGCOLOR type ZEXCEL_S_STYLE_COLOR . + data BGCOLOR type ZEXCEL_S_STYLE_COLOR . methods CONSTRUCTOR . methods GET_STRUCTURE @@ -53,39 +53,43 @@ 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 CONSTRUCTOR. filltype = zcl_excel_style_fill=>c_fill_none. + fgcolor-theme = zcl_excel_style_color=>c_theme_not_set. + fgcolor-indexed = zcl_excel_style_color=>c_indexed_not_set. + bgcolor-theme = zcl_excel_style_color=>c_theme_not_set. + bgcolor-indexed = zcl_excel_style_color=>c_indexed_sys_foreground. rotation = 0. endmethod. - - + + method GET_STRUCTURE. es_fill-rotation = me->rotation. es_fill-filltype = me->filltype. diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk index 47d9a5f..7137ada 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_FONT.slnk @@ -1,17 +1,17 @@ - + class ZCL_EXCEL_STYLE_FONT definition public final create public . +public section. *"* public components of class ZCL_EXCEL_STYLE_FONT *"* do not include other source files here!!! -public section. type-pools ABAP . data BOLD type FLAG . - data COLOR type ZEXCEL_STYLE_COLOR_ARGB . + data COLOR type ZEXCEL_S_STYLE_COLOR . constants C_SCHEME_MAJOR type ZEXCEL_STYLE_FONT_SCHEME value 'major'. "#EC NOTEXT constants C_SCHEME_MINOR type ZEXCEL_STYLE_FONT_SCHEME value 'minor'. "#EC NOTEXT constants C_UNDERLINE_DOUBLE type CHAR20 value 'double'. "#EC NOTEXT @@ -48,32 +48,34 @@ private section. *"* in the implementation part of the class ABAP - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. - me->color = zcl_excel_style_color=>c_black. + me->color-rgb = zcl_excel_style_color=>c_black. + me->color-theme = zcl_excel_style_color=>c_theme_not_set. + me->color-indexed = zcl_excel_style_color=>c_indexed_not_set. me->scheme = zcl_excel_style_font=>c_scheme_minor. me->underline_mode = zcl_excel_style_font=>c_underline_single. endmethod. - - + + method GET_STRUCTURE. es_font-bold = me->bold. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index a355f8f..0462ce8 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -1,6 +1,6 @@ - - + + class ZCL_EXCEL_WRITER_2007 definition public final @@ -14,9 +14,9 @@ public section. *"* protected components of class ZCL_EXCEL_WRITER_2007 *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL_WRITER_2007 + private section. +*"* private components of class ZCL_EXCEL_WRITER_2007 *"* do not include other source files here!!! -private section. constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT @@ -80,6 +80,12 @@ private section. !IV_DRAWING_INDEX type I returning value(EP_CONTENT) type XSTRING . + methods CREATE_XL_STYLES_COLOR_NODE + importing + !IO_DOCUMENT type ref to IF_IXML_DOCUMENT + !IO_PARENT type ref to IF_IXML_ELEMENT + !IV_COLOR_ELEM_NAME type STRING default 'color' + !IS_COLOR type ZEXCEL_S_STYLE_COLOR . methods CREATE_XL_STYLES returning value(EP_CONTENT) type XSTRING . @@ -112,32 +118,32 @@ 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_WRITER~WRITE_FILE. me->excel = io_excel. ep_file = me->create( ). endmethod. - - + + method CREATE. @@ -307,8 +313,8 @@ endmethod. endmethod. - - + + method CREATE_CONTENT_TYPES. @@ -561,8 +567,8 @@ endmethod. endmethod. - - + + method CREATE_DOCPROPS_APP. @@ -782,8 +788,8 @@ endmethod. endmethod. - - + + method CREATE_DOCPROPS_CORE. @@ -898,8 +904,8 @@ endmethod. endmethod. - - + + method CREATE_RELATIONSHIPS. @@ -997,9 +1003,9 @@ endmethod. endmethod. - - - + + + method CREATE_XL_DRAWINGS. @@ -1227,9 +1233,9 @@ endmethod. endmethod. - - - + + + method CREATE_XL_DRAWINGS_RELS. ** Constant node name @@ -1313,8 +1319,8 @@ endmethod. endmethod. - - + + method CREATE_XL_RELATIONSHIPS. @@ -1461,8 +1467,8 @@ endmethod. endmethod. - - + + method CREATE_XL_SHAREDSTRINGS. @@ -1578,10 +1584,10 @@ endmethod. endmethod. - - - - + + + + method CREATE_XL_SHEET. ** Constant node name @@ -2748,10 +2754,10 @@ endmethod. endmethod. - - - - + + + + method CREATE_XL_SHEET_RELS. @@ -2893,9 +2899,9 @@ endmethod. endmethod. - - - method CREATE_XL_STYLES. + + + METHOD create_xl_styles. ** Constant node name @@ -2952,6 +2958,7 @@ endmethod. lc_xml_attr_theme TYPE string VALUE 'theme', lc_xml_attr_rgb TYPE string VALUE 'rgb', lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_tint TYPE string VALUE 'tint', lc_xml_attr_style TYPE string VALUE 'style', lc_xml_attr_position TYPE string VALUE 'position', lc_xml_attr_degree TYPE string VALUE 'degree', @@ -3237,12 +3244,11 @@ endmethod. value = lv_value ). lo_element_font->append_child( new_child = lo_sub_element ). "color - lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_color - parent = lo_document ). - lv_value = ls_font-color. - lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). - lo_element_font->append_child( new_child = lo_sub_element ). + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_element_font + is_color = ls_font-color ). + "name lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_name parent = lo_document ). @@ -3280,25 +3286,18 @@ endmethod. lo_sub_element->set_attribute_ns( name = lc_xml_attr_patterntype value = lv_value ). " fgcolor - IF ls_fill-fgcolor IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_fgcolor - parent = lo_document ). - lv_value = ls_fill-fgcolor. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_fill-fgcolor + iv_color_elem_name = lc_xml_node_fgcolor ). - lo_sub_element->append_child( new_child = lo_sub_element_2 )." fgcolor - ENDIF. " bgcolor - IF ls_fill-bgcolor IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_bgcolor - parent = lo_document ). - lv_value = ls_fill-bgcolor. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_indexed - value = lv_value ). - - lo_sub_element->append_child( new_child = lo_sub_element_2 )." bgcolor - ENDIF. + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_fill-bgcolor + iv_color_elem_name = lc_xml_node_bgcolor ). lo_element_fill->append_child( new_child = lo_sub_element )."pattern lo_element_fills->append_child( new_child = lo_element_fill ). @@ -3316,14 +3315,12 @@ endmethod. lo_sub_element->set_attribute_ns( name = lc_xml_attr_style value = lv_value ). ENDIF. - IF ls_border-left_color IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color - parent = lo_document ). - lv_value = ls_border-left_color. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). - lo_sub_element->append_child( new_child = lo_sub_element_2 )." color - ENDIF. + + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_border-left_color ). + lo_element_border->append_child( new_child = lo_sub_element ). "right @@ -3334,14 +3331,12 @@ endmethod. lo_sub_element->set_attribute_ns( name = lc_xml_attr_style value = lv_value ). ENDIF. - IF ls_border-right_color IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color - parent = lo_document ). - lv_value = ls_border-right_color. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). - lo_sub_element->append_child( new_child = lo_sub_element_2 )." color - ENDIF. + + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_border-right_color ). + lo_element_border->append_child( new_child = lo_sub_element ). "top @@ -3352,14 +3347,12 @@ endmethod. lo_sub_element->set_attribute_ns( name = lc_xml_attr_style value = lv_value ). ENDIF. - IF ls_border-top_color IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color - parent = lo_document ). - lv_value = ls_border-top_color. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). - lo_sub_element->append_child( new_child = lo_sub_element_2 )." color - ENDIF. + + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_border-top_color ). + lo_element_border->append_child( new_child = lo_sub_element ). "bottom @@ -3370,14 +3363,12 @@ endmethod. lo_sub_element->set_attribute_ns( name = lc_xml_attr_style value = lv_value ). ENDIF. - IF ls_border-bottom_color IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color - parent = lo_document ). - lv_value = ls_border-bottom_color. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). - lo_sub_element->append_child( new_child = lo_sub_element_2 )." color - ENDIF. + + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_border-bottom_color ). + lo_element_border->append_child( new_child = lo_sub_element ). "diagonal @@ -3388,14 +3379,12 @@ endmethod. lo_sub_element->set_attribute_ns( name = lc_xml_attr_style value = lv_value ). ENDIF. - IF ls_border-diagonal_color IS NOT INITIAL. - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_color - parent = lo_document ). - lv_value = ls_border-diagonal_color. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_rgb - value = lv_value ). - lo_sub_element->append_child( new_child = lo_sub_element_2 )." color - ENDIF. + + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element + is_color = ls_border-diagonal_color ). + lo_element_border->append_child( new_child = lo_sub_element ). lo_element_borders->append_child( new_child = lo_element_border ). ENDLOOP. @@ -3626,11 +3615,62 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -endmethod. +ENDMETHOD. - - - + + + + + + METHOD create_xl_styles_color_node. + DATA: lo_sub_element TYPE REF TO if_ixml_element, + lv_value TYPE string. + + CONSTANTS: lc_xml_attr_theme TYPE string VALUE 'theme', + lc_xml_attr_rgb TYPE string VALUE 'rgb', + lc_xml_attr_indexed TYPE string VALUE 'indexed', + lc_xml_attr_tint TYPE string VALUE 'tint'. + +"add node only if at least one attribute is set + CHECK is_color-rgb IS NOT INITIAL OR + is_color-indexed <> zcl_excel_style_color=>c_indexed_not_set OR + is_color-theme <> zcl_excel_style_color=>c_theme_not_set OR + is_color-tint IS NOT INITIAL. + + lo_sub_element = io_document->create_simple_element( + name = iv_color_elem_name + parent = io_parent ). + + IF is_color-rgb IS NOT INITIAL. + lv_value = is_color-rgb. + lo_sub_element->set_attribute_ns( name = lc_xml_attr_rgb + value = lv_value ). + ENDIF. + + IF is_color-indexed <> zcl_excel_style_color=>c_indexed_not_set. + lv_value = zcl_excel_common=>number_to_excel_string( is_color-indexed ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_indexed + value = lv_value ). + ENDIF. + + IF is_color-theme <> zcl_excel_style_color=>c_theme_not_set. + lv_value = zcl_excel_common=>number_to_excel_string( is_color-theme ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_theme + value = lv_value ). + ENDIF. + + IF is_color-tint IS NOT INITIAL. + lv_value = zcl_excel_common=>number_to_excel_string( is_color-tint ). + lo_sub_element->set_attribute_ns( name = lc_xml_attr_tint + value = lv_value ). + ENDIF. + + io_parent->append_child( new_child = lo_sub_element ). +ENDMETHOD. + + + + method CREATE_XL_TABLE. DATA: lc_xml_node_table TYPE string VALUE 'table', @@ -3799,8 +3839,8 @@ endmethod. endmethod. - - + + method CREATE_XL_THEME. @@ -3888,8 +3928,8 @@ endmethod. endmethod. - - + + method CREATE_XL_WORKBOOK. @@ -4111,9 +4151,9 @@ endmethod. endmethod. - - - + + + method FLAG2BOOL. @@ -4124,9 +4164,9 @@ endmethod. ENDIF. endmethod. - - - + + + method GET_SHARED_STRING_INDEX. diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_INDEXED.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_INDEXED.slnk new file mode 100644 index 0000000..662eed1 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_INDEXED.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_THEME.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_THEME.slnk new file mode 100644 index 0000000..30125f8 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_THEME.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_TINT.slnk b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_TINT.slnk new file mode 100644 index 0000000..0b4db9f --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_STYLE_COLOR_TINT.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/PROG/ZDEMO_EXCEL11.slnk b/ZA2X/PROG/ZDEMO_EXCEL11.slnk index 63f9657..8b444f6 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL11.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL11.slnk @@ -1,5 +1,5 @@ - + @@ -259,16 +259,16 @@ START-OF-SELECTION. " Create border object CREATE OBJECT lo_border_dark. - lo_border_dark->border_color = zcl_excel_style_color=>c_black. + lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black. lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. "Create style with border even lo_style_body = lo_excel->add_new_style( ). - lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_yellow. + lo_style_body->fill->fgcolor-rgb = zcl_excel_style_color=>c_yellow. lo_style_body->borders->allborders = lo_border_dark. lv_style_body_even_guid = lo_style_body->get_guid( ). "Create style with border and green fill lo_style_body = lo_excel->add_new_style( ). - lo_style_body->fill->fgcolor = zcl_excel_style_color=>c_green. + lo_style_body->fill->fgcolor-rgb = zcl_excel_style_color=>c_green. lo_style_body->borders->allborders = lo_border_dark. lv_style_body_green = lo_style_body->get_guid( ). diff --git a/ZA2X/PROG/ZDEMO_EXCEL13.slnk b/ZA2X/PROG/ZDEMO_EXCEL13.slnk index cf5a131..b69c4be 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL13.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL13.slnk @@ -1,5 +1,5 @@ - + @@ -62,13 +62,13 @@ START-OF-SELECTION. lo_worksheet->set_title( 'sheet1' ). CREATE OBJECT lo_border_dark. - lo_border_dark->border_color = zcl_excel_style_color=>c_black. + lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black. lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. lo_style_bold_border = lo_excel->add_new_style( ). lo_style_bold_border->font->bold = abap_true. lo_style_bold_border->font->italic = abap_false. - lo_style_bold_border->font->color = zcl_excel_style_color=>c_black. + lo_style_bold_border->font->color-rgb = zcl_excel_style_color=>c_black. lo_style_bold_border->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. lo_style_bold_border->borders->allborders = lo_border_dark. lv_style_bold_border_guid = lo_style_bold_border->get_guid( ). diff --git a/ZA2X/PROG/ZDEMO_EXCEL17.slnk b/ZA2X/PROG/ZDEMO_EXCEL17.slnk index 6789e35..be416f5 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL17.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL17.slnk @@ -1,5 +1,5 @@ - + @@ -76,7 +76,7 @@ START-OF-SELECTION. " Another style which should not affect the unlock style lo_style = lo_excel->add_new_style( ). lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style->fill->fgcolor = 'FFCC3333'. + lo_style->fill->fgcolor-rgb = 'FFCC3333'. lv_style = lo_style->get_guid( ). lo_worksheet->set_cell( ip_row = 3 ip_column = 'C' ip_value = 'This cell is locked locked and has the second formating' ip_style = lv_style ). lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'This cell is unlocked' ip_style = lv_style_protection_guid ). diff --git a/ZA2X/PROG/ZDEMO_EXCEL2.slnk b/ZA2X/PROG/ZDEMO_EXCEL2.slnk index c069801..45b4d25 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL2.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL2.slnk @@ -1,5 +1,5 @@ - + @@ -70,16 +70,16 @@ START-OF-SELECTION. " Create border object CREATE OBJECT lo_border_dark. - lo_border_dark->border_color = zcl_excel_style_color=>c_black. + lo_border_dark->border_color-rgb = zcl_excel_style_color=>c_black. lo_border_dark->border_style = zcl_excel_style_border=>c_border_thin. CREATE OBJECT lo_border_light. - lo_border_light->border_color = zcl_excel_style_color=>c_gray. + lo_border_light->border_color-rgb = zcl_excel_style_color=>c_gray. lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. " Create a bold / italic style lo_style_bold = lo_excel->add_new_style( ). lo_style_bold->font->bold = abap_true. lo_style_bold->font->italic = abap_true. - lo_style_bold->font->color = zcl_excel_style_color=>c_red. + lo_style_bold->font->color-rgb = zcl_excel_style_color=>c_red. lv_style_bold_guid = lo_style_bold->get_guid( ). " Create an underline double style lo_style_underline = lo_excel->add_new_style( ). @@ -89,7 +89,7 @@ START-OF-SELECTION. " Create filled style yellow lo_style_filled = lo_excel->add_new_style( ). lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_yellow. + lo_style_filled->fill->fgcolor-theme = zcl_excel_style_color=>c_theme_accent6. lv_style_filled_guid = lo_style_filled->get_guid( ). " Create border with button effects lo_style_button = lo_excel->add_new_style( ). @@ -105,7 +105,7 @@ START-OF-SELECTION. " Create filled style green lo_style_filled = lo_excel->add_new_style( ). lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style_filled->fill->fgcolor = zcl_excel_style_color=>c_green. + lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_green. lv_style_filled_green_guid = lo_style_filled->get_guid( ). " Get active sheet diff --git a/ZA2X/PROG/ZDEMO_EXCEL21.slnk b/ZA2X/PROG/ZDEMO_EXCEL21.slnk index b4ee8e0..aa85efa 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL21.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL21.slnk @@ -1,5 +1,5 @@ - + @@ -102,7 +102,7 @@ START-OF-SELECTION. APPEND INITIAL LINE TO color_styles ASSIGNING <color_style>. lo_style_filled = lo_excel->add_new_style( ). lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style_filled->fill->fgcolor = color. + lo_style_filled->fill->fgcolor-rgb = color. <color_style>-color = color. <color_style>-style = lo_style_filled->get_guid( ). blue = blue + step. diff --git a/ZA2X/PROG/ZDEMO_EXCEL22.slnk b/ZA2X/PROG/ZDEMO_EXCEL22.slnk index 6063fbe..4d3818f 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL22.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL22.slnk @@ -77,7 +77,7 @@ START-OF-SELECTION. " sheet style (white background) lo_style = lo_excel->add_new_style( ). lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style->fill->fgcolor = zcl_excel_style_color=>c_white. + lo_style->fill->fgcolor-rgb = zcl_excel_style_color=>c_white. lv_style_guid = lo_style->get_guid( ). " Get active sheet @@ -92,13 +92,13 @@ START-OF-SELECTION. " Create cell style for display only fields lo_style = lo_excel->add_new_style( ). lo_style->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style->fill->fgcolor = zcl_excel_style_color=>c_gray. + lo_style->fill->fgcolor-rgb = zcl_excel_style_color=>c_gray. lo_style->number_format->format_code = zcl_excel_style_number_format=>c_format_text. " Create cell style for display only date field lo_style_date = lo_excel->add_new_style( ). lo_style_date->fill->filltype = zcl_excel_style_fill=>c_fill_solid. - lo_style_date->fill->fgcolor = zcl_excel_style_color=>c_gray. + lo_style_date->fill->fgcolor-rgb = zcl_excel_style_color=>c_gray. lo_style_date->number_format->format_code = zcl_excel_style_number_format=>c_format_date_ddmmyyyy. " Create cell style for editable fields diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk index 0dd48c2..0fc3a53 100644 --- a/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_BORDER.slnk @@ -1,14 +1,34 @@ - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_COLOR.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_COLOR.slnk new file mode 100644 index 0000000..722ffb8 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_COLOR.slnk @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk index 3c70c4b..e1325ca 100644 --- a/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_FILL.slnk @@ -1,8 +1,16 @@ - + - - - - + + + + + + + + + + + + diff --git a/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk b/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk index 697d15d..8bd8b47 100644 --- a/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk +++ b/ZA2X/TABL/ZEXCEL_S_STYLE_FONT.slnk @@ -1,14 +1,18 @@ - + - - - - - - - - - - + + + + + + + + + + + + + +