We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

SetPaletteColor Quirkiness

Thread ID:

Created:

Updated:

Platform:

Replies:

36845 Nov 10,2005 02:05 PM Nov 11,2005 05:56 AM Windows Forms 1
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On November 10, 2005 02:05 PM

I’m trying to use a custom background color in my Excel document and after a ton of digging I think if figured it out. The key is to use IWorkbook.SetPaletteColor() prior to assigning the background color. This makes some sense now actually, Excel must be aware of the custom color. Warning to others, using CellStyle.FillBackgroundRGB without first calling SetPaletteColor() does not work. Excel will round the color to the next closest known color. According to your docs SetPalletColor() takes a Pallete index and a standard .NET Color value. However, there is no explanation that certain index values are invalid. For example the following code throws an exception: SetPaletteColor(7, Color.FromARGB(20,30,40)); But this doesn''t: SetPaletteColor(8, Color.FromARGB(20,30,40)); Even more confusing is the description of the Palette property: Get Palette of colors which an Excel document can have. Here is a table of color indexes to places in the color tool box provided by Excel application: -------------------------------------------- | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ---+---------------------------------------- |1 | 00 | 51 | 50 | 49 | 47 | 10 | 53 | 54 | |2 | 08 | 45 | 11 | 09 | 13 | 04 | 46 | 15 | |3 | 02 | 44 | 42 | 48 | 41 | 40 | 12 | 55 | |4 | 06 | 43 | 05 | 03 | 07 | 32 | 52 | 14 | |5 | 37 | 39 | 35 | 34 | 33 | 36 | 38 | 01 | ---+---------------------------------------- |6 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | |7 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------- Looks like this was made to be seen in the source code file. Can someone please elaborate?

Administrator [Syncfusion]
Replied On November 11, 2005 05:56 AM

Hi, Workbook has a palette of 56 colors that you can apply to cells, fonts, gridlines, graphic objects, and fills and lines in a chart. This Colors in the Palette can be customized. This IWorkbook.SetPaletteColor() method is used for customizing the Palette. Here use the index values from 8 to 63. I here with attach a sample for your reference which gives you some idea about the Color palettes. colorpalette.zip Please take a look and let me know if you have any questions. Thanks for your interest with Syncfusion products. Best Regards, Seetha >I’m trying to use a custom background color in my Excel document and after a ton of digging I think if figured it out. The key is to use IWorkbook.SetPaletteColor() prior to assigning the background color. This makes some sense now actually, Excel must be aware of the custom color. > >Warning to others, using CellStyle.FillBackgroundRGB without first calling SetPaletteColor() does not work. Excel will round the color to the next closest known color. > >According to your docs SetPalletColor() takes a Pallete index and a standard .NET Color value. However, there is no explanation that certain index values are invalid. > >For example the following code throws an exception: >SetPaletteColor(7, Color.FromARGB(20,30,40)); > >But this doesn''t: >SetPaletteColor(8, Color.FromARGB(20,30,40)); > >Even more confusing is the description of the Palette property: > >Get Palette of colors which an Excel document can have. Here is a table of color indexes to places in the color tool box provided by Excel application: -------------------------------------------- | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ---+---------------------------------------- |1 | 00 | 51 | 50 | 49 | 47 | 10 | 53 | 54 | |2 | 08 | 45 | 11 | 09 | 13 | 04 | 46 | 15 | |3 | 02 | 44 | 42 | 48 | 41 | 40 | 12 | 55 | |4 | 06 | 43 | 05 | 03 | 07 | 32 | 52 | 14 | |5 | 37 | 39 | 35 | 34 | 33 | 36 | 38 | 01 | ---+---------------------------------------- |6 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | |7 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------- > >Looks like this was made to be seen in the source code file. Can someone please elaborate? >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;