Skip to Content
avatar image
Former Member

How to Set Tab Color for Excel Work Sheet by using XML Code in ABAP ?

Dear Experts,

I have Created Multiple Sheets Colored Excel by Using XML Code in ABAP. Now the requirement is Each Excel Work Sheet Tab Should have a Color.

I have used the below Code in the program ( Mentioned in BOLD Letters) for Tab Color and its not working.

r_worksheet = l_document->create_simple_element( name = 'Worksheet' parent = l_element_root ).
r_worksheet->set_attribute_ns( name = 'Name' prefix = 'ss' value = lv_value ).

r_worksheet->set_attribute_ns( name = 'TabColor.Rgb' prefix = 'ss' value = 'Red' ).

Please tell me how to apply colors for Excel Tabs Using XML Code in ABAP.


Nagaraju Adhikari

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Mar 02, 2017 at 07:55 AM


    Please use some of this sample to test if it works for you :

      "Create style-tableheader
      lr_ixml_style = lr_ixml_document->create_simple_element( name = 'Style' parent = lr_ixml_styles  ).
      lr_ixml_style->set_attribute_ns( name = 'ID' prefix = 'ss' value = 'Header' ).
      lr_ixml_format->set_attribute_ns( name = 'Color' prefix = 'ss' value = '#00CCFF' ).

    Some references I used in the past :

    • XML Spreadsheet Reference : link
    • SAP-Wiki Excel Download : link
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 02, 2017 at 08:57 AM

    Dear Nic,

    Thank you for your response. I have tried with given sample code but still its not working.

    Thanks & Regards,

    Nagaraju Adhikari

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Dear Nic,

      I have seen the the references given by you and I tried by setting multiple Properties to Worksheet to get the Tab Color.

      Following Options I have tried:

      ‘TabColor.Rgb’ Property is used to Coloring in Open XML, Same I haveused in XML Coiding in ABAP which is not working ( Check Point no:1 ).

      1. r_worksheet->set_attribute_ns( name = ‘TabColor.Rgb’ prefix = ‘ss’ Value = ‘Red’ ).

      TabColor Property is used to coloring the Excel Worksheet Tab. ( Check Point no:2 ).

      2. r_worksheet->set_attribute_ns( name = ‘TabColor’ prefix = ‘ss’ Value = ‘Red’ ).

      ‘Color’ Property, Which is Used for Coloring Excel Cell . ( Check Point no:3 ).

      3. r_worksheet->set_attribute_ns( name = ‘Color’ prefix = ‘ss’ Value = ‘Red’ ).

      I have recorded a Macro in Excel for tab coloring and I found ThemeColor Property used the same in abap XML Coding (Check point no:4 )

      4. r_worksheet->set_attribute_ns( name = ‘ThemeColor’ prefix = ‘ss’ Value = ‘Red’ ).

      But I am not getting the below expected output.

      If you have any solutions/Other options, Please suggest.

      Thanks & Regards,

      Nagaraju Adhikari

      lbf9d.png (8.5 kB)
  • Mar 06, 2017 at 05:52 AM

    My generic answer : if you want to do something on a XMLSS file, just open it in Excel, do the operation, save it, then compare the XMLSS before and after, and apply the differences in your ABAP program.

    Add comment
    10|10000 characters needed characters exceeded