Skip to content
Spreadsheet Engine

Range

A Range specifies an area in cell coordinate space that is enclosed by the Range’s upper-left point (top,left) and its lower-right point (bottom,right), both inclusive.

new Range(src): Range$1;

zero-based coordinates of the bounds of a range, and optionally the “lockedness” of any of those bounds. The bottom and right bounds default to top and left, respectively.

boolean

boolean

boolean

boolean

number

number

number

number

number

Range$1

$bottom: boolean;

$left: boolean;

$right: boolean;

$top: boolean;

bottom: number;

left: number;

right: number;

top: number;

unbounded: Unbounded;

static MAX_COL: number;

static MAX_ROW: number;
get height(): number;

number


get isCollapsed(): boolean;

Returns true if this is 1x1, a single-cell range.

boolean


get size(): number;

number


get width(): number;

number

collapse(toTopLeft?): Range$1;

Returns a new Range collapsed to a single point at to one of the boundary points of this range.

boolean

true collapses the Range to its top/left corner, false to its bottom/right.

Range$1


collapseToBottomRight(): Range$1;

Returns a new Range collapsed to a single point at the bottom-right corner of this range. Does not copy lock attributes ($top etc.).

Range$1


collapseToColumn(c?): Range$1;

Returns a new Range collapsed to the given column of this range (default leftmost column). Does not copy lock attributes ($top etc.). Does not check bounds, so result will be outside this range if c >= width.

number

zero-based index of the column to collapse to.

Range$1


collapseToRow(r?): Range$1;

Returns a new Range collapsed to the given row of this range (default top row) Does not copy lock attributes ($top etc.). Does not check bounds, so result will be outside this range if r >= height.

number

zero-based index of the row to collapse to.

Range$1


collapseToTopLeft(): Range$1;

Returns a new Range collapsed to a single point at the top-left corner of this range. Does not copy lock attributes ($top etc.).

Range$1


contains(rangeOrCoords): boolean;

Checks whether the specified range is fully covered by this range.

SlimRangeOrCoords

the reference range with which to compare.

boolean


equals(range): boolean;

Compares this range to another range to test if their defined rectangles are equal. This only tests the values of top, left, bottom, right; ignoring any locks.

SlimRange | null

the reference range with which to compare.

boolean


except(range): IterableIterator<Range$1>;

Subtract the supplied range from the current one. Yields up to 4 ranges, depending on how the ranges overlap.

SlimRange

IterableIterator<Range$1>


extendSide(side, position): Range$1;

Side

number

Range$1


extendToLength(newLength): Range$1;

Returns a new Range with the same shorter dimension as this one, but the longer dimension set to newLength. (This will make the longer dimension the shorter one, if newLength < the shorter dimension. The intended use case of this is to extend rather than contract, in which case the longer dimension remains longer, so this will need changing if the opposite use case becomes relevant.) Does not copy lock attributes ($top etc.).

number

the length of the longer dimension (width or height) of the new range

Range$1

a range like this one but with its longer dimension changed to newLength.


getIntersection(other): Range$1 | null;

SlimRange

Range$1 | null


hasUnanchoredBound(kind): boolean;

True if any bound the address writes out is unanchored, i.e. written without a $.

AddressKind

which bounds the address writes out (see AddressKind)

boolean

true if a written bound has no $


intersects(range): boolean;

SlimRange

boolean


iterCoordinates(): IterableIterator<{
column: number;
row: number;
}>;

IterableIterator<{ column: number; row: number; }>


moveBy(deltaX, deltaY): Range$1;

number

number

Range$1

a new range that has been shifted by X and Y.


strictEquals(range): boolean;

Compares this range to another range to test if their defined rectangles are equal. This tests both the rectangles as well as the status of locks on the dimensions.

| SlimRange & Pick<Range$1, "$top" | "$left" | "$bottom" | "$right"> | null

the reference range with which to compare.

boolean


toBoundingBox(): object;

object

maxX: number;
maxY: number;
minX: number;
minY: number;

toString(abs?): string;

boolean

string


translateFromOrigin(
originRow,
originCol,
kind
): Range$1;

Return a copy with every unanchored bound shifted by the given zero-based origin, which is how a defined name’s coordinates read: an unanchored one is an offset from A1, resolved against the cell that references the name. A bound shifted past the last row or column wraps around to the first, so that up-and-left from A1 is the bottom-right cell.

number

zero-based row of the cell the coordinates are resolved against

number

zero-based column of that cell

AddressKind

which bounds the address writes out (see AddressKind)

Range$1

the shifted copy, its anchoring flags as on this range


static createColumnRange(left, right?): Range$1;

number

number

defaults to left

Range$1


static createRowRange(top, bottom?): Range$1;

number

number

defaults to top

Range$1


static withinBounds(col, row): boolean;

number

number

boolean