How to set paler grey colors for cells background

How to set style for cells backgstandard greys, . I use Silver, they are too dark, that is not our client like. They need gray as 10%, 15%, 25%. Any idea?

my code

styleIndex = excel.Styles.Add();
style = excel.Styles[styleIndex];
//Setting the LightGray(custom) color to the font
style.ForegroundColor = Color.Silver;
style.Pattern = BackgroundType.Solid;
style.Name = “colorAlterRow”;

StyleFlag styleflag = new StyleFlag();
styleflag.All = true;
cells.Rows[iRow].ApplyStyle(excel.Styles[“colorAlterRow”], styleflag);

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

You need to find out the rgb value of your colors.

You can create your sample xls/xlsx file manually using Ms-Excel with your desired colors and then post it here.

One way is to load your file in a workbook and find the rgb value of your desired colors.

You can also find it out manually.

Please see the screenshot, how to get the RGB value of any color in Ms-Excel 2010.

Screenshot:

Hi,


Instead of using Color.Silver, you can use the:

Color.FromArgb(Red,Blue,Green)

function to achieve this. Using a combination of RGB, you can specify the color of the cell. You can use MS-Paint to achieve the RGB values for this purpose according to your selected color.


Thanks & Best Regards

Thanks, but I am using Excel 2003, the color palette doesn’t exist in excel 2003. so I cannot find that light gray color.

if I set Color.FromArgb(240, 240, 240);

in excel 2003, it is similar with white.
in excel 2010, I can see the light gray.

Hi,

Well, LightGray, LightGreen etc colos are not present on Excel(97-2003) color palette for XLS format, so you need to add the color in the palette first. See the following topic for your reference:

Please note down , if you want to use all the colors without palette, then you should use Xlsx format. For Xls format, you will use the same technique as I have shown above.

Here is the sample code that adds a light green color inside color palette and then changes the tab color.

Sample code:

//Instantiate a new Workbook

Workbook workbook = new Workbook();

//Color the second sheet

Worksheet sheet2 = workbook.Worksheets.Add(“Sheet2”);

Color clr = Color.LightGreen;

//Add light green color to the Excel palette first.

workbook.ChangePalette(clr, 55);

//Set the tab color

sheet2.TabColor = clr;

//Save the excel file

workbook.Save(“e:\test2\mytabcolorxls.xls”);