We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Color Pallete and CellsColor

Hi,

I want to add custom color to pallete and assign it to range object. Here is what i'm doing.


Workbook.ChangePalette(Color.FromArgb(102, 136, 164), 53);

//need to use color by index
CellsColor csc = ReportWorkbook.CreateCellsColor();
csc.ColorIndex = 53;

style.ForegroundColor = csc.Color;
style.Pattern = BackgroundType.Solid;

StyleFlag sfg = new StyleFlag();
sfg.All = true;

range.ApplyStyle(style, sfg);

When i assign color with index as 53, it still gives me diff color (RGB 255 102 0). Can you please advise what is wrong here?
Please note, i've req to assign by color by index, so i'm using CellsColor object here. Thanks


This message was posted using Aspose.Live 2 Forum

Hi,

We found the issue after an initial test and get back to you soon. Your issue is logged into our issue tracking system with an id: CELLSNET-17622.

By the way, you may change your code a bit

Workbook.ChangePalette(Color.FromArgb(102, 136, 164), 53);


//need to use color by index
CellsColor csc =
ReportWorkbook.CreateCellsColor();
csc.Color = Color.FromArgb(102, 136, 164);

style.ForegroundColor
= csc.Color;
style.Pattern = BackgroundType.Solid;

StyleFlag
sfg = new StyleFlag();
sfg.All = true;

range.ApplyStyle(style,
sfg);



Thank you.



Hi,

Please try the attached version. We have fixed your
issue.

Following is my test code that works fine now.

wb.Worksheets.Clear();
Worksheet ws = wb.Worksheets.Add(“New”);

wb.ChangePalette(Color.FromArgb(102, 136, 164), 53);

ws.Cells[“A8”].PutValue(34);
ws.Cells[“A9”].PutValue(50);
ws.Cells[“A10”].PutValue(34);

CellsColor csc = wb.CreateCellsColor();
csc.ColorIndex = 53;

Range range = ws.Cells.CreateRange(“A8:A10”);
Style style = wb.Styles[wb.Styles.Add()];
style.ForegroundColor = csc.Color;
style.Pattern = BackgroundType.Solid;

StyleFlag sfg = new StyleFlag();
sfg.All = true;

range.ApplyStyle(style, sfg);
wb.Save(@“e:\test\ResultantBook.xls”);


Thank you.