Skip to main content

GetColor

Returns the shading color.

Syntax​

expression.GetColor();

expression - A variable that represents an ApiShd class.

Parameters​

This method doesn't have any parameters.

Returns​

ApiColor | null | undefined

Example​

Retrieve the color of a shading object in a spreadsheet.

// Read back the color stored in a shading object in a spreadsheet.

// Shade the text of a shape and write the shading color into it.

const worksheet = Api.GetActiveSheet();
const fill = Api.CreateSolidFill(Api.Color('#F2F2F2'));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = worksheet.AddShape('rect', 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);

const shd = Api.CreateShd('clear', Api.Color('#FCE4D6'));
const paragraph = shape.GetContent().GetElement(0);
const run = Api.CreateRun();
run.SetFontSize(30);
run.SetFill(Api.CreateSolidFill(Api.Color('#000000')));
run.SetShd(shd);
run.AddText('Shading color = ' + shd.GetColor().GetHex());
paragraph.AddElement(run);