Skip to main content

GetRange

Returns an object that represents the selected range of the current sheet.

Can be a single cell - A1, or cells from a single row - A1:E1, or cells from a single column - A1:A10, or cells from several rows and columns - A1:E10.

Syntax​

expression.GetRange(Range1, Range2);

expression - A variable that represents an ApiWorksheet class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
Range1Requiredstring | ApiRangeThe range of cells from the current sheet.
Range2Requiredstring | ApiRangeThe range of cells from the current sheet.

Returns​

ApiRange | null

Example​

Select cells by typing their address in a spreadsheet.

// Find and modify a specific block of cells using its coordinates in a spreadsheet?

// Reference any rectangular group to style all cells at once in a spreadsheet.

let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A2").SetValue("2");
let range = worksheet.GetRange("A1:D5");
range.SetAlignHorizontal("center");