Excel 2003 SpreadsheetML Color Attribute Question

Shutty

New Member
Joined
Jun 4, 2004
Messages
3
I have an application that generates a SpreadsheetML file. It contains style elements that specify the background colors of cells.

e.g.
Code:
<Style ss:ID="s21">
   <Alignment ss:Vertical="Center"/>
   <Borders/>
   <Font/>
   <Interior ss:Color="#8080C0" ss:Pattern="Solid"/>
   <NumberFormat/>
   <Protection/>
  </Style>

the hex triplet color above translates to an RGB of 128, 128, 192; a rather nice purple colour (as can be viewed in PaintBrush). However when the cell is rendered in Excel the background colour is a dull dark gray! (#808080).

Are there any known issues/workarounds regarding the excel color palette?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Shutty,

From my experience of using the Excel colour palette, it will only let you use up to 56 different RGBs, which it stores as ColorIndexs. You could possibly try storing this RGB as ColorIndex 30 say by:

ActiveWorkbook.Colors(30) = RGB(128,128,192)

Then set the ColorIndex property as opposed to the Color to 30. I suspect that Excel is not letting you set the Color to this value as it is not in its 'set' of Colors.

Alex
 
Upvote 0
Thanks for your reply alex, after alot more investigation i found this to be the case. I found this article quite useful http://www.mvps.org/dmcritchie/excel/colors.htm#dpalette.

I tend to generate my SpreadsheetML from scratch as it executes faster than generating an Excel object first. the actual SpreadsheetML required to change the excel colour palette is..
Code:
  <Colors>
   <Color>
    <Index>21</Index>
    <RGB>#FF8040</RGB>
   </Color>
    <Color>
    <Index>23</Index>
    <RGB>#FFFF40</RGB>
   </Color>
   ...etc...
  </Colors>

Why Excel limits itself to 56 colours and does not use the rich windows colour palette I do not know! :banghead:
 
Upvote 0
Excellent, I'm glad you sorted that out Shutty.
Thanks for posting the SpreadsheetML stuff, its not something I know a huge amount about (as you may have gathered by my posting), but something that is certainly of interest to me.

Alex
 
Upvote 0

Forum statistics

Threads
1,223,590
Messages
6,173,233
Members
452,505
Latest member
Neeraj1990

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top