Free Support Forum - aspose.com

Why doesn't GetMatchingColor get the color I just added to the palette

I can add a custom color to my workbooks palette through workbook.ChangePalette(customColor, 6). Then calling IsColorInPalette(customColor) yields true, but GetMatchingColor(customColor) returns a different color than customColor. Why is this?


This message was posted using Page2Forum from
Workbook.GetMatchingColor Method - Aspose.Cells for .NET

Hi,

Well, I have tested your scenario and it works fine. The GetMatchingColor() actually returns the custom color which was added to the standard color palette.

I tried the attached the latest version/fix (please try it) with the following sample code:

Sample code:

Workbook workbook = new Workbook();
//Define a custom color.
Color color1;
color1 = Color.FromArgb(59, 114, 167);

//Add to excel color palette.
workbook.ChangePalette(color1, 55);

bool chkcolor = workbook.IsColorInPalette(color1);
MessageBox.Show(chkcolor.ToString()); //true

//Get the matching color with respect to custom color.
Color mcolor = workbook.GetMatchingColor(color1);
//Check the matching color’s rgb values.
MessageBox.Show(mcolor.R.ToString()); //59 - OK
MessageBox.Show(mcolor.G.ToString()); //114 - OK
MessageBox.Show(mcolor.B.ToString()); //167 - OK


If you still find the issue, kindly post your sample code (with template file if you have) here to reproduce the issue, we will check it soon.

Thank you.