Skip to main content

CreateColorFromRGB

Creates an RGB color setting the appropriate values for the red, green and blue color components.

Syntax

expression.CreateColorFromRGB(r, g, b);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
rRequiredbyteRed color component value.
gRequiredbyteGreen color component value.
bRequiredbyteBlue color component value.

Returns

ApiColor

Example

Define a custom color from red, green, and blue values to apply to elements in a spreadsheet.

// How do I build a specific color using red, green, and blue numbers in a spreadsheet?

// Color text or shapes with a precise tone by mixing three numeric channel values in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let color = Api.CreateColorFromRGB(255, 111, 61);
worksheet.GetRange("A2").SetValue("Text with color");
worksheet.GetRange("A2").SetFontColor(color);