Click or drag to resize

IWorkbook GetNearestColor Method (Int32, Int32, Int32)

Gets the nearest color to the specified by red, green, and blue values color from 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.Core
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
ExcelColors GetNearestColor(
	int r,
	int g,
	int b
)

Parameters

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

Return Value

Type: ExcelColors
Color index from workbook palette.
See Also