Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

Regards,

Nagaraju Adhikari

5 REPLIES 5

NTeunckens
Active Contributor
0 Kudos

Hello

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

Former Member
0 Kudos

Dear Nic,

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

Thanks & Regards,

Nagaraju Adhikari

0 Kudos

Hello

I didn't see your reaction because you posted it as a new "Reply" rather than a "Comment" ...

But all the same :

  • Check if the sample application works for you in this Wiki or this Wiki ... these should work so please check if you have some missing code in your application ...
  • Another Blogpost with Sample-code : link


Kind regards

Nic T.

0 Kudos

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

Sandra_Rossi
Active Contributor
0 Kudos

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.