diff --git a/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk b/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk index 564ec79..e967197 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_DRAWING.slnk @@ -420,26 +420,68 @@ endmethod. node2 ?= node->find_from_name( name = 'varyColors' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). lo_piechart->ns_varyColorsval = ls_prop-val. - node2 ?= node->find_from_name( name = 'idx' namespace = 'c' ). - zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). - lo_piechart->ns_idxval = ls_prop-val. - node2 ?= node->find_from_name( name = 'order' namespace = 'c' ). - zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). - lo_piechart->ns_orderval = ls_prop-val. - node2 ?= node->find_from_name( name = 'v' namespace = 'c' ). - if node2 is bound. - lo_piechart->sername = node2->get_value( ). - endif. - node2 ?= node->find_from_name( name = 'strRef' namespace = 'c' ). - if node2 is bound. - node3 ?= node2->find_from_name( name = 'f' namespace = 'c' ). - lo_piechart->LBL = node3->get_value( ). - endif. - node2 ?= node->find_from_name( name = 'numRef' namespace = 'c' ). - if node2 is bound. - node3 ?= node2->find_from_name( name = 'f' namespace = 'c' ). - lo_piechart->REF = node3->get_value( ). + + "Load series + 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_sername type string. + DATA lv_label type string. + DATA lv_value type string. + + CALL METHOD node->get_elements_by_tag_name + EXPORTING +* depth = 0 + name = 'ser' +* namespace = '' + 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( ixml_iid_element ). endif. + WHILE lo_node is bound. + node2 ?= node->find_from_name( name = 'idx' namespace = 'c' ). + zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lv_idx = ls_prop-val. + node2 ?= node->find_from_name( name = 'order' namespace = 'c' ). + zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). + lv_order = ls_prop-val. + node2 ?= node->find_from_name( name = 'v' namespace = 'c' ). + if node2 is bound. + lv_sername = node2->get_value( ). + endif. + node2 ?= node->find_from_name( name = 'strRef' namespace = 'c' ). + if node2 is bound. + node3 ?= node2->find_from_name( name = 'f' namespace = 'c' ). + lv_label = node3->get_value( ). + endif. + node2 ?= node->find_from_name( name = 'numRef' namespace = 'c' ). + if node2 is bound. + node3 ?= node2->find_from_name( name = 'f' namespace = 'c' ). + lv_value = node3->get_value( ). + endif. + CALL METHOD lo_piechart->create_serie + EXPORTING + idx = lv_idx + order = lv_order + lbl = lv_label + REF = lv_value + sername = lv_sername + . + lo_node = lo_iterator->GET_NEXT( ). + if lo_node is bound. + node2 ?= lo_node->query_interface( ixml_iid_element ). + endif. + ENDWHILE. + "note: numCache avoided node2 ?= node->find_from_name( name = 'showLegendKey' namespace = 'c' ). zcl_excel_reader_2007=>fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). diff --git a/ZA2X/CLAS/ZCL_EXCEL_GRAPH.slnk b/ZA2X/CLAS/ZCL_EXCEL_GRAPH.slnk index fa21e1a..45b318b 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_GRAPH.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_GRAPH.slnk @@ -1,13 +1,23 @@ - + + class ZCL_EXCEL_GRAPH definition public @@ -18,28 +28,43 @@ public section. *"* do not include other source files here!!! 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 . + BEGIN OF s_series, + idx TYPE i, + order TYPE i, + 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 LBL type STRING . - data REF type STRING . - data SERNAME type STRING . 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 T_PAGEMARGINS . + 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 SERIES type T_SERIES . - methods CONSTRUCTOR . + methods CONSTRUCTOR . + methods CREATE_SERIE + importing + !IDX type I + !ORDER type I + !LBL type STRING + !REF type STRING + !SERNAME type STRING . protected section. *"* protected components of class ZCL_EXCEL_GRAPH *"* do not include other source files here!!! @@ -54,17 +79,15 @@ public section. *"* components in the private section *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - - - - - - - + + + + + + + + + method CONSTRUCTOR. "Load default values @@ -76,4 +99,21 @@ public section. me->pagemargins-footer = '0.3'. endmethod. + + + + + + + METHOD create_serie. + DATA ls_serie TYPE s_series. + ls_serie-idx = idx. + ls_serie-order = order. + ls_serie-lbl = lbl. + ls_serie-ref = ref. + ls_serie-sername = sername. + APPEND ls_serie TO me->series. + SORT me->series BY order ASCENDING. +ENDMETHOD. + diff --git a/ZA2X/CLAS/ZCL_EXCEL_GRAPH_PIE.slnk b/ZA2X/CLAS/ZCL_EXCEL_GRAPH_PIE.slnk index c3dee2c..2435218 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_GRAPH_PIE.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_GRAPH_PIE.slnk @@ -16,8 +16,6 @@ public section. 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_IDXVAL type STRING value '0'. "#EC NOTEXT . - data NS_ORDERVAL 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 . @@ -41,18 +39,16 @@ public section. *"* in the implementation part of the class - - - - - - - - - + + + + + + + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 1799d21..936ea07 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -1303,41 +1303,53 @@ endmethod. parent = lo_element3 ). lo_element4->set_attribute_ns( name = 'val' value = lo_chartp->ns_varycolorsval ). - lo_element4 = lo_document->create_simple_element( name = lc_xml_node_ser + + "series + data ls_serie type zcl_excel_graph=>s_series. + data lv_str type string. + loop at lo_chartp->SERIES into ls_serie. + lo_element4 = lo_document->create_simple_element( name = lc_xml_node_ser parent = lo_element3 ). - lo_element5 = lo_document->create_simple_element( name = lc_xml_node_idx + lo_element5 = lo_document->create_simple_element( name = lc_xml_node_idx parent = lo_element4 ). - lo_element5->set_attribute_ns( name = 'val' - value = lo_chartp->ns_idxval ). - lo_element5 = lo_document->create_simple_element( name = lc_xml_node_order + lv_str = ls_serie-idx. + condense lv_str. + lo_element5->set_attribute_ns( name = 'val' + value = lv_str ). + lo_element5 = lo_document->create_simple_element( name = lc_xml_node_order parent = lo_element4 ). - lo_element5->set_attribute_ns( name = 'val' - value = lo_chartp->ns_orderval ). - if lo_chartp->sername is not initial. - lo_element5 = lo_document->create_simple_element( name = lc_xml_node_tx + lv_str = ls_serie-order. + condense lv_str. + lo_element5->set_attribute_ns( name = 'val' + value = lv_str ). + if ls_serie-sername is not initial. + lo_element5 = lo_document->create_simple_element( name = lc_xml_node_tx parent = lo_element4 ). - lo_element6 = lo_document->create_simple_element( name = lc_xml_node_v + lo_element6 = lo_document->create_simple_element( name = lc_xml_node_v parent = lo_element5 ). - lo_element6->set_value( value = lo_chartp->sername ). - endif. - IF lo_chartp->lbl IS NOT INITIAL. - lo_element5 = lo_document->create_simple_element( name = lc_xml_node_cat + lo_element6->set_value( value = ls_serie-sername ). + endif. + IF ls_serie-lbl IS NOT INITIAL. + lo_element5 = lo_document->create_simple_element( name = lc_xml_node_cat parent = lo_element4 ). - lo_element6 = lo_document->create_simple_element( name = lc_xml_node_strref + lo_element6 = lo_document->create_simple_element( name = lc_xml_node_strref parent = lo_element5 ). - lo_element7 = lo_document->create_simple_element( name = lc_xml_node_f + lo_element7 = lo_document->create_simple_element( name = lc_xml_node_f parent = lo_element6 ). - lo_element7->set_value( value = lo_chartp->lbl ). - ENDIF. - IF lo_chartp->ref IS NOT INITIAL. - lo_element5 = lo_document->create_simple_element( name = lc_xml_node_val + lo_element7->set_value( value = ls_serie-lbl ). + ENDIF. + IF ls_serie-ref IS NOT INITIAL. + lo_element5 = lo_document->create_simple_element( name = lc_xml_node_val parent = lo_element4 ). - lo_element6 = lo_document->create_simple_element( name = lc_xml_node_numref + lo_element6 = lo_document->create_simple_element( name = lc_xml_node_numref parent = lo_element5 ). - lo_element7 = lo_document->create_simple_element( name = lc_xml_node_f + lo_element7 = lo_document->create_simple_element( name = lc_xml_node_f parent = lo_element6 ). - lo_element7->set_value( value = lo_chartp->ref ). - ENDIF. + lo_element7->set_value( value = ls_serie-ref ). + ENDIF. + endloop. + "endseries + lo_element4 = lo_document->create_simple_element( name = lc_xml_node_dlbls parent = lo_element3 ). lo_element5 = lo_document->create_simple_element( name = lc_xml_node_showlegendkey diff --git a/ZA2X/PROG/ZDEMO_EXCEL39.slnk b/ZA2X/PROG/ZDEMO_EXCEL39.slnk index 1ac3867..4583ef9 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL39.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL39.slnk @@ -62,11 +62,26 @@ START-OF-SELECTION. lv_value = 3. lo_worksheet->set_cell( ip_column = 'J' ip_row = 3 ip_value = lv_value ). - " Create a pie chart and assign value range + " Create a pie chart and series CREATE OBJECT lo_pie. - lo_pie->ref = 'Sheet1!$J$1:$J$3'. "VALUE RANGE FOR CHART - lo_pie->lbl = 'Sheet1!$K$1:$K$3'. "VALUE RANGE FOR CHART - lo_pie->sername = 'My serie'. "Serie name + + CALL METHOD lo_pie->create_serie + EXPORTING + idx = 0 + order = 0 + lbl = 'Sheet1!$K$1:$K$3' + REF = 'Sheet1!$J$1:$J$3' + sername = 'My serie 1' + . + + CALL METHOD lo_pie->create_serie + EXPORTING + idx = 1 + order = 1 + lbl = 'Sheet1!$K$1:$K$3' + REF = 'Sheet1!$J$1:$J$3' + sername = 'My serie 2' + . " Create global drawing, set type as pie chart, assign chart, set position and media type lo_drawing = lo_worksheet->excel->add_new_drawing(