Returns the closest color to the specified RGB value that the file can support.

 public Color GetClosestColor(int red, int green, int blue)
Public Function GetClosestColor(ByVal red As Integer, ByVal green As Integer, ByVal blue As Integer) As Color

The red component of the desired color. Must be between 0 and 255.

The green component of the desired color. Must be between 0 and 255.

The blue component of the desired color. Must be between 0 and 255.

The closest color in the palette to the specified RGB value

If the given red, green, or blue value is not between 0 and 255.

For .xls files, this will be the color in the palette that has the minimum difference between the specified RGB value and its RGB value. .xlsx files are not limited to colors in the palette, and will return a Color representing the specified RGB values exactly.

Color clr = pal.GetClosestColor(162, 221, 139);
Dim clr As Color = pal.GetCloestColor(162, 221, 139)