跳到主要内容

CreateColorByName

Creates a color selecting it from one of the available color presets.

Syntax

expression.CreateColorByName(sPresetColor);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sPresetColorRequiredPresetColorA preset selected from the list of the available color preset names.

Returns

ApiColor

Example

This example creates a color selecting it from one of the available color presets.

var oWorksheet = Api.GetActiveSheet();
var oColor = Api.CreateColorByName("peachPuff");
oWorksheet.GetRange("A2").SetValue("Text with color");
oWorksheet.GetRange("A2").SetFontColor(oColor);