Click or drag to resize

Workbook GetMatchingColor Method (Int32, Int32, Int32)

Find best matching Color in workbook palette.
Examples
The following code illustrates how to get the indexed color from ExcelColors for the given color from Color structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get color</para><para>ExcelColors color = workbook.GetMatchingColor(255, 0, 0);</para><para>//Set color</para><para>worksheet["B2"].Style.KnownColor = color;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>

Namespace: Spire.Xls
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
public ExcelColors GetMatchingColor(
	int r,
	int g,
	int b
)

Parameters

r
Type: System Int32
Red color.
g
Type: System Int32
Green color.
b
Type: System Int32
Blue color.

Return Value

Type: ExcelColors
Workbook palette color.
See Also