Click or drag to resize

Workbook GetMatchingColor Method (Color)

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(System.Drawing.Color.Red);</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(
	Color color
)

Parameters

color
Type: System.Drawing Color
Color to search for.

Return Value

Type: ExcelColors
Workbook palette color.
See Also