How can I assign a custom color to a cell in Aspose Cells?

210 Views Asked by At

In the legacy (Excel Interop) code, this can be done to assign a custom color to a cell:

contractCell.Interior.Color = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));

Using Aspose Cells, I'm trying to find the corresponding way to do it. This code:

styleContractRow2.ForegroundColor = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));
styleContractRow2.Pattern = BackgroundType.Solid;

...does not compile, telling me, "Cannot implicitly convert type 'int' to 'System.Drawing.Color'"

So how can I assign a custom color in Aspose Cells?

2

There are 2 best solutions below

0
On BEST ANSWER

Please check the reply and sample code in your Aspose.Cells forum thread.

Note: I am working as Developer Evangelist at Aspose

0
On

It seems as if the translation is unnecessary; this compiles:

styleContractRow2.ForegroundColor = Color.FromArgb(202, 134, 250);