Skip to Content
0

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

Mar 02, 2017 at 04:09 AM

186

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Nic Teunckens Mar 02, 2017 at 07:55 AM
0

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
Share
10 |10000 characters needed characters left characters exceeded
NAGARAJU ADHIKARI Mar 02, 2017 at 08:57 AM
0

Dear Nic,

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

Thanks & Regards,

Nagaraju Adhikari

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

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)
0
Sandra Rossi Mar 06, 2017 at 05:52 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded