CellRange

CellRange holds cell coordinates as CellCoords instances. This object represent unit of the selection layer which
can contains multiple contiquous cells or single cell.

Members

Usually the same as highlight, but in Excel there is distinction - one can change highlight within a selection.

highlightCellCoords

Used to draw bold border around a cell where selection was started and to edit the cell when you press Enter.

End selection.

Methods

expand(cellCoords){Boolean}

Adds a cell to a range (only if exceeds corners of the range). Returns information if range was expanded.

Parameters:
Name Type Description
cellCoords CellCoords
Returns: {Boolean}

expandByRange(expandingRange){Boolean}

Expand the current object by the range passed in the first argument.

Parameters:
Name Type Description
expandingRange CellRange

Object extending the range.

Returns: {Boolean}

flipDirectionHorizontally()

Flip the direction horizontally. (e.g. NW-SE changes to NE-SW).

flipDirectionVertically()

Flip the direction vertically. (e.g. NW-SE changes to SW-NE).

forAll(callback)

Runs a callback function against all cells in the range. You can break the iteration by returning
false in the callback function

Parameters:
Name Type Description
callback function

getAll(){Array}

Get all selected cell coords defined by this range

Returns: {Array}

getBordersSharedWith(range){Array}

Parameters:
Name Type Description
range CellRange
Returns: {Array}

getBottomLeftCorner(){CellCoords}

Gets the bottom left corner of this range.

Returns: {CellCoords}

getBottomRightCorner(){CellCoords}

Gets the bottom right corner of this range.

Returns: {CellCoords}

getDirection(){String}

Gets the direction of the selection.

Returns: {String} Returns one of the values: 'NW-SE', 'NE-SW', 'SE-NW', 'SW-NE'.

getHeight(){Number}

Returns selected range height (in number of rows).

Returns: {Number}

getHorizontalDirection(){String}

Gets the horizontal direction of the range.

Returns: {String} Returns one of the values: W-E (west->east), E-W (east->west).

getInner(){Array}

Get inner selected cell coords defined by this range

Returns: {Array}

getOppositeCorner(coords, expandedRange){CellCoords}

Gets coordinates of the corner which is opposite to the matched. When the passed coordinates matched to the
bottom-right corner of this range then the coordinates for top-left will be returned.

Parameters:
Name Type Description
coords CellCoords

Cell coordinates to check.

expandedRange CellRange optional
Returns: {CellCoords}

getTopLeftCorner(){CellCoords}

Gets the top left corner of this range.

Returns: {CellCoords}

getTopRightCorner(){CellCoords}

Gets the top right corner of this range.

Returns: {CellCoords}

getVerticalDirection(){String}

Gets the vertical direction of the range.

Returns: {String} Returns one of the values: N-S (north->south), S-N (south->north).

getWidth(){Number}

Returns selected range width (in number of columns).

Returns: {Number}

includes(cellCoords){Boolean}

Checks if given cell coordinates are within from and to cell coordinates of this range.

Parameters:
Name Type Description
cellCoords CellCoords

The cell coordinates to check.

Returns: {Boolean}

includesRange(cellRange){Boolean}

Checks if given range is within of this range.

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

isCorner(coords, expandedRange){Boolean}

Checks if coordinates match to one of the 4th corners of this range.

Parameters:
Name Type Description
coords CellCoords

Cell coordinates to check.

expandedRange CellRange optional
Returns: {Boolean}

isEqual(cellRange){Boolean}

Checks if given range is equal to this range.

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

isNorthWestOf(cellRange){Boolean}

Checks if tested coordinates are positioned in north-west from this cell range.

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

isOverlappingHorizontally(cellRange){Boolean}

Returns true if the provided range is overlapping the current range horizontally (e.g. the current range's last
column is 5 and the provided range's first column is 3).

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

isOverlappingVertically(cellRange){Boolean}

Returns true if the provided range is overlapping the current range vertically (e.g. the current range's last
row is 5 and the provided range's first row is 3).

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

isSingle(){Boolean}

Checks if this cell range is restricted to one cell

Returns: {Boolean}

isSouthEastOf(cellRange){Boolean}

Checks if tested coordinates are positioned in south-east from this cell range.

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

isValid(wot){Boolean}

Checks if given coordinates are valid in context of a given Walkontable instance.

Parameters:
Name Type Description
wot Walkontable

The Walkontable instance.

Returns: {Boolean}

overlaps(cellRange){Boolean}

Checks if tested range overlaps with the range. Range A is considered to to be overlapping with range B
if intersection of A and B or B and A is not empty.

Parameters:
Name Type Description
cellRange CellRange

The cells range to check.

Returns: {Boolean}

setDirection(direction)

Sets the direction of the selection.

Parameters:
Name Type Description
direction String

One of the values: 'NW-SE', 'NE-SW', 'SE-NW', 'SW-NE'.

setFrom(coords)

Set the new coordinates where selection starts from.

Parameters:
Name Type Description
coords CellCoords

Coordinates to use.

setHighlight(coords)

Set the new coordinates for highlighting selection.

Parameters:
Name Type Description
coords CellCoords

Coordinates to use.

setTo(coords)

Set new coordinates where selection ends from.

Parameters:
Name Type Description
coords CellCoords

Coordinates to use.

toObject(){Object}

Convert CellRange to literal object.

Returns: {Object} Returns a literal object with from and to properties which each of that object
contains row and col keys.
Class: CellRange