#236: Chart creation in a worksheet from ABAP

Added:
- Labels management
- Serie name

TODO: Multiple series and bar charts

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@383 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
Alessandro Iannacci 2012-12-04 15:15:40 +00:00
parent 181ac2cb38
commit f73376b3e0
4 changed files with 212 additions and 164 deletions

View File

@ -426,8 +426,20 @@ endmethod.</source>
node2 ?= node-&gt;find_from_name( name = &apos;order&apos; namespace = &apos;c&apos; ). node2 ?= node-&gt;find_from_name( name = &apos;order&apos; namespace = &apos;c&apos; ).
zcl_excel_reader_2007=&gt;fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). zcl_excel_reader_2007=&gt;fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ).
lo_piechart-&gt;ns_orderval = ls_prop-val. lo_piechart-&gt;ns_orderval = ls_prop-val.
node2 ?= node-&gt;find_from_name( name = &apos;f&apos; namespace = &apos;c&apos; ). node2 ?= node-&gt;find_from_name( name = &apos;v&apos; namespace = &apos;c&apos; ).
if node2 is bound.
lo_piechart-&gt;sername = node2-&gt;get_value( ).
endif.
node2 ?= node-&gt;find_from_name( name = &apos;strRef&apos; namespace = &apos;c&apos; ).
if node2 is bound.
node3 ?= node2-&gt;find_from_name( name = &apos;f&apos; namespace = &apos;c&apos; ).
lo_piechart-&gt;LBL = node3-&gt;get_value( ).
endif.
node2 ?= node-&gt;find_from_name( name = &apos;numRef&apos; namespace = &apos;c&apos; ).
if node2 is bound.
node3 ?= node2-&gt;find_from_name( name = &apos;f&apos; namespace = &apos;c&apos; ).
lo_piechart-&gt;REF = node3-&gt;get_value( ). lo_piechart-&gt;REF = node3-&gt;get_value( ).
endif.
&quot;note: numCache avoided &quot;note: numCache avoided
node2 ?= node-&gt;find_from_name( name = &apos;showLegendKey&apos; namespace = &apos;c&apos; ). node2 ?= node-&gt;find_from_name( name = &apos;showLegendKey&apos; namespace = &apos;c&apos; ).
zcl_excel_reader_2007=&gt;fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ). zcl_excel_reader_2007=&gt;fill_struct_from_attributes( EXPORTING ip_element = node2 CHANGING cp_structure = ls_prop ).

View File

@ -27,7 +27,9 @@ public section.
footer TYPE string, footer TYPE string,
END OF t_pagemargins . END OF t_pagemargins .
data LBL type STRING .
data REF type STRING . data REF type STRING .
data SERNAME type STRING .
data NS_1904VAL type STRING value &apos;0&apos;. &quot;#EC NOTEXT . data NS_1904VAL type STRING value &apos;0&apos;. &quot;#EC NOTEXT .
data NS_LANGVAL type STRING value &apos;it-IT&apos;. &quot;#EC NOTEXT . data NS_LANGVAL type STRING value &apos;it-IT&apos;. &quot;#EC NOTEXT .
data NS_ROUNDEDCORNERSVAL type STRING value &apos;0&apos;. &quot;#EC NOTEXT . data NS_ROUNDEDCORNERSVAL type STRING value &apos;0&apos;. &quot;#EC NOTEXT .
@ -52,15 +54,17 @@ public section.
*&quot;* components in the private section</localTypes> *&quot;* components in the private section</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need <localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros> *&quot;* in the implementation part of the class</localMacros>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_1904VAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="2 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="LBL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="1 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_AUTOTITLEDELETEDVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="6 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_1904VAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="4 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_DISPBLANKSASVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="8 " ATTDECLTYP="0" ATTVALUE="&apos;gap&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_AUTOTITLEDELETEDVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="8 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_LANGVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="3 " ATTDECLTYP="0" ATTVALUE="&apos;it-IT&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_DISPBLANKSASVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="10 " ATTDECLTYP="0" ATTVALUE="&apos;gap&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_PLOTVISONLYVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="7 " ATTDECLTYP="0" ATTVALUE="&apos;1&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_LANGVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="5 " ATTDECLTYP="0" ATTVALUE="&apos;it-IT&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_ROUNDEDCORNERSVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="4 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_PLOTVISONLYVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="9 " ATTDECLTYP="0" ATTVALUE="&apos;1&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_SHOWDLBLSOVERMAXVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="9 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_ROUNDEDCORNERSVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="6 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="PAGEMARGINS" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="5 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="T_PAGEMARGINS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="NS_SHOWDLBLSOVERMAXVAL" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="11 " ATTDECLTYP="0" ATTVALUE="&apos;0&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="REF" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="1 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/> <attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="PAGEMARGINS" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="7 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="T_PAGEMARGINS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="REF" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="2 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="SERNAME" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="3 " ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="STRING" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<method CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="CONSTRUCTOR" VERSION="1" LANGU="E" DESCRIPT="CONSTRUCTOR" EXPOSURE="2" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="2" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0"> <method CLSNAME="ZCL_EXCEL_GRAPH" CMPNAME="CONSTRUCTOR" VERSION="1" LANGU="E" DESCRIPT="CONSTRUCTOR" EXPOSURE="2" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="2" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>method CONSTRUCTOR. <source>method CONSTRUCTOR.
&quot;Load default values &quot;Load default values

View File

@ -1110,50 +1110,54 @@ endmethod.</source>
&quot;---------------------------CHART &quot;---------------------------CHART
lc_xml_node_chart TYPE string VALUE &apos;c:chart&apos;, lc_xml_node_chart TYPE string VALUE &apos;c:chart&apos;,
lc_xml_node_autoTitleDeleted TYPE string VALUE &apos;c:autoTitleDeleted&apos;, lc_xml_node_autotitledeleted TYPE string VALUE &apos;c:autoTitleDeleted&apos;,
&quot;plotArea &quot;plotArea
lc_xml_node_plotArea TYPE string VALUE &apos;c:plotArea&apos;, lc_xml_node_plotarea TYPE string VALUE &apos;c:plotArea&apos;,
lc_xml_node_layout TYPE string VALUE &apos;c:layout&apos;, lc_xml_node_layout TYPE string VALUE &apos;c:layout&apos;,
&quot;plotArea-&gt;pie &quot;plotArea-&gt;pie
lc_xml_node_pieChart TYPE string VALUE &apos;c:pieChart&apos;, lc_xml_node_piechart TYPE string VALUE &apos;c:pieChart&apos;,
lc_xml_node_varyColors TYPE string VALUE &apos;c:varyColors&apos;, lc_xml_node_varycolors TYPE string VALUE &apos;c:varyColors&apos;,
lc_xml_node_ser TYPE string VALUE &apos;c:ser&apos;, lc_xml_node_ser TYPE string VALUE &apos;c:ser&apos;,
lc_xml_node_idx TYPE string VALUE &apos;c:idx&apos;, lc_xml_node_idx TYPE string VALUE &apos;c:idx&apos;,
lc_xml_node_order TYPE string VALUE &apos;c:order&apos;, lc_xml_node_order TYPE string VALUE &apos;c:order&apos;,
lc_xml_node_tx TYPE string VALUE &apos;c:tx&apos;,
lc_xml_node_v TYPE string VALUE &apos;c:v&apos;,
lc_xml_node_val TYPE string VALUE &apos;c:val&apos;, lc_xml_node_val TYPE string VALUE &apos;c:val&apos;,
lc_xml_node_numRef TYPE string VALUE &apos;c:numRef&apos;, lc_xml_node_cat TYPE string VALUE &apos;c:cat&apos;,
lc_xml_node_numref TYPE string VALUE &apos;c:numRef&apos;,
lc_xml_node_strref TYPE string VALUE &apos;c:strRef&apos;,
lc_xml_node_f TYPE string VALUE &apos;c:f&apos;, &quot;this is the range lc_xml_node_f TYPE string VALUE &apos;c:f&apos;, &quot;this is the range
&quot;note: numcache avoided &quot;note: numcache avoided
lc_xml_node_dLbls TYPE string VALUE &apos;c:dLbls&apos;, lc_xml_node_dlbls TYPE string VALUE &apos;c:dLbls&apos;,
lc_xml_node_showLegendKey TYPE string VALUE &apos;c:showLegendKey&apos;, lc_xml_node_showlegendkey TYPE string VALUE &apos;c:showLegendKey&apos;,
lc_xml_node_showVal TYPE string VALUE &apos;c:showVal&apos;, lc_xml_node_showval TYPE string VALUE &apos;c:showVal&apos;,
lc_xml_node_showCatName TYPE string VALUE &apos;c:showCatName&apos;, lc_xml_node_showcatname TYPE string VALUE &apos;c:showCatName&apos;,
lc_xml_node_showSerName TYPE string VALUE &apos;c:showSerName&apos;, lc_xml_node_showsername TYPE string VALUE &apos;c:showSerName&apos;,
lc_xml_node_showPercent TYPE string VALUE &apos;c:showPercent&apos;, lc_xml_node_showpercent TYPE string VALUE &apos;c:showPercent&apos;,
lc_xml_node_showBubbleSize TYPE string VALUE &apos;c:showBubbleSize&apos;, lc_xml_node_showbubblesize TYPE string VALUE &apos;c:showBubbleSize&apos;,
lc_xml_node_showLeaderLines TYPE string VALUE &apos;c:showLeaderLines&apos;, lc_xml_node_showleaderlines TYPE string VALUE &apos;c:showLeaderLines&apos;,
lc_xml_node_firstSliceAng TYPE string VALUE &apos;c:firstSliceAng&apos;, lc_xml_node_firstsliceang TYPE string VALUE &apos;c:firstSliceAng&apos;,
&quot;plotArea-&gt;bar &quot;plotArea-&gt;bar
lc_xml_node_barChart TYPE string VALUE &apos;c:barChart&apos;, lc_xml_node_barchart TYPE string VALUE &apos;c:barChart&apos;,
lc_xml_node_catAx TYPE string VALUE &apos;c:catAx&apos;, lc_xml_node_catax TYPE string VALUE &apos;c:catAx&apos;,
lc_xml_node_valAx TYPE string VALUE &apos;c:valAx&apos;, lc_xml_node_valax TYPE string VALUE &apos;c:valAx&apos;,
&quot;legend &quot;legend
lc_xml_node_legend TYPE string VALUE &apos;c:legend&apos;, lc_xml_node_legend TYPE string VALUE &apos;c:legend&apos;,
&quot;legend-&gt;pie &quot;legend-&gt;pie
lc_xml_node_legendPos TYPE string VALUE &apos;c:legendPos&apos;, lc_xml_node_legendpos TYPE string VALUE &apos;c:legendPos&apos;,
* lc_xml_node_layout TYPE string VALUE &apos;c:layout&apos;, &quot;already exist * lc_xml_node_layout TYPE string VALUE &apos;c:layout&apos;, &quot;already exist
lc_xml_node_overlay TYPE string VALUE &apos;c:overlay&apos;, lc_xml_node_overlay TYPE string VALUE &apos;c:overlay&apos;,
lc_xml_node_txPr TYPE string VALUE &apos;c:txPr&apos;, lc_xml_node_txpr TYPE string VALUE &apos;c:txPr&apos;,
lc_xml_node_bodyPr TYPE string VALUE &apos;a:bodyPr&apos;, lc_xml_node_bodypr TYPE string VALUE &apos;a:bodyPr&apos;,
lc_xml_node_lstStyle TYPE string VALUE &apos;a:lstStyle&apos;, lc_xml_node_lststyle TYPE string VALUE &apos;a:lstStyle&apos;,
lc_xml_node_p TYPE string VALUE &apos;a:p&apos;, lc_xml_node_p TYPE string VALUE &apos;a:p&apos;,
lc_xml_node_pPr TYPE string VALUE &apos;a:pPr&apos;, lc_xml_node_ppr TYPE string VALUE &apos;a:pPr&apos;,
lc_xml_node_defRPr TYPE string VALUE &apos;a:defRPr&apos;, lc_xml_node_defrpr TYPE string VALUE &apos;a:defRPr&apos;,
lc_xml_node_endParaRPr TYPE string VALUE &apos;a:endParaRPr&apos;, lc_xml_node_endpararpr TYPE string VALUE &apos;a:endParaRPr&apos;,
&quot;legend-&gt;bar &quot;legend-&gt;bar
lc_xml_node_plotVisOnly TYPE string VALUE &apos;c:plotVisOnly&apos;, lc_xml_node_plotvisonly TYPE string VALUE &apos;c:plotVisOnly&apos;,
lc_xml_node_dispBlanksAs TYPE string VALUE &apos;c:dispBlanksAs&apos;, lc_xml_node_dispblanksas TYPE string VALUE &apos;c:dispBlanksAs&apos;,
lc_xml_node_showDLblsOverMax TYPE string VALUE &apos;c:showDLblsOverMax&apos;, lc_xml_node_showdlblsovermax TYPE string VALUE &apos;c:showDLblsOverMax&apos;,
&quot;---------------------------END OF CHART &quot;---------------------------END OF CHART
lc_xml_node_printsettings TYPE string VALUE &apos;c:printSettings&apos;, lc_xml_node_printsettings TYPE string VALUE &apos;c:printSettings&apos;,
@ -1271,34 +1275,34 @@ endmethod.</source>
&quot;---------------------------CHART &quot;---------------------------CHART
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_chart lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_chart
parent = lo_element_root ). parent = lo_element_root ).
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_autoTitleDeleted lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_autotitledeleted
parent = lo_element ). parent = lo_element ).
lo_element2-&gt;set_attribute_ns( name = &apos;val&apos; lo_element2-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chart-&gt;ns_autoTitleDeletedval ). value = lo_chart-&gt;ns_autotitledeletedval ).
&quot;plotArea &quot;plotArea
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_plotArea lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_plotarea
parent = lo_element ). parent = lo_element ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_layout lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_layout
parent = lo_element2 ). parent = lo_element2 ).
CASE io_drawing-&gt;graph_type. CASE io_drawing-&gt;graph_type.
WHEN zcl_excel_drawing=&gt;c_graph_bars. WHEN zcl_excel_drawing=&gt;c_graph_bars.
&quot;----bar &quot;----bar
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_barChart lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_barchart
parent = lo_element2 ). parent = lo_element2 ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_catAx lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_catax
parent = lo_element2 ). parent = lo_element2 ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_valAx lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_valax
parent = lo_element2 ). parent = lo_element2 ).
&quot;TODO &quot;TODO
WHEN zcl_excel_drawing=&gt;c_graph_pie. WHEN zcl_excel_drawing=&gt;c_graph_pie.
&quot;----pie &quot;----pie
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_pieChart lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_piechart
parent = lo_element2 ). parent = lo_element2 ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_varyColors lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_varycolors
parent = lo_element3 ). parent = lo_element3 ).
lo_element4-&gt;set_attribute_ns( name = &apos;val&apos; lo_element4-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_varyColorsval ). value = lo_chartp-&gt;ns_varycolorsval ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_ser lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_ser
parent = lo_element3 ). parent = lo_element3 ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_idx lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_idx
@ -1309,47 +1313,65 @@ endmethod.</source>
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_orderval ). value = lo_chartp-&gt;ns_orderval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_val if lo_chartp-&gt;sername is not initial.
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_tx
parent = lo_element4 ). parent = lo_element4 ).
lo_element6 = lo_document-&gt;create_simple_element( name = lc_xml_node_numRef lo_element6 = lo_document-&gt;create_simple_element( name = lc_xml_node_v
parent = lo_element5 ).
lo_element6-&gt;set_value( value = lo_chartp-&gt;sername ).
endif.
IF lo_chartp-&gt;lbl IS NOT INITIAL.
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_cat
parent = lo_element4 ).
lo_element6 = lo_document-&gt;create_simple_element( name = lc_xml_node_strref
parent = lo_element5 ). parent = lo_element5 ).
lo_element7 = lo_document-&gt;create_simple_element( name = lc_xml_node_f lo_element7 = lo_document-&gt;create_simple_element( name = lc_xml_node_f
parent = lo_element6 ). parent = lo_element6 ).
lo_element7-&gt;set_value( value = lo_chartp-&gt;REF ). lo_element7-&gt;set_value( value = lo_chartp-&gt;lbl ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_dLbls ENDIF.
IF lo_chartp-&gt;ref IS NOT INITIAL.
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_val
parent = lo_element4 ).
lo_element6 = lo_document-&gt;create_simple_element( name = lc_xml_node_numref
parent = lo_element5 ).
lo_element7 = lo_document-&gt;create_simple_element( name = lc_xml_node_f
parent = lo_element6 ).
lo_element7-&gt;set_value( value = lo_chartp-&gt;ref ).
ENDIF.
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_dlbls
parent = lo_element3 ). parent = lo_element3 ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showLegendKey lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showlegendkey
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showLegendKeyval ). value = lo_chartp-&gt;ns_showlegendkeyval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showVal lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showval
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showValval ). value = lo_chartp-&gt;ns_showvalval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showCatName lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showcatname
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showCatNameval ). value = lo_chartp-&gt;ns_showcatnameval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showSerName lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showsername
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showSerNameval ). value = lo_chartp-&gt;ns_showsernameval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showPercent lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showpercent
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showPercentval ). value = lo_chartp-&gt;ns_showpercentval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showBubbleSize lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showbubblesize
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showBubbleSizeval ). value = lo_chartp-&gt;ns_showbubblesizeval ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showLeaderLines lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_showleaderlines
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;val&apos; lo_element5-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_showLeaderLinesval ). value = lo_chartp-&gt;ns_showleaderlinesval ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_firstSliceAng lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_firstsliceang
parent = lo_element3 ). parent = lo_element3 ).
lo_element4-&gt;set_attribute_ns( name = &apos;val&apos; lo_element4-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_firstSliceAngval ). value = lo_chartp-&gt;ns_firstsliceangval ).
WHEN OTHERS. WHEN OTHERS.
ENDCASE. ENDCASE.
@ -1362,49 +1384,49 @@ endmethod.</source>
&quot;TODO &quot;TODO
WHEN zcl_excel_drawing=&gt;c_graph_pie. WHEN zcl_excel_drawing=&gt;c_graph_pie.
&quot;----pie &quot;----pie
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_legendPos lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_legendpos
parent = lo_element2 ). parent = lo_element2 ).
lo_element3-&gt;set_attribute_ns( name = &apos;val&apos; lo_element3-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_legendPosval ). value = lo_chartp-&gt;ns_legendposval ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_layout lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_layout
parent = lo_element2 ). parent = lo_element2 ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_overlay lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_overlay
parent = lo_element2 ). parent = lo_element2 ).
lo_element3-&gt;set_attribute_ns( name = &apos;val&apos; lo_element3-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chartp-&gt;ns_overlayval ). value = lo_chartp-&gt;ns_overlayval ).
lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_txPr lo_element3 = lo_document-&gt;create_simple_element( name = lc_xml_node_txpr
parent = lo_element2 ). parent = lo_element2 ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_bodyPr lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_bodypr
parent = lo_element3 ). parent = lo_element3 ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_lstStyle lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_lststyle
parent = lo_element3 ). parent = lo_element3 ).
lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_p lo_element4 = lo_document-&gt;create_simple_element( name = lc_xml_node_p
parent = lo_element3 ). parent = lo_element3 ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_pPr lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_ppr
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;rtl&apos; lo_element5-&gt;set_attribute_ns( name = &apos;rtl&apos;
value = lo_chartp-&gt;ns_pPrrtl ). value = lo_chartp-&gt;ns_pprrtl ).
lo_element6 = lo_document-&gt;create_simple_element( name = lc_xml_node_defRPr lo_element6 = lo_document-&gt;create_simple_element( name = lc_xml_node_defrpr
parent = lo_element5 ). parent = lo_element5 ).
lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_endParaRPr lo_element5 = lo_document-&gt;create_simple_element( name = lc_xml_node_endpararpr
parent = lo_element4 ). parent = lo_element4 ).
lo_element5-&gt;set_attribute_ns( name = &apos;lang&apos; lo_element5-&gt;set_attribute_ns( name = &apos;lang&apos;
value = lo_chartp-&gt;ns_endParaRPrlang ). value = lo_chartp-&gt;ns_endpararprlang ).
WHEN OTHERS. WHEN OTHERS.
ENDCASE. ENDCASE.
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_plotVisOnly lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_plotvisonly
parent = lo_element ). parent = lo_element ).
lo_element2-&gt;set_attribute_ns( name = &apos;val&apos; lo_element2-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chart-&gt;ns_plotVisOnlyval ). value = lo_chart-&gt;ns_plotvisonlyval ).
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_dispBlanksAs lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_dispblanksas
parent = lo_element ). parent = lo_element ).
lo_element2-&gt;set_attribute_ns( name = &apos;val&apos; lo_element2-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chart-&gt;ns_dispBlanksAsval ). value = lo_chart-&gt;ns_dispblanksasval ).
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_showDLblsOverMax lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_showdlblsovermax
parent = lo_element ). parent = lo_element ).
lo_element2-&gt;set_attribute_ns( name = &apos;val&apos; lo_element2-&gt;set_attribute_ns( name = &apos;val&apos;
value = lo_chart-&gt;ns_showDLblsOverMaxval ). value = lo_chart-&gt;ns_showdlblsovermaxval ).
&quot;---------------------------END OF CHART &quot;---------------------------END OF CHART
&quot;printSettings &quot;printSettings
@ -1429,7 +1451,7 @@ endmethod.</source>
lo_element2-&gt;set_attribute_ns( name = &apos;footer&apos; lo_element2-&gt;set_attribute_ns( name = &apos;footer&apos;
value = lo_chart-&gt;pagemargins-footer ). value = lo_chart-&gt;pagemargins-footer ).
&quot;pageSetup &quot;pageSetup
lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_pageSetup lo_element2 = lo_document-&gt;create_simple_element( name = lc_xml_node_pagesetup
parent = lo_element ). parent = lo_element ).
********************************************************************** **********************************************************************

View File

@ -46,6 +46,14 @@ START-OF-SELECTION.
lo_worksheet = lo_excel-&gt;get_active_worksheet( ). lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
lo_worksheet-&gt;set_title( &apos;Sheet1&apos; ). lo_worksheet-&gt;set_title( &apos;Sheet1&apos; ).
&quot; Set labels for chart
lv_value = 1.
lo_worksheet-&gt;set_cell( ip_column = &apos;K&apos; ip_row = 1 ip_value = &apos;One&apos; ).
lv_value = 2.
lo_worksheet-&gt;set_cell( ip_column = &apos;K&apos; ip_row = 2 ip_value = &apos;Two&apos; ).
lv_value = 3.
lo_worksheet-&gt;set_cell( ip_column = &apos;K&apos; ip_row = 3 ip_value = &apos;Three&apos; ).
&quot; Set values for chart &quot; Set values for chart
lv_value = 1. lv_value = 1.
lo_worksheet-&gt;set_cell( ip_column = &apos;J&apos; ip_row = 1 ip_value = lv_value ). lo_worksheet-&gt;set_cell( ip_column = &apos;J&apos; ip_row = 1 ip_value = lv_value ).
@ -57,6 +65,8 @@ START-OF-SELECTION.
&quot; Create a pie chart and assign value range &quot; Create a pie chart and assign value range
CREATE OBJECT lo_pie. CREATE OBJECT lo_pie.
lo_pie-&gt;ref = &apos;Sheet1!$J$1:$J$3&apos;. &quot;VALUE RANGE FOR CHART lo_pie-&gt;ref = &apos;Sheet1!$J$1:$J$3&apos;. &quot;VALUE RANGE FOR CHART
lo_pie-&gt;lbl = &apos;Sheet1!$K$1:$K$3&apos;. &quot;VALUE RANGE FOR CHART
lo_pie-&gt;sername = &apos;My serie&apos;. &quot;Serie name
&quot; Create global drawing, set type as pie chart, assign chart, set position and media type &quot; Create global drawing, set type as pie chart, assign chart, set position and media type
lo_drawing = lo_worksheet-&gt;excel-&gt;add_new_drawing( lo_drawing = lo_worksheet-&gt;excel-&gt;add_new_drawing(
@ -66,8 +76,8 @@ START-OF-SELECTION.
lo_drawing-&gt;graph_type = zcl_excel_drawing=&gt;c_graph_pie. lo_drawing-&gt;graph_type = zcl_excel_drawing=&gt;c_graph_pie.
&quot;Set chart position (anchor 2 cells) &quot;Set chart position (anchor 2 cells)
ls_lower-row = 10. ls_lower-row = 22.
ls_lower-col = 10. ls_lower-col = 11.
lo_drawing-&gt;set_position2( lo_drawing-&gt;set_position2(
EXPORTING EXPORTING
ip_from = ls_upper ip_from = ls_upper