From 9b5cf42123600832aa064a39300587e99c550f23 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 27 Aug 2014 11:23:28 -0500 Subject: [PATCH] Fix issue #330 Adding ColorScale Conditional formatting --- ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk | 106 ++++++++++--------- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 78 +++++++++++++- ZA2X/TABL/ZEXCEL_CONDITIONAL_COLORSCALE.slnk | 13 +++ 3 files changed, 142 insertions(+), 55 deletions(-) create mode 100644 ZA2X/TABL/ZEXCEL_CONDITIONAL_COLORSCALE.slnk diff --git a/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk b/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk index f90f932..cbb9715 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_STYLE_CONDITIONAL.slnk @@ -9,54 +9,58 @@ *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CONSTRUCTOR. @@ -84,7 +88,7 @@ me->stop_cell-cell_column = 1. me->start_cell-cell_row = 1. me->start_cell-cell_column = 1. -endmethod. + endmethod. @@ -94,7 +98,7 @@ endmethod. ELSE. CONCATENATE start_cell-cell_coords ':' stop_cell-cell_coords INTO ep_dimension_range. ENDIF. -endmethod. + endmethod. @@ -120,6 +124,6 @@ endmethod. SHIFT lv_row_alpha RIGHT DELETING TRAILING space. SHIFT lv_row_alpha LEFT DELETING LEADING space. CONCATENATE ip_start_column lv_row_alpha INTO start_cell-cell_coords. -endmethod. + endmethod. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 2236c17..a249b1d 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -2624,7 +2624,16 @@ - method CREATE_XL_SHEET. + METHOD create_xl_sheet. +*--------------------------------------------------------------------* +* issue #330 - Adding ColorScale conditional formatting +* - Ivan Femia, 2014-08-25 +*--------------------------------------------------------------------* + + TYPES: BEGIN OF colors, + colorrgb TYPE zexcel_color, + END OF colors. + *--------------------------------------------------------------------* * issue #237 - Error writing column-style * - Stefan Schmöcker, 2012-11-01 @@ -2675,6 +2684,7 @@ lc_xml_node_cfrule TYPE string VALUE 'cfRule', lc_xml_node_color TYPE string VALUE 'color', " Databar by Albert Lladanosa lc_xml_node_databar TYPE string VALUE 'dataBar', " Databar by Albert Lladanosa + lc_xml_node_colorscale TYPE string VALUE 'colorScale', lc_xml_node_iconset TYPE string VALUE 'iconSet', lc_xml_node_cfvo TYPE string VALUE 'cfvo', lc_xml_node_formula TYPE string VALUE 'formula', @@ -2827,11 +2837,14 @@ lv_style_guid TYPE zexcel_cell_style, lv_flag TYPE c, ls_databar TYPE zexcel_conditional_databar, " Databar by Albert Lladanosa + ls_colorscale TYPE zexcel_conditional_colorscale, ls_iconset TYPE zexcel_conditional_iconset, ls_cellis TYPE zexcel_conditional_cellis, ls_expression TYPE zexcel_conditional_expression, lt_cfvo TYPE TABLE OF cfvo, ls_cfvo TYPE cfvo, + lt_colors TYPE TABLE OF colors, + ls_colors TYPE colors, lv_cell_row_s TYPE string, ls_last_row TYPE zexcel_s_cell_data, ls_style_mapping TYPE zexcel_s_styles_mapping, @@ -3682,7 +3695,7 @@ value = lv_value ). CASE lo_style_conditional->rule. - " Start >> Databar by Albert Lladanosa + " Start >> Databar by Albert Lladanosa WHEN zcl_excel_style_conditional=>c_rule_databar. ls_databar = lo_style_conditional->mode_databar. @@ -3721,7 +3734,64 @@ lo_element_3->append_child( new_child = lo_element_4 ). " color node lo_element_2->append_child( new_child = lo_element_3 ). " databar node - " End << Databar by Albert Lladanosa + " End << Databar by Albert Lladanosa + WHEN zcl_excel_style_conditional=>c_rule_colorscale. + + ls_colorscale = lo_style_conditional->mode_colorscale. + + CLEAR lt_cfvo. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_colorscale + parent = lo_document ). + + MOVE ls_colorscale-cfvo1_value TO ls_cfvo-value. + MOVE ls_colorscale-cfvo1_type TO ls_cfvo-type. + APPEND ls_cfvo TO lt_cfvo. + + MOVE ls_colorscale-cfvo2_value TO ls_cfvo-value. + MOVE ls_colorscale-cfvo2_type TO ls_cfvo-type. + APPEND ls_cfvo TO lt_cfvo. + + MOVE ls_colorscale-cfvo3_value TO ls_cfvo-value. + MOVE ls_colorscale-cfvo3_type TO ls_cfvo-type. + APPEND ls_cfvo TO lt_cfvo. + + APPEND ls_colorscale-colorrgb1 TO lt_colors. + APPEND ls_colorscale-colorrgb2 TO lt_colors. + APPEND ls_colorscale-colorrgb3 TO lt_colors. + + LOOP AT lt_cfvo INTO ls_cfvo. + + IF ls_cfvo IS INITIAL. + CONTINUE. + ENDIF. + + " cfvo node + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_cfvo + parent = lo_document ). + lv_value = ls_cfvo-type. + lo_element_4->set_attribute_ns( name = lc_xml_attr_type + value = lv_value ). + lv_value = ls_cfvo-value. + lo_element_4->set_attribute_ns( name = lc_xml_attr_val + value = lv_value ). + lo_element_3->append_child( new_child = lo_element_4 ). " cfvo node + ENDLOOP. + LOOP AT lt_colors INTO ls_colors. + + IF ls_colors IS INITIAL. + CONTINUE. + ENDIF. + + lo_element_4 = lo_document->create_simple_element( name = lc_xml_node_color + parent = lo_document ). + lv_value = ls_colors-colorrgb. + lo_element_4->set_attribute_ns( name = lc_xml_attr_tabcolor_rgb + value = lv_value ). + + lo_element_3->append_child( new_child = lo_element_4 ). " color node + ENDLOOP. + + lo_element_2->append_child( new_child = lo_element_3 ). " databar node WHEN zcl_excel_style_conditional=>c_rule_iconset. ls_iconset = lo_style_conditional->mode_iconset. @@ -4275,7 +4345,7 @@ lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). - endmethod. +ENDMETHOD. diff --git a/ZA2X/TABL/ZEXCEL_CONDITIONAL_COLORSCALE.slnk b/ZA2X/TABL/ZEXCEL_CONDITIONAL_COLORSCALE.slnk new file mode 100644 index 0000000..7735815 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_CONDITIONAL_COLORSCALE.slnk @@ -0,0 +1,13 @@ + + + + + + + + + + + + +