Skip to main content

CreatePatternFill

Creates a pattern fill to apply to the object using the selected pattern as the object background.

Syntax​

expression.CreatePatternFill(patternType, bgColor, fgColor);

expression - A variable that represents an Api class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
patternTypeRequiredPatternTypeThe pattern type used for the fill selected from one of the available pattern types.
bgColorRequiredApiColorThe background color used for the pattern creation.
fgColorRequiredApiColorThe foreground color used for the pattern creation.

Returns​

ApiFill

Example​

Fill a shape's background with a repeating pattern of two colors in a spreadsheet.

// How do I apply a tiled pattern as the background of a shape in a spreadsheet?

// Decorate a shape by covering its surface with a repeated design made from two chosen colors in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let fill = Api.CreatePatternFill("dashDnDiag", Api.RGB(255, 111, 61), Api.RGB(51, 51, 51));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
worksheet.AddShape("flowChartOnlineStorage", 60 * 36000, 35 * 36000, fill, stroke, 0, 2 * 36000, 1, 3 * 36000);