mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 07:56:15 +08:00
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:
parent
d40950c96f
commit
65bb19e575
|
@ -26,6 +26,7 @@ public section.
|
|||
TITLE = 'abap2xlsx' .
|
||||
|
||||
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>
|
|||
*"* implementation or private method's signature</localTypes>
|
||||
<localMacros>*"* use this source file for any macro definitions you need
|
||||
*"* 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->zif_excel_book_protection~protected = zif_excel_book_protection=>c_unprotected.
|
||||
|
@ -189,6 +193,7 @@ endmethod.</source>
|
|||
CREATE OBJECT ranges.
|
||||
CREATE OBJECT styles.
|
||||
CREATE OBJECT drawings.
|
||||
CREATE OBJECT legacy_palette.
|
||||
|
||||
me->zif_excel_book_protection~initialize( ).
|
||||
me->zif_excel_book_properties~initialize( ).
|
||||
|
|
187
ZA2X/CLAS/ZCL_EXCEL_LEGACY_PALETTE.slnk
Normal file
187
ZA2X/CLAS/ZCL_EXCEL_LEGACY_PALETTE.slnk
Normal 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.
|
||||
*"* public components of class ZCL_EXCEL_LEGACY_PALETTE
|
||||
*"* 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.
|
||||
*"* protected components of class ZCL_EXCEL_LEGACY_PALETTE
|
||||
*"* do not include other source files here!!!</protectedSection>
|
||||
<privateSection>private section.
|
||||
*"* private components of class ZCL_EXCEL_LEGACY_PALETTE
|
||||
*"* do not include other source files here!!!
|
||||
|
||||
data MODIFIED type ABAP_BOOL value ABAP_FALSE. "#EC NOTEXT .
|
||||
data COLORS type ZEXCEL_T_STYLE_COLOR_ARGB .</privateSection>
|
||||
<localImplementation>*"* use this source file for the definition and implementation of
|
||||
*"* local helper classes, interface definitions and type
|
||||
*"* declarations</localImplementation>
|
||||
<localTypes>*"* use this source file for any type of declarations (class
|
||||
*"* definitions, interfaces or type declarations) you need for
|
||||
*"* components in the private section</localTypes>
|
||||
<localMacros>*"* use this source file for any macro definitions you need
|
||||
*"* 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.
|
||||
" default Excel palette based on
|
||||
" http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.indexedcolors.aspx
|
||||
|
||||
APPEND '00000000' TO colors.
|
||||
APPEND '00FFFFFF' TO colors.
|
||||
APPEND '00FF0000' TO colors.
|
||||
APPEND '0000FF00' TO colors.
|
||||
APPEND '000000FF' TO colors.
|
||||
APPEND '00FFFF00' TO colors.
|
||||
APPEND '00FF00FF' TO colors.
|
||||
APPEND '0000FFFF' TO colors.
|
||||
APPEND '00000000' TO colors.
|
||||
APPEND '00FFFFFF' TO colors.
|
||||
|
||||
APPEND '00FF0000' TO colors.
|
||||
APPEND '0000FF00' TO colors.
|
||||
APPEND '000000FF' TO colors.
|
||||
APPEND '00FFFF00' TO colors.
|
||||
APPEND '00FF00FF' TO colors.
|
||||
APPEND '0000FFFF' TO colors.
|
||||
APPEND '00800000' TO colors.
|
||||
APPEND '00008000' TO colors.
|
||||
APPEND '00000080' TO colors.
|
||||
APPEND '00808000' TO colors.
|
||||
|
||||
APPEND '00800080' TO colors.
|
||||
APPEND '00008080' TO colors.
|
||||
APPEND '00C0C0C0' TO colors.
|
||||
APPEND '00808080' TO colors.
|
||||
APPEND '009999FF' TO colors.
|
||||
APPEND '00993366' TO colors.
|
||||
APPEND '00FFFFCC' TO colors.
|
||||
APPEND '00CCFFFF' TO colors.
|
||||
APPEND '00660066' TO colors.
|
||||
APPEND '00FF8080' TO colors.
|
||||
|
||||
APPEND '000066CC' TO colors.
|
||||
APPEND '00CCCCFF' TO colors.
|
||||
APPEND '00000080' TO colors.
|
||||
APPEND '00FF00FF' TO colors.
|
||||
APPEND '00FFFF00' TO colors.
|
||||
APPEND '0000FFFF' TO colors.
|
||||
APPEND '00800080' TO colors.
|
||||
APPEND '00800000' TO colors.
|
||||
APPEND '00008080' TO colors.
|
||||
APPEND '000000FF' TO colors.
|
||||
|
||||
APPEND '0000CCFF' TO colors.
|
||||
APPEND '00CCFFFF' TO colors.
|
||||
APPEND '00CCFFCC' TO colors.
|
||||
APPEND '00FFFF99' TO colors.
|
||||
APPEND '0099CCFF' TO colors.
|
||||
APPEND '00FF99CC' TO colors.
|
||||
APPEND '00CC99FF' TO colors.
|
||||
APPEND '00FFCC99' TO colors.
|
||||
APPEND '003366FF' TO colors.
|
||||
APPEND '0033CCCC' TO colors.
|
||||
|
||||
APPEND '0099CC00' TO colors.
|
||||
APPEND '00FFCC00' TO colors.
|
||||
APPEND '00FF9900' TO colors.
|
||||
APPEND '00FF6600' TO colors.
|
||||
APPEND '00666699' TO colors.
|
||||
APPEND '00969696' TO colors.
|
||||
APPEND '00003366' TO colors.
|
||||
APPEND '00339966' TO colors.
|
||||
APPEND '00003300' TO colors.
|
||||
APPEND '00333300' TO colors.
|
||||
|
||||
APPEND '00993300' TO colors.
|
||||
APPEND '00993366' TO colors.
|
||||
APPEND '00333399' TO colors.
|
||||
APPEND '00333333' 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 <> 0.
|
||||
RAISE EXCEPTION TYPE zcx_excel
|
||||
EXPORTING
|
||||
error = 'Invalid color index'.
|
||||
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: <lv_color> LIKE LINE OF colors.
|
||||
|
||||
lv_index = ip_index + 1.
|
||||
READ TABLE colors ASSIGNING <lv_color> INDEX lv_index.
|
||||
IF sy-subrc <> 0.
|
||||
RAISE EXCEPTION TYPE zcx_excel
|
||||
EXPORTING
|
||||
error = 'Invalid color index'.
|
||||
ENDIF.
|
||||
|
||||
IF <lv_color> <> ip_color.
|
||||
modified = abap_true.
|
||||
<lv_color> = ip_color.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.</source>
|
||||
<methodDocumentation/>
|
||||
</method>
|
||||
</CLAS>
|
|
@ -3037,6 +3037,8 @@ endmethod.</source>
|
|||
lc_xml_node_tablestyles TYPE string VALUE 'tableStyles',
|
||||
" Colors
|
||||
lc_xml_node_colors TYPE string VALUE 'colors',
|
||||
lc_xml_node_indexedcolors TYPE string VALUE 'indexedColors',
|
||||
lc_xml_node_rgbcolor TYPE string VALUE 'rgbColor',
|
||||
lc_xml_node_mrucolors TYPE string VALUE 'mruColors',
|
||||
" Alignment
|
||||
lc_xml_node_alignment TYPE string VALUE 'alignment',
|
||||
|
@ -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=>builtinstyle_pivot_light16 ).
|
||||
lo_element_root->append_child( new_child = lo_element ).
|
||||
|
||||
"write legacy color palette in case any indexed color was changed
|
||||
IF excel->legacy_palette->is_modified( ) = abap_true.
|
||||
lo_element = lo_document->create_simple_element( name = lc_xml_node_colors
|
||||
parent = lo_document ).
|
||||
lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_indexedcolors
|
||||
parent = lo_document ).
|
||||
lo_element->append_child( new_child = lo_sub_element ).
|
||||
|
||||
lt_colors = excel->legacy_palette->get_colors( ).
|
||||
LOOP AT lt_colors INTO ls_color.
|
||||
lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_rgbcolor
|
||||
parent = lo_document ).
|
||||
lv_value = ls_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 ).
|
||||
ENDLOOP.
|
||||
|
||||
lo_element_root->append_child( new_child = lo_element ).
|
||||
ENDIF.
|
||||
|
||||
**********************************************************************
|
||||
* STEP 5: Create xstring stream
|
||||
lo_streamfactory = lo_ixml->create_stream_factory( ).
|
||||
|
|
|
@ -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->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_filled_green_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Create filled style turquoise using legacy excel ver <= 2003 palette. (https://code.sdn.sap.com/spaces/abap2xlsx/tickets/92)
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_excel->legacy_palette->set_color( "replace built-in color from palette with out custom RGB turquoise
|
||||
ip_index = 16
|
||||
ip_color = '0040E0D0' ).
|
||||
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-indexed = 16.
|
||||
lv_style_filled_turquoise_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Styles' ).
|
||||
|
@ -126,6 +137,7 @@ START-OF-SELECTION.
|
|||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Modified color for Excel 2003' ip_style = lv_style_filled_turquoise_guid ).
|
||||
" Fill the cell and apply one style
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
" Change the style
|
||||
|
|
2
ZA2X/TTYP/ZEXCEL_T_STYLE_COLOR_ARGB.slnk
Normal file
2
ZA2X/TTYP/ZEXCEL_T_STYLE_COLOR_ARGB.slnk
Normal 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"/>
|
Loading…
Reference in New Issue
Block a user