跳到主要内容

Resize

Resizes the current range by changing the number of rows and columns.

Syntax

expression.Resize(rowSize, columnSize);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
rowSizeRequirednumberThe number of rows for the new range.
columnSizeRequirednumberThe number of columns for the new range.

Returns

ApiRange | null

Example

This example shows how to resize a range to a different number of rows and columns.

// How to resize a range.

// Get a range, resize it and fill the resized range with color.

let worksheet = Api.GetActiveSheet();
let originalRange = worksheet.GetRange("B2:C3");
originalRange.SetValue("Original");
originalRange.SetFillColor(Api.CreateColorFromRGB(173, 216, 230));

let resizedRange = originalRange.Resize(originalRange.Rows.Count + 2, originalRange.Columns.Count + 1);
resizedRange.SetBorders("InsideHorizontal", "Thick", Api.CreateColorFromRGB(255, 111, 61));
resizedRange.SetBorders("InsideVertical", "Thick", Api.CreateColorFromRGB(255, 111, 61));