Fix #92 - Enable changing legacy color palette (to change colors on Excel ver <= 2003)

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@206 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
Tomek Mackowski 2011-07-11 21:51:08 +00:00
parent d40950c96f
commit 65bb19e575
5 changed files with 238 additions and 7 deletions

View File

@ -26,6 +26,7 @@ public section.
TITLE = &apos;abap2xlsx&apos; .
data SECURITY type ref to ZCL_EXCEL_SECURITY .
data LEGACY_PALETTE type ref to ZCL_EXCEL_LEGACY_PALETTE read-only .
methods ADD_NEW_DRAWING
importing
@ -96,11 +97,14 @@ protected section.</protectedSection>
*&quot;* implementation or private method&apos;s signature</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="DRAWINGS" VERSION="1" LANGU="E" DESCRIPT="Worksheets collection" EXPOSURE="0" STATE="1" EDITORDER="1 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110528" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_DRAWINGS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="RANGES" VERSION="1" LANGU="E" DESCRIPT="Ranges collection" EXPOSURE="0" STATE="1" EDITORDER="2 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110611" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_RANGES" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="SECURITY" VERSION="1" LANGU="E" DESCRIPT="Security" EXPOSURE="2" STATE="1" EDITORDER="3 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110611" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_SECURITY" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="STYLES" VERSION="1" LANGU="E" DESCRIPT="Styles collection" EXPOSURE="0" STATE="1" EDITORDER="4 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110611" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLES" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="WORKSHEETS" VERSION="1" LANGU="E" DESCRIPT="Worksheets collection" EXPOSURE="0" STATE="1" EDITORDER="5 " AUTHOR="FEMIA" CREATEDON="20110528" CHANGEDBY="FEMIA" CHANGEDON="20110611" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEETS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<textPool/>
<classDocumentation/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="DRAWINGS" VERSION="1" LANGU="E" DESCRIPT="Worksheets collection" EXPOSURE="0" STATE="1" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20110711" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_DRAWINGS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="LEGACY_PALETTE" VERSION="1" LANGU="E" EXPOSURE="2" STATE="1" EDITORDER="2 " AUTHOR="BCUSER" CREATEDON="20110711" CHANGEDON="00000000" ATTDECLTYP="0" ATTRDONLY="X" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_LEGACY_PALETTE" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="RANGES" VERSION="1" LANGU="E" DESCRIPT="Ranges collection" EXPOSURE="0" STATE="1" EDITORDER="2 " AUTHOR="BCUSER" CREATEDON="20110711" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_RANGES" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="SECURITY" VERSION="1" LANGU="E" DESCRIPT="Security" EXPOSURE="2" STATE="1" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20110711" CHANGEDBY="BCUSER" CHANGEDON="20110711" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_SECURITY" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="STYLES" VERSION="1" LANGU="E" DESCRIPT="Styles collection" EXPOSURE="0" STATE="1" EDITORDER="4 " AUTHOR="BCUSER" CREATEDON="20110711" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_STYLES" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL" CMPNAME="WORKSHEETS" VERSION="1" LANGU="E" DESCRIPT="Worksheets collection" EXPOSURE="0" STATE="1" EDITORDER="5 " AUTHOR="BCUSER" CREATEDON="20110711" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="3" TYPE="ZCL_EXCEL_WORKSHEETS" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<interfaceMethod CLSNAME="ZCL_EXCEL" CPDNAME="ZIF_EXCEL_BOOK_PROTECTION~INITIALIZE">
<source>method ZIF_EXCEL_BOOK_PROTECTION~INITIALIZE.
me-&gt;zif_excel_book_protection~protected = zif_excel_book_protection=&gt;c_unprotected.
@ -189,6 +193,7 @@ endmethod.</source>
CREATE OBJECT ranges.
CREATE OBJECT styles.
CREATE OBJECT drawings.
CREATE OBJECT legacy_palette.
me-&gt;zif_excel_book_protection~initialize( ).
me-&gt;zif_excel_book_properties~initialize( ).

View File

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="utf-16"?>
<CLAS CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" VERSION="1" LANGU="E" DESCRIPT="Excel legacy color palette" UUID="00235A8D06891EE0A99EAB131A4E70BD" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="BCUSER" CREATEDON="20110702" CHANGEDON="00000000" CHGDANYON="00000000" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="702" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 ">
<publicSection>class ZCL_EXCEL_LEGACY_PALETTE definition
public
create public .
public section.
*&quot;* public components of class ZCL_EXCEL_LEGACY_PALETTE
*&quot;* do not include other source files here!!!
type-pools ABAP .
methods CONSTRUCTOR .
methods IS_MODIFIED
returning
value(EP_MODIFIED) type ABAP_BOOL .
methods GET_COLOR
importing
!IP_INDEX type I
returning
value(EP_COLOR) type ZEXCEL_STYLE_COLOR_ARGB
raising
ZCX_EXCEL .
methods GET_COLORS
returning
value(EP_COLORS) type ZEXCEL_T_STYLE_COLOR_ARGB .
methods SET_COLOR
importing
!IP_INDEX type I
!IP_COLOR type ZEXCEL_STYLE_COLOR_ARGB .</publicSection>
<protectedSection>protected section.
*&quot;* protected components of class ZCL_EXCEL_LEGACY_PALETTE
*&quot;* do not include other source files here!!!</protectedSection>
<privateSection>private section.
*&quot;* private components of class ZCL_EXCEL_LEGACY_PALETTE
*&quot;* do not include other source files here!!!
data MODIFIED type ABAP_BOOL value ABAP_FALSE. &quot;#EC NOTEXT .
data COLORS type ZEXCEL_T_STYLE_COLOR_ARGB .</privateSection>
<localImplementation>*&quot;* use this source file for the definition and implementation of
*&quot;* local helper classes, interface definitions and type
*&quot;* declarations</localImplementation>
<localTypes>*&quot;* use this source file for any type of declarations (class
*&quot;* definitions, interfaces or type declarations) you need for
*&quot;* components in the private section</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<textPool/>
<classDocumentation/>
<typeUsage CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" TYPEGROUP="ABAP" VERSION="1" TPUTYPE="0" EXPLICIT="X" IMPLICIT="X"/>
<forwardDeclaration>ABAP</forwardDeclaration>
<attribute CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="COLORS" VERSION="1" LANGU="E" DESCRIPT="Table of RGB colors" EXPOSURE="0" STATE="1" EDITORDER="2 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000" ATTDECLTYP="0" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_T_STYLE_COLOR_ARGB" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="MODIFIED" VERSION="1" LANGU="E" EXPOSURE="0" STATE="1" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20110702" CHANGEDON="00000000" ATTDECLTYP="0" ATTVALUE="ABAP_FALSE" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ABAP_BOOL" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " R3RELEASE="702" TYPESRC_LENG="0 "/>
<method CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="CONSTRUCTOR" VERSION="1" LANGU="E" DESCRIPT="CONSTRUCTOR" EXPOSURE="2" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000" MTDTYPE="2" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<source>METHOD constructor.
&quot; default Excel palette based on
&quot; http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.indexedcolors.aspx
APPEND &apos;00000000&apos; TO colors.
APPEND &apos;00FFFFFF&apos; TO colors.
APPEND &apos;00FF0000&apos; TO colors.
APPEND &apos;0000FF00&apos; TO colors.
APPEND &apos;000000FF&apos; TO colors.
APPEND &apos;00FFFF00&apos; TO colors.
APPEND &apos;00FF00FF&apos; TO colors.
APPEND &apos;0000FFFF&apos; TO colors.
APPEND &apos;00000000&apos; TO colors.
APPEND &apos;00FFFFFF&apos; TO colors.
APPEND &apos;00FF0000&apos; TO colors.
APPEND &apos;0000FF00&apos; TO colors.
APPEND &apos;000000FF&apos; TO colors.
APPEND &apos;00FFFF00&apos; TO colors.
APPEND &apos;00FF00FF&apos; TO colors.
APPEND &apos;0000FFFF&apos; TO colors.
APPEND &apos;00800000&apos; TO colors.
APPEND &apos;00008000&apos; TO colors.
APPEND &apos;00000080&apos; TO colors.
APPEND &apos;00808000&apos; TO colors.
APPEND &apos;00800080&apos; TO colors.
APPEND &apos;00008080&apos; TO colors.
APPEND &apos;00C0C0C0&apos; TO colors.
APPEND &apos;00808080&apos; TO colors.
APPEND &apos;009999FF&apos; TO colors.
APPEND &apos;00993366&apos; TO colors.
APPEND &apos;00FFFFCC&apos; TO colors.
APPEND &apos;00CCFFFF&apos; TO colors.
APPEND &apos;00660066&apos; TO colors.
APPEND &apos;00FF8080&apos; TO colors.
APPEND &apos;000066CC&apos; TO colors.
APPEND &apos;00CCCCFF&apos; TO colors.
APPEND &apos;00000080&apos; TO colors.
APPEND &apos;00FF00FF&apos; TO colors.
APPEND &apos;00FFFF00&apos; TO colors.
APPEND &apos;0000FFFF&apos; TO colors.
APPEND &apos;00800080&apos; TO colors.
APPEND &apos;00800000&apos; TO colors.
APPEND &apos;00008080&apos; TO colors.
APPEND &apos;000000FF&apos; TO colors.
APPEND &apos;0000CCFF&apos; TO colors.
APPEND &apos;00CCFFFF&apos; TO colors.
APPEND &apos;00CCFFCC&apos; TO colors.
APPEND &apos;00FFFF99&apos; TO colors.
APPEND &apos;0099CCFF&apos; TO colors.
APPEND &apos;00FF99CC&apos; TO colors.
APPEND &apos;00CC99FF&apos; TO colors.
APPEND &apos;00FFCC99&apos; TO colors.
APPEND &apos;003366FF&apos; TO colors.
APPEND &apos;0033CCCC&apos; TO colors.
APPEND &apos;0099CC00&apos; TO colors.
APPEND &apos;00FFCC00&apos; TO colors.
APPEND &apos;00FF9900&apos; TO colors.
APPEND &apos;00FF6600&apos; TO colors.
APPEND &apos;00666699&apos; TO colors.
APPEND &apos;00969696&apos; TO colors.
APPEND &apos;00003366&apos; TO colors.
APPEND &apos;00339966&apos; TO colors.
APPEND &apos;00003300&apos; TO colors.
APPEND &apos;00333300&apos; TO colors.
APPEND &apos;00993300&apos; TO colors.
APPEND &apos;00993366&apos; TO colors.
APPEND &apos;00333399&apos; TO colors.
APPEND &apos;00333333&apos; TO colors.
ENDMETHOD.</source>
<methodDocumentation/>
</method>
<method CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="GET_COLOR" VERSION="1" LANGU="E" DESCRIPT="Get color" EXPOSURE="2" STATE="1" EDITORDER="3 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110702" CHANGEDBY="BCUSER" CHANGEDON="20110703" MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="GET_COLOR" SCONAME="IP_INDEX" VERSION="1" LANGU="E" DESCRIPT="0 - based index" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDBY="BCUSER" CHANGEDON="20110703" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="I"/>
<parameter CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="GET_COLOR" SCONAME="EP_COLOR" VERSION="1" LANGU="E" DESCRIPT="Color ARGB" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_ARGB"/>
<exception CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="GET_COLOR" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000"/>
<source>METHOD get_color.
DATA: lv_index type i.
lv_index = ip_index + 1.
READ TABLE colors INTO ep_color INDEX lv_index.
IF sy-subrc &lt;&gt; 0.
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = &apos;Invalid color index&apos;.
ENDIF.
ENDMETHOD.</source>
<methodDocumentation/>
</method>
<method CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="GET_COLORS" VERSION="1" LANGU="E" DESCRIPT="Get all colors" EXPOSURE="2" STATE="1" EDITORDER="4 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110702" CHANGEDBY="BCUSER" CHANGEDON="20110703" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="GET_COLORS" SCONAME="EP_COLORS" VERSION="1" LANGU="E" DESCRIPT="Table of RGB colors" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ZEXCEL_T_STYLE_COLOR_ARGB"/>
<source>METHOD get_colors.
ep_colors = colors.
ENDMETHOD.</source>
<methodDocumentation/>
</method>
<method CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="IS_MODIFIED" VERSION="1" LANGU="E" DESCRIPT="Is the palette modified from standard?" EXPOSURE="2" STATE="1" EDITORDER="2 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110702" CHANGEDBY="BCUSER" CHANGEDON="20110703" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="IS_MODIFIED" SCONAME="EP_MODIFIED" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000" PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ABAP_BOOL"/>
<source>METHOD is_modified.
ep_modified = modified.
ENDMETHOD.</source>
<methodDocumentation/>
</method>
<method CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="SET_COLOR" VERSION="1" LANGU="E" DESCRIPT="Set (replace) color" EXPOSURE="2" STATE="1" EDITORDER="5 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110702" CHANGEDBY="BCUSER" CHANGEDON="20110703" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="702" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="SET_COLOR" SCONAME="IP_INDEX" VERSION="1" LANGU="E" DESCRIPT="0 - based index" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDBY="BCUSER" CHANGEDON="20110703" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="I"/>
<parameter CLSNAME="ZCL_EXCEL_LEGACY_PALETTE" CMPNAME="SET_COLOR" SCONAME="IP_COLOR" VERSION="1" LANGU="E" DESCRIPT="Color ARGB" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20110703" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_ARGB"/>
<source>METHOD set_color.
DATA: lv_index TYPE i.
FIELD-SYMBOLS: &lt;lv_color&gt; LIKE LINE OF colors.
lv_index = ip_index + 1.
READ TABLE colors ASSIGNING &lt;lv_color&gt; INDEX lv_index.
IF sy-subrc &lt;&gt; 0.
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = &apos;Invalid color index&apos;.
ENDIF.
IF &lt;lv_color&gt; &lt;&gt; ip_color.
modified = abap_true.
&lt;lv_color&gt; = ip_color.
ENDIF.
ENDMETHOD.</source>
<methodDocumentation/>
</method>
</CLAS>

View File

@ -3037,6 +3037,8 @@ endmethod.</source>
lc_xml_node_tablestyles TYPE string VALUE &apos;tableStyles&apos;,
&quot; Colors
lc_xml_node_colors TYPE string VALUE &apos;colors&apos;,
lc_xml_node_indexedcolors TYPE string VALUE &apos;indexedColors&apos;,
lc_xml_node_rgbcolor TYPE string VALUE &apos;rgbColor&apos;,
lc_xml_node_mrucolors TYPE string VALUE &apos;mruColors&apos;,
&quot; Alignment
lc_xml_node_alignment TYPE string VALUE &apos;alignment&apos;,
@ -3125,7 +3127,9 @@ endmethod.</source>
ls_styles_mapping TYPE zexcel_s_styles_mapping,
ls_style_cond_mapping TYPE zexcel_s_styles_cond_mapping,
ls_cellis TYPE zexcel_conditional_cellis,
ls_expression TYPE zexcel_conditional_expression.
ls_expression TYPE zexcel_conditional_expression,
lt_colors TYPE zexcel_t_style_color_argb,
ls_color LIKE LINE OF lt_colors.
DATA: lv_value TYPE string,
lv_dfx_count TYPE i,
@ -3859,6 +3863,27 @@ endmethod.</source>
value = zcl_excel_table=&gt;builtinstyle_pivot_light16 ).
lo_element_root-&gt;append_child( new_child = lo_element ).
&quot;write legacy color palette in case any indexed color was changed
IF excel-&gt;legacy_palette-&gt;is_modified( ) = abap_true.
lo_element = lo_document-&gt;create_simple_element( name = lc_xml_node_colors
parent = lo_document ).
lo_sub_element = lo_document-&gt;create_simple_element( name = lc_xml_node_indexedcolors
parent = lo_document ).
lo_element-&gt;append_child( new_child = lo_sub_element ).
lt_colors = excel-&gt;legacy_palette-&gt;get_colors( ).
LOOP AT lt_colors INTO ls_color.
lo_sub_element_2 = lo_document-&gt;create_simple_element( name = lc_xml_node_rgbcolor
parent = lo_document ).
lv_value = ls_color.
lo_sub_element_2-&gt;set_attribute_ns( name = lc_xml_attr_rgb
value = lv_value ).
lo_sub_element-&gt;append_child( new_child = lo_sub_element_2 ).
ENDLOOP.
lo_element_root-&gt;append_child( new_child = lo_element ).
ENDIF.
**********************************************************************
* STEP 5: Create xstring stream
lo_streamfactory = lo_ixml-&gt;create_stream_factory( ).

View File

@ -32,7 +32,8 @@ DATA: lv_style_bold_guid TYPE zexcel_cell_style,
lv_style_filled_guid TYPE zexcel_cell_style,
lv_style_filled_green_guid TYPE zexcel_cell_style,
lv_style_border_guid TYPE zexcel_cell_style,
lv_style_button_guid TYPE zexcel_cell_style.
lv_style_button_guid TYPE zexcel_cell_style,
lv_style_filled_turquoise_guid TYPE zexcel_cell_style.
DATA: lv_file TYPE xstring,
lv_bytecount TYPE i,
@ -117,6 +118,16 @@ START-OF-SELECTION.
lo_style_filled-&gt;font-&gt;scheme = zcl_excel_style_font=&gt;c_scheme_major.
lv_style_filled_green_guid = lo_style_filled-&gt;get_guid( ).
&quot; Create filled style turquoise using legacy excel ver &lt;= 2003 palette. (https://code.sdn.sap.com/spaces/abap2xlsx/tickets/92)
lo_style_filled = lo_excel-&gt;add_new_style( ).
lo_excel-&gt;legacy_palette-&gt;set_color( &quot;replace built-in color from palette with out custom RGB turquoise
ip_index = 16
ip_color = &apos;0040E0D0&apos; ).
lo_style_filled-&gt;fill-&gt;filltype = zcl_excel_style_fill=&gt;c_fill_solid.
lo_style_filled-&gt;fill-&gt;fgcolor-indexed = 16.
lv_style_filled_turquoise_guid = lo_style_filled-&gt;get_guid( ).
&quot; Get active sheet
lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
lo_worksheet-&gt;set_title( ip_title = &apos;Styles&apos; ).
@ -126,6 +137,7 @@ START-OF-SELECTION.
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 5 ip_value = &apos;Filled text&apos; ip_style = lv_style_filled_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;C&apos; ip_row = 6 ip_value = &apos;Borders&apos; ip_style = lv_style_border_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;D&apos; ip_row = 7 ip_value = &apos;I&apos;&apos;m not a button :)&apos; ip_style = lv_style_button_guid ).
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 9 ip_value = &apos;Modified color for Excel 2003&apos; ip_style = lv_style_filled_turquoise_guid ).
&quot; Fill the cell and apply one style
lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 6 ip_value = &apos;Filled text&apos; ip_style = lv_style_filled_guid ).
&quot; Change the style

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-16"?>
<TTYP TYPENAME="ZEXCEL_T_STYLE_COLOR_ARGB" DDLANGUAGE="E" ROWTYPE="ZEXCEL_STYLE_COLOR_ARGB" ROWKIND="E" DATATYPE="CHAR" LENG="000008" DECIMALS="000000" ACCESSMODE="T" KEYDEF="D" KEYKIND="N" KEYFDCOUNT="0000" AS4USER="BCUSER" AS4DATE="20110703" AS4TIME="000614" DDTEXT="Table of RGB colors" TYPELEN="000008" CTLENG="000000" CTDECIMALS="000000" OCCURS="00000"/>