SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface ICellRange

    A ICellRange represents a rectangular collection of ICell within an ISheet.

    Naming Conventions: Methods usually adhere to the following conventions except when adhering to a idiomatic existing conventions of Typescript (for example size or 'length'):

    • Methods returning information about the range (e.g., width, count) use a get prefix.
    • Methods that transform the range's data into a different type use a to prefix (e.g., toArray()).
    interface ICellRange {
        isICellRange: true;
        get size(): number;
        "[iterator]"(): IterableIterator<Scalar>;
        addAutoTable(options?: AddAutoTableOptions): ITable;
        addListener(listener: Listener, options?: ListenerOptions): Remove;
        addTable(options?: boolean | ITableCollection.AddOptions): ITable;
        addWatch(
            formula: string | IFormula,
            callback: ICellRange.WatchCallback,
            options?: WatchOptions,
        ): Remove;
        autoFill(destination: ICellRange.Address, options?: AutoFillOptions): this;
        autoFit(options?: AutoFitOptions): this;
        calculate(full?: boolean): this;
        canInsertFrom(
            source: ICellRange.Address | ICellRange.ISnapshot<any, any>,
            options?: InsertFromOptions,
        ): boolean;
        clear(
            applyTo?: ICell.Content,
            options?: ITransaction.OperationOptions,
        ): this;
        clearGroups(
            axes?: AxisSelection,
            options?: ITransaction.OperationOptions,
        ): this;
        copyFrom(
            source: ICellRange.Address | ICellRange.ISnapshot<any, any>,
            options?: ICellRange.CopyOptions,
        ): Promise<ICellRange | null>;
        createFormula(expression: string, options?: CreateFormulaOptions): IFormula;
        createSparseBuilder(
            options?: ICellRange.SparseBuilderOptions,
        ): ICellRange.SparseBuilder;
        delete(options?: Axis | DeleteOptions): this;
        doBatch<R>(
            callback: (commit: ICommit) => R | Promise<R>,
            options?: string | ITransaction.OperationOptions,
        ): R | Promise<R>;
        entries(
            options?: ICellRange.IteratorOptions<ICellRange.Address>,
        ): IterableIterator<ICellRange.Entry<Scalar>>;
        filter(
            condition: ICondition.RangeOptions | Input<any>,
            options?: ITransaction.OperationOptions,
        ): Promise<ICellRange>;
        find(options: string | FindOptions): Iterator<ICell>;
        forEach<B>(
            callback: ICellRange.ForEachCallback<B>,
            options?: ICellRange.IteratorOptions<ICellRange.Address>,
        ): void | B;
        getAddress(r1c1?: boolean): string;
        getBestFit(options?: BestFitOptions): Size;
        getBottomRight(options?: ICellRange.GetRangeOptions): this;
        getBounds(): Bounds;
        getCell(address?: ICell.Address): ICell;
        getCells(options?: ICellRange.GetValuesOptions): ICell[][];
        getColumnAfter(options?: ICellRange.GetRangeOptions): this;
        getColumnAt(
            columnIndex: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getColumnBefore(options?: ICellRange.GetRangeOptions): this;
        getColumnBy(
            columnDelta: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getColumnCount(): number;
        getColumnEnd(): number;
        getColumnHeaders(
            options?: ICellHeaderRange.GetRangeOptions,
        ): ICellHeaderRange;
        getColumnStart(): number;
        getComments(
            options?: ICellRange.GetItemsOptions<
                ICommentCollection.GetItemsOptions,
            >,
        ): IComment[];
        getConditionalFormats(
            options?: ICellRange.GetItemsOptions<
                IConditionalFormatCollection.GetItemsOptions,
            >,
        ): IConditionalFormat[];
        getCoords(): Readonly<IRange.FixableCoords>;
        getCounts(
            features?: ICellRange.Feature | readonly ICellRange.Feature[],
        ): Counts;
        getDataValidations(
            options?: ICellRange.GetItemsOptions<
                IDataValidationCollection.GetItemsOptions,
            >,
        ): IDataValidation[];
        getDefaultAutoFillCriteria(
            direction?: Direction,
            destination?: ICellRange.Address,
        ): DefaultCriteria | null;
        getDefaultShiftAxis(): Axis;
        getDefaultSortCriteria(
            axis?: Axis,
            cell?: ICell.Address,
        ): DefaultSortCriteria | null;
        getDependents(): Promise<ICellRanges | null>;
        getDifferences(
            address: ICellRange.Address,
            options?: ICellRange.GetRangeOptions,
        ): ICellRanges | null;
        getDirectDependents(): Promise<ICellRanges | null>;
        getDirectPrecedents(): Promise<ICellRanges | null>;
        getEntireColumns(
            shift?: boolean,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getEntireRows(shift?: boolean, options?: ICellRange.GetRangeOptions): this;
        getExtended(
            direction: Direction,
            cell?: ICell.Address | GetExtendedOptions,
        ): this;
        getFixed(options?: boolean | GetFixedOptions): this;
        getFormula(address?: ICell.Address): IFormula;
        getFormulas(): string[][];
        getInteropValue(): InteropScalar;
        getInteropValues(options?: ICellRange.GetValuesOptions): InteropScalar[][];
        getIntersect(
            address?: ICellRange.Address,
            options?: ICellRange.GetRangeOptions,
        ): ICellRange | null;
        getMerges(): Coords[];
        getMovables(
            options?: ICellRange.GetItemsOptions<
                IMovableCollection.GetItemsOptions,
            >,
        ): IMovable[];
        getNumberFormat(): string;
        getNumberFormats(): string[][];
        getOffsetBy(
            rowDelta: number,
            colDelta: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getOffsetTo(
            rowStart: number,
            colStart: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getPrecedents(): Promise<ICellRanges | null>;
        getRangeAt(
            rowStart: number,
            colStart: number,
            rowEnd?: number,
            colEnd?: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getRegions(
            features?: ICellRange.Feature | readonly ICellRange.Feature[],
            options?: GetRegionsOptions,
        ): ICellRegions;
        getResizeBy(
            rowDelta: number,
            colDelta: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getResizeTo(
            rowEnd: number,
            colEnd: number,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getRowAfter(options?: ICellRange.GetRangeOptions): this;
        getRowAt(rowIndex: number, options?: ICellRange.GetRangeOptions): this;
        getRowBefore(options?: ICellRange.GetRangeOptions): this;
        getRowBy(rowDelta: number, options?: ICellRange.GetRangeOptions): this;
        getRowCount(): number;
        getRowEnd(): number;
        getRowHeaders(options?: ICellHeaderRange.GetRangeOptions): ICellHeaderRange;
        getRowStart(): number;
        getSheet(): ISheet;
        getSnapshot(options?: ICellRange.CopyOptions): ICellRange.ISnapshot;
        getStats(options?: GetStatsOptions): IRangeStats;
        getStyle(): IStyle;
        getSurrounding(options?: GetSurroundingOptions): this;
        getTables(
            options?: ICellRange.GetItemsOptions<ITableCollection.GetItemsOptions>,
        ): ITable[];
        getTopLeft(options?: ICellRange.GetRangeOptions): this;
        getUnion(
            address?: ICellRange.Address,
            options?: ICellRange.GetRangeOptions,
        ): this;
        getUnlocked(
            options?: ICellRange.GetItemsOptions<
                IProtectedRangeCollection.GetItemsOptions,
            >,
        ): IProtectedRange[];
        getUsedRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
        getValue(): Scalar;
        getValues(options?: ICellRange.GetValuesOptions): Scalar[][];
        getValuesRange(): IRange;
        getVisible(options?: GetVisibleOptions): ICellRanges | null;
        group(axis?: Axis, options?: ITransaction.OperationOptions): this;
        hideGroupDetails(
            axis?: Axis,
            options?: ITransaction.OperationOptions,
        ): this;
        insert(options?: Axis | InsertOptions): this;
        insertFrom(
            source: ICellRange.Address | ICellRange.ISnapshot<any, any>,
            options?: InsertFromOptions,
        ): Promise<ICellRange | null>;
        isContentful(
            features?: ICellRange.Feature | readonly ICellRange.Feature[],
        ): boolean;
        isEmpty(): boolean;
        isEntireColumns(): boolean;
        isEntireRange(): boolean;
        isEntireRows(): boolean;
        isEqual(
            address: ICellRange.Address,
            options?: ICellRange.GetRangeOptions,
        ): boolean;
        isInvalid(): boolean;
        isReadOnly(): boolean;
        isSingleCell(): boolean;
        merge(options?: AxisSelection | MergeOptions): this;
        removeDuplicates(options?: RemoveDuplicatesOptions): this;
        select(options?: ICellRange.SelectOptions): Promise<ICellRange>;
        setComments(
            comments: IComment.Update,
            options?: ITransaction.OperationOptions,
        ): this;
        setComputedValues(
            callback: (range: IRange) => IRange,
            options?: ITransaction.OperationOptions,
        ): this;
        setFormula(value: ValuesUpdateOrCallback, options?: SetValuesOptions): this;
        setFormulas(
            formulas: readonly string[][],
            options?: SetValuesOptions,
        ): this;
        setHyperlink(
            hyperlink: IHyperlink.Update,
            options?: ITransaction.OperationOptions,
        ): this;
        setNumberFormat(numFmt: string | null, options?: UpdateOptions): this;
        setNumberFormats(
            formats: readonly string[][],
            options?: UpdateCellsOptions,
        ): this;
        setValue(value: ValuesUpdateOrCallback, options?: SetValuesOptions): this;
        setValues(values: ValuesUpdate, options?: SetValuesOptions): this;
        showGroupDetails(
            axis?: Axis,
            options?: ITransaction.OperationOptions,
        ): this;
        sort(
            options?:
                | boolean
                | ISort.Options[]
                | ISort.RangeOptions & ITransaction.OperationOptions,
        ): this;
        sortAt(
            index: number,
            options?: boolean | Criteria & ITransaction.OperationOptions,
        ): this;
        textToColumns(options?: string | TextToColumnsOptions): this;
        toString(): string;
        ungroup(axis?: Axis, options?: ITransaction.OperationOptions): this;
        unmerge(options?: ITransaction.OperationOptions): this;
        updateCells(update: ICellRange.Update, options?: UpdateCellsOptions): this;
        values(
            options?: ICellRange.IteratorOptions<ICellRange.Address>,
        ): IterableIterator<Scalar>;
    }

    Hierarchy (View Summary)

    Index
    isICellRange: true

    For runtime type checking.

    • get size(): number

      Returns the size of the range this is the rows * columns.

      Returns number

    • Returns an iterator that allows you to iterate over the individual values within the range.

      Returns IterableIterator<Scalar>

      For more advanced iteration, use ICellRange.entries or ICellRange.forEach.

    • Evaluates formula across this range and calls callback with the results — then again every time anything the formula reads changes.

      Parameters

      • formula: string | IFormula

        An expression, compiled at this range's top-left, or an already-compiled formula anchored there (see the anchor note below).

      • callback: ICellRange.WatchCallback

        Receives one value per cell of this range, read with local coordinates (getValueAt(0, 0) is this range's top-left).

      • Optionaloptions: WatchOptions

      Returns Remove

      A callback to remove the watch. IListener.Remove

      The difference from createFormula is the lifetime: that one compiles and evaluates once and registers nothing, so its answer silently ages. This one keeps answering.

      Block-shaped, always. A rule's operand is a value per cell, not one value for the range: an absolute reference ($A$1) yields the same value in every cell and a relative one (A1) yields each cell's own — the same code path, which is why per-cell semantics cost nothing here.

      The callback fires on the first evaluation as well as on every change, so a caller never has to evaluate separately and then watch — a sequence with a window in it where a change is lost. An evaluation superseded by a newer one is dropped rather than delivered late, so the callback never goes backwards in time.

      The anchor must be this range's top-left, and a compiled formula anchored elsewhere throws rather than being quietly re-sited. A formula means different things read from different cells (ICalculation.IFormula.shift), so silently moving one would answer a question the caller did not ask. To watch a formula belonging to a multi-area rule, fill it first — or use ICellRanges.addWatch, which does that for every area.

      The formula is held by the calculation engine like a formula in a cell: its references follow row and column inserts and deletes, a reference to deleted cells reads #REF!, and undo restores it. A range the formula discovers at evaluation time (INDIRECT, OFFSET) is watched too. A volatile formula (NOW, RAND) re-evaluates with the engine's pass and does not re-fire on its own.

      With ICellRange.WatchOptions.arrayFirstCell each cell is evaluated the way a conditional-format or data-validation rule evaluates its formula: as an array-entered formula whose extent is that one cell.

    • Fill the range to a destination using an array of IAutoFill.Filler.

      Parameters

      Returns this

      ICellRange for the destination.

      Error If the destination range does not share 3 edges with the range.

      • The destination must share 3 edges with the range and move exactly one edge.
      • An edge moved outward extends the fill; an edge moved inward shrinks it — the vacated cells are cleared (mirrors dragging Excel's fill handle back over the source).
      • A destination equal to the range is a no-op.
      • If the range contains merges then the fill amount must be a multiple of the merge unit on the fill axis, otherwise this throws — pass AutoFillOptions.snap to fill the nearest amount that qualifies instead.
      • With AutoFillOptions.preview nothing is committed and the returned range projects the result instead: its cells are computed, not read from the sheet, so ICell.getValue / ICell.getText report what would be filled. A projected cell also carries the merge the fill would create, so ICell.getRange, ICell.getSpans and ICell.getExtrusions describe the block rather than a single cell — and asking for any coord inside that block returns the block's anchor cell, where the value lives. Cells the fill does not touch (the range itself) read straight from the sheet.
      // What would land in the last cell, and how big will that cell be?
      const preview = sheet.getRange('A1:B4').autoFill('A1:B8', { preview: true });
      const last = preview.getCell({ rowIndex: 7, colIndex: 1 });
      last.getText(); // the value the fill would write
      last.getExtrusions(); // the merged block it would occupy (null if not merged)
    • Adjusts the column widths and rows heights to fit the content.

      Parameters

      Returns this

      The current ICellRange.

    • Re-evaluates and formulas within the range.

      Parameters

      • Optionalfull: boolean

        If true then all formulas will be recalculated.

      Returns this

    • Whether insertFrom would go through, asked without performing it.

      Parameters

      • source: ICellRange.Address | ICellRange.ISnapshot<any, any>

        The source that would be inserted - the same argument insertFrom takes.

      • Optionaloptions: InsertFromOptions

        The same options insertFrom would be given; axis and isCut both change the answer, so pass the ones the real call will use.

      Returns boolean

      false when insertFrom would refuse, true otherwise.

      A drop can be refused for reasons the caller cannot see: a cut whose gap the insert would only half close, a merge the shift would tear or land inside of, a table it would split. This answers the same question insertFrom asks itself before it commits, which is what lets an interactive drag show a drop as refused BEFORE the user commits to it, rather than reporting an error after.

      It reports only what can be known up front. A refusal raised deeper in the operation (protection, or content pushed off the end of the sheet) still surfaces as a thrown error.

    • Removes the outline levels from the rows and columns of the range. Hidden rows and columns stay hidden.

      Parameters

      Returns this

      The current ICellRange.

      The counterpart of Excel's Range.ClearOutline: both axes over the range's rows and columns, so entire rows also clear every column's levels unless axes names the rows, and a single cell clears the whole sheet. To outline a sheet from its formulas see IOutline.autoOutline.

    • Parses a formula expression and returns a transient formula object anchored at this range's top-left cell.

      Parameters

      • expression: string

        The formula expression to parse.

      • Optionaloptions: CreateFormulaOptions

        Optional parse options; the expression is storage text unless target is 'display'.

      Returns IFormula

      The anchored convenience form: equivalent to getSheet().createFormula(expression, topLeftCoords), where the anchor is this range's top-left cell. Nothing is committed — the formula is not registered in the workbook or the dependency graph.

      Two behaviors follow from the sheet form (see ISheet.createFormula):

      • A bare reference (A2) resolves against THIS range's sheet, never the selected one.
      • Relative references resolve relative to the anchor cell, so the expression reads exactly as it would if it were authored here.
    • Creates a SparseBuilder for efficiently updating sparsely populated cells in a streaming low memory way.

      For contiguous or mostly contiguous updates, the ICellRange.updateCells method is simpler and will use ICellRange.SparseBuilder internally.

      Parameters

      Returns ICellRange.SparseBuilder

      • Ordering: By default updates must be added in either row-major or column-major order, as specified by the axis parameter, with major/minor coordinates increasing monotonically. Unless allowUnorderedWrites is set to `true out of order updates will result in an error.

      • Performance: Setting axis to IRange.Axis.Column is generally faster as it aligns with the internal data representation.

      • Performance: Setting allowUnorderedWrites adds a nominal performance overhead for all updates and will do a full apply when an out of order update is detected. The default IRange.Axis.Row is provided for compatibility with common spreadsheet APIs.

      • Validation: Data validation (e.g., for protected cells or boundaries) is performed when the apply method is called.

      • Transactions:

        • Adding values to the SparseBuilder only builds a temporary representation of the updates. No actual changes are made to the sheet until apply is called.
        • This allows for safe batching of updates within a single transaction using doBatch.
      const builder = range.createSparseBuilder()
      .push('A1', 2)
      .push('A2', 567)
      .push('A3', 3)
      .push('A4', 123)
      .push('A5', 1)
      .apply();
      });
    • Delete the cells within the range and shifts the remaining cells to fill the gap.

      Parameters

      Returns this

      The current ICellRange.

      This is different from clearing cells, which removes their content but doesn't affect the overall sheet structure. Deleting cells results in a shift of the remaining data.

    • Perform a set of operations as a batch.

      Type Parameters

      • R

        The callback return type.

      Parameters

      • callback: (commit: ICommit) => R | Promise<R>

        Function to perform the operations.

      • Optionaloptions: string | ITransaction.OperationOptions

        Description of the operation or additional options. This will be used for tracking undo/redo and history.

      Returns R | Promise<R>

      The result of the callback.

      'Range Update'
      
    • Hide the rows that do not meet the condition.

      Parameters

      Returns Promise<ICellRange>

      Apply filter to multiple spans in either axis.

      Example – hide rows where column C is >= 3:

      sheet.getRange('A2:E100').filter({
      axis: IRange.Axis.Row, // default but could be column
      conditions: [
      {
      operator: ICondition.BuiltInOperatorNames.GreaterThanEqualTo,
      param: 3,
      // 0-based index of column C within the range (relative to the range, not the sheet)
      index: 2,
      },
      ],
      });

      @see
      {@link IFilter.IFilterable
    • Iterates over the cells within the range, applying the provided callback function to each cell.

      This method is a more scalable alternative to getValues or getCells for large or sparse ranges, as it:

      1. Skips empty values by default.
      2. Avoids creating large arrays.
      3. Allows for early termination.

      Type Parameters

      • B

      Parameters

      • callback: ICellRange.ForEachCallback<B>

        A function that will be called for each non-empty cell in the range. The callback receives:

        • value: The Scalar at the current cell.
        • context: A IteratorContext object providing additional information and utilities for the cell.
        • The callback can return { break: T } to stop the iteration early.
      • Optionaloptions: ICellRange.IteratorOptions<ICellRange.Address>

      Returns void | B

      The value returned by the callback function if it explicitly returned to stop the iteration early; otherwise, void.

    • Returns the coords as a string address (e.g., 'A1' or 'A1:E5').

      Parameters

      • Optionalr1c1: boolean

        If unspecified returns the environment's default.

      Returns string

    • The size this range's content needs — what getBounds would report if the range had been autoFit. A pure query: nothing is measured onto the model and nothing is committed.

      Parameters

      • Optionaloptions: BestFitOptions

        Measurement options. Default { axes: IRange.AxisSelection.Both }.

      Returns Size

      • The width is the sum of the per-column best fits and the height the sum of the per-row best fits, so a single-column range answers "how wide must this list be" directly.
      • An axis left out of BestFitOptions.axes reports its current size.
      • Only the range's own content is measured, so the answer never depends on cells outside it. (autoFit also scans outside the range, to prove a shrink is safe.)
      • Sheet protection is not consulted: reading a size cannot violate it, and a protected sheet answers the same as an unprotected one.
    • Returns the absolute bounds for the range.

      Returns Bounds

    • Returns the column after the current range.

      Parameters

      Returns this

      ICellRange with the top-left corner immediately after the current range.

      This will return a range with a column width of 1 but the original row height.

    • Returns the column at the specified absolute column index, retaining the current row span.

      Parameters

      • columnIndex: number

        The absolute column index (0-based). Must be ≥ 0. Not relative to the current range.

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange with a column width of 1 and the original row height.

    • Returns the column before the current range.

      Parameters

      Returns this

      ICellRange with the top-left corner immediately before the current range.

      This will return a range with a column width of 1 but the original row height.

    • Returns the column at the specified delta relative to the start of the current range, retaining the current row span.

      Parameters

      • columnDelta: number

        Number of columns to move from columnStart. Positive moves right; negative moves left.

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange with a column width of 1 and the original row height.

      getColumnBy(0) is equivalent to getColumnAt(columnStart) — the first column of the current range. To advance past the end of the range, use getColumnAfter instead.

    • Returns the number of columns of the range.

      Returns number

    • Returns the right of the range.

      Returns number

    • Returns the column start.

      Returns number

    • The IRange.Coords.

      Returns Readonly<IRange.FixableCoords>

    • Returns per-feature cell counts for the range.

      Parameters

      Returns Counts

      getCounts answers "how much of each feature is here"; getStats answers "what are the values like". Feature occupancy vs value analysis — they do not overlap.

      • Every public ICellRange.Feature appears as a key; features not requested, or not present, are an explicit 0 — the shape is stable and self-describing, never null.
      • Each feature is counted independently. getCounts([Fill, Border]) is two numbers, not the count of their refined intersection — the refined count is getRegions.
      • Counts are cells, never regions: a region count would either disagree with the partition getRegions returns or cost as much as computing it.
    • Returns the fill this range implies — which cells it would read, which it would cover, the fill types that can be offered for it, and the one to open on.

      Parameters

      • Optionaldirection: Direction

        Which way the series runs. Defaults to the range's own shape: a single row runs Right, anything else runs Down — or, with a destination, to the way it extends.

      • Optionaldestination: ICellRange.Address

        Fill the range as it is to here — the fill handle's drag. The template is then the WHOLE range, blanks included, rather than its leading run, and destination must extend it on exactly one edge as autoFill requires.

      Returns DefaultCriteria | null

      IAutoFill.DefaultCriteria, or null where there is nowhere to fill: the range is one cell deep along direction, or destination does not extend it — which is also how a surface learns that a direction is not on offer at all.

      Error If destination does not share three edges with the range, or direction is not the way it extends.

      Useful for displaying options to the ui — a Series dialog, or a fill menu deciding what to grey. Nothing is filled and nothing is committed; see autoFill to run one, and AutoFill.toFillOptions for the options a chosen IAutoFill.Preset amounts to.

    • Returns the default shift IRange.Axis for insert and delete if no axis is provided.

      Returns Axis

      Default IRange.Axis that will be used to shift the range.

      By default the direction of the shift will be the direction that shifts the fewest cells. If the range is the same size in both directions IRange.Axis.Row will be used.

      For example, a range with 5 columns and 1 row will have a default axis of IRange.Axis.Row.

    • Returns a default sort that would be used if no overrides where provided.

      Parameters

      • Optionalaxis: Axis

        The axis to sort. Default Value IRange.Axis.Row.

      • Optionalcell: ICell.Address

        A cell location that can be used to determine the sort column.

      Returns DefaultSortCriteria | null

      Default ISort.DefaultSortCriteria or null if there is not valid sort criteria.

      Useful for displaying options to the ui. The default behavior will look for headers and merges.

    • Returns all cells eventually affected by this range, through the full calculation chain.

      Returns Promise<ICellRanges | null>

      The range form of ICell.getDependents: a recursive walk downstream giving the total blast radius of a write here. Resolves null when there are none.

    • Returns a set of non-overlapping ranges the represents the difference between the current range and the specified range.

      Parameters

      Returns ICellRanges | null

      ICellRanges containing the resulting non-overlapping ranges, or null if:

      • There is no intersection between the current range and the specified address.
      • The specified address is the same as or encompasses the current range.
      • The method will always return between 0 and 4 ranges.
      • If there's no intersection, it returns an ICellRanges containing only the current range.
    • Returns the cells that directly reference any cell in this range.

      Returns Promise<ICellRanges | null>

      The range form of ICell.getDirectDependents — the immediate consumers of anything this range produces. Resolves null when there are none.

    • Returns the ranges immediately referenced by the formulas in this range.

      Returns Promise<ICellRanges | null>

      The range form of ICell.getDirectPrecedents: the union over every cell, one call rather than a fan-out — the calculation graph is indexed by range, so the cell form is this one over a 1×1.

      • Resolves null when there are none; see ICell.getDirectPrecedents for when it resolves.
      • Not filtered against the range itself. A block containing both a formula and its input lists that input; "what does this block read" and "what does it read from outside" are different questions, and the second is getDifferences away.
    • Returns a range that includes the columns for the entire sheet. For example, if the range is A1:B2, this method will return A:B.

      Parameters

      • Optionalshift: boolean

        If true this will also shift the columns by the width of the range. default false.

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange at the repositioned range.

    • Returns a range that includes the rows for the entire sheet. For example, if the range is A1:B2, this method will return 1:2.

      Parameters

      • Optionalshift: boolean

        If true this will also shift the rows by the height of the range. default false.

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange at the repositioned range.

    • Returns a range that includes the current range up to a content edge boundary.

      Parameters

      Returns this

      ICellRange extended in the given direction.

      The result includes the current range, and a boundary with nowhere to go returns the range unchanged — so comparing the two is how you tell there was nothing to extend onto.

      ICellRange.GetExtendedOptions.basis picks what the boundary is read from: the range's own content (Ctrl+Arrow, the default) or the lines flanking it (a double-clicked fill handle).

      Both bases read the content, merge and table indexes rather than walking cells, so the cost is the blocks involved and not the distance traveled — extending across a million rows costs what extending across ten does.

    • Returns a range with coordinates adjusted to be fixed (absolute) or flexible (relative).

      Parameters

      • Optionaloptions: boolean | GetFixedOptions

        Either a ICellRange.GetFixedOptions object to specify individual coordinate settings, or a boolean to adjust all coordinates at once. If a boolean is provided: - true sets all coordinates to absolute. - false sets all coordinates to relative.

      Returns this

      ICellRange with updated coordinate references types.

      If no options are provided, this method toggles the fixed flags for the range's coordinates based on their current settings. Calling this repeatedly will cycle between relative and absolute references. For example: A1 → $A$1 → A$1 → $A1 → A1

    • Returns the formula for the range.

      Parameters

      • Optionaladdress: ICell.Address

        The address of the cell to retrieve the formula for. Default value is the 'top left' cell of the range.

      Returns IFormula

      When querying the formula this will always be for the top left. However the set values work for the entire range.

      Returns the formula object, or null for a cell without one. For formula text across the whole range use ICellRange.getFormulas, which reads '' for cells without a formula.

    • Returns the formula text of every cell in the range.

      Returns string[][]

      A row-major 2D array in the shape of the range.

    • Returns the value for the top left InteropScalar.

      Returns InteropScalar

      The ignoreHidden option is ignored.

    • Return an array of coords for all merges.

      Returns Coords[]

      An array of 'IRange.Coords` that contain merges.

    • Returns the number format of every cell in the range.

      Returns string[][]

      A row-major 2D array in the shape of the range.

      • A cell without an authored format reads 'General'.
      • Throws if the range holds more than 10000 cells, like ICellRange.getValues.
    • Returns a range with the top-left corner moved by the specified row and column offsets.

      Parameters

      • rowDelta: number

        The number of rows to move the top-left corner up (negative) or down (positive).

      • colDelta: number

        The number of columns to move the top-left corner left (negative) or right (positive).

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange at the repositioned range.

    • Returns a range repositioned to the specified starting row and column indices.

      Parameters

      • rowStart: number

        The new starting row index (inclusive).

      • colStart: number

        The new starting column index (inclusive).

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange at the repositioned range.

    • Returns all ranges contributing to this range's values, through the full calculation chain.

      Returns Promise<ICellRanges | null>

      The range form of ICell.getPrecedents: a recursive walk upstream to the root data sources. Resolves null when there are none.

      Reach for this before editing. The precedents of a block are what its values depend on, so they are what a change to it can be wrong about.

    • Returns a 1×1 cell or an explicit range at the specified absolute sheet coordinates.

      Parameters

      • rowStart: number

        The absolute row index (0-based, inclusive). Must be ≥ 0.

      • colStart: number

        The absolute column index (0-based, inclusive). Must be ≥ 0.

      • OptionalrowEnd: number

        The absolute ending row index (inclusive). If not provided, defaults to rowStart (1×1 cell).

      • OptionalcolEnd: number

        The absolute ending column index (inclusive). If not provided, defaults to columnStart (1×1 cell).

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange at the specified coordinates.

      All indices are absolute — they are used directly as sheet coordinates and are not relative to the current range. Negative indices are not supported.

      When only rowStart and columnStart are supplied the result is always a single cell (1×1), regardless of the current range's shape. Use getOffsetTo to move the top-left corner while preserving the original dimensions.

    • Returns the uniform regions for the requested features within the range.

      Parameters

      • Optionalfeatures: ICellRange.Feature | readonly ICellRange.Feature[]

        The features to partition by. Defaults to ['Contentful'] — never all; combining features refines the partition (a cross-product), so all-features is the maximum-fragmentation call. Query one feature at a time; combine only when the relationship between features is the question.

      • Optionaloptions: GetRegionsOptions

      Returns ICellRegions

      A region answers where, not what. It carries its address, its shape and the features it was partitioned by, and it bridges to the objects that answer reads: ICellRegion.getCell (the anchor — whose read IS the region's payload, since a region is uniform by construction) and ICellRegion.getRange (the block). Reading is a different verb on a different object, and the hop is the point — it is what keeps a discovery result from answering a question it was never asked.

      • getRegions combines features into one partition; getCounts counts each feature separately. The refined count is this method; the cheap discovery is that one.
      • A count is presence; a partition is payload identity. getCounts(Fill) counts the cells that have a fill and getRegions(Fill) splits them by color; getCounts(Formula) counts formula cells and getRegions(Formula) splits them by authored R1C1 — so a filled block is ONE region and the value pasted over the middle of it is a hole. The rule holds for every feature.
      • Regions are maximal rectangles, never runs: a block filled down and across is one region, not one per column.
      • Regions carrying none of the requested features are elided — the yielded regions are the feature-bearing side of the partition.
      • Nothing is computed until the result is iterated or counted. The returned ICellRegions is a lazily backed handle, so building the query costs nothing.
      • Regions follow the payload, not how it was written. A solid A1:D4 is one Contentful region, and a number format applied in three strokes (or loaded from a file that stored it in pieces) is one NumberFormat region. The same holds for Fill and the other content-style features (Font, Alignment, Protection), and each of those splits only on its own part: a bold column inside a uniform number format does not split the NumberFormat region. Borders is the exception — a border's edges belong to the block it was applied to, so two equal boxes side by side are two regions. Refinement is unaffected — [Contentful, Fill] still partitions by fill and still excludes unoccupied cells.
      • Every Feature partitions — there is no throwing member left. DateFormat splits by format string, the same way Fill splits by color; Error splits by error value, backed by the reconciled error index. Scalar kinds (String/Number/Boolean) are not in this vocabulary at all — see Feature's own remarks for where they went.
    • Returns a range with the bottom-right corner moved by the specified row and column offsets.

      Parameters

      • rowDelta: number

        The number of rows to move the bottom-right corner up (negative) or down (positive).

      • colDelta: number

        The number of columns to move the bottom-right corner left (negative) or right (positive).

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange with the resized range.

    • Resizes the current range to the specified ending row and column indices.

      Parameters

      • rowEnd: number

        The new ending row index (inclusive).

      • colEnd: number

        The new ending column index (inclusive).

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange with the resized range.

    • Returns the row after the current range.

      Parameters

      Returns this

      ICellRange with the top-left corner immediately after the current range.

      This will return a range with a row height of 1 but the original column width.

    • Returns the row at the specified absolute row index, retaining the current column span.

      Parameters

      • rowIndex: number

        The absolute row index (0-based). Must be ≥ 0. Not relative to the current range.

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange with a row height of 1 and the original column width.

    • Returns the row before the current range.

      Parameters

      Returns this

      ICellRange with the top-left corner immediately before the current range.

      This will return a range with a row height of 1 but the original column width.

    • Returns the row at the specified delta relative to the start of the current range, retaining the current column span.

      Parameters

      • rowDelta: number

        Number of rows to move from rowStart. Positive moves down; negative moves up.

      • Optionaloptions: ICellRange.GetRangeOptions

      Returns this

      ICellRange with a row height of 1 and the original column width.

      getRowBy(0) is equivalent to getRowAt(rowStart) — the first row of the current range. To advance past the end of the range, use getRowAfter instead.

    • Returns the number of rows of the range.

      Returns number

    • Returns the bottom of the range.

      Returns number

    • Returns the top of the range.

      Returns number

    • Returns a snapshot of the current range's data and formatting suitable for copying or archiving.

      Parameters

      Returns ICellRange.ISnapshot

      A ISnapshot object representing the range.

      • Option Merging: If options are provided on getSnapshot and the copy operation, the two will be merged with the copy options taking precedence.
      • getSnapshot can be called multiple times allowing for multiple snapshots.
    • Returns the statistics for the range.

      Parameters

      • Optionaloptions: GetStatsOptions

        Iterator options the stats are created with — most usefully { onError: 'ignore' } so aggregate reads degrade instead of faulting on error values. The same override is available per-call on IRangeStats.getAggregates. { ignoreHidden: true } measures only what the sheet is showing.

      Returns IRangeStats

      getStats answers "what are the values like"; getCounts answers "how much of each feature is here". Value analysis (visits values) vs feature occupancy (reads the indexes) — they do not overlap.

    • Returns the style for the range.

      Returns IStyle

      When querying the style the values will always be for the top left. However the set values work for the entire range.

    • Returns a range with surrounding data or the entire range if there is no data nearby.

      Parameters

      Returns this

      ICellRange containing either nearby content or the entire range.

    • Returns the smallest range within the range that contains any used cells.

      Parameters

      Returns ICellRange | null

      ICellRange that contains the smallest range with used cells, or null if the range is empty.

      This method returns the range of cells that have been "used," which includes cells with data, as well as certain types of formatting or styling. It focuses on cells that have been interacted with in some form, whether through data entry or other modifications. Merged cells and overflow values may not always be included in this range.

      Narrow what counts as used with GetRangeOptions.features: cells with values always count, and each listed feature widens the extent beyond them — so features: [] is the values-only fast path (no feature index is consulted) and ['merge'] is values plus merged spans. The selection is sticky: the returned range carries it.

    • Returns the value for the top left Scalar.

      Returns Scalar

      The ignoreHidden option is ignored.

    • Returns a 2D array of Scalar | values in the shape of the range.

      Parameters

      • Optionaloptions: ICellRange.GetValuesOptions

        asJSDate Return dates as Javascript dates instead of SerialDates but is slower due to need to create dates.

        • maxSize Limit the size of the results. defaultValue 10000.

      Returns Scalar[][]

      A 2D array of values.

      • Empty values will be null.
    • Returns an immutable IRange snapshot of the cell range's current values.

      Returns IRange

      IRange is SheetXL's stateless value computation layer — it has no knowledge of the sheet, and the same logic runs identically in a browser, Node.js, or a Web Worker.

      This is the bridge between the live sheet (ICellRange) and pure value computation (IRange):

      • Pass the result to setValues or setComputedValues to write back to the sheet.
      • Use directly with formula functions and UDFs, which only operate on IRange.

      ICellRange and IRange for a full guide.

    • Returns a range that excludes any hidden rows or columns.

      Parameters

      • Optionaloptions: GetVisibleOptions

        Optional parameters that can adjust how visibility is determined (e.g., by ignoring specific visibility rules).

      Returns ICellRanges | null

      An ICellRanges object that contains the visible portions of the range, excluding any hidden rows or columns.

      • If all ranges within the original selection are visible, this method returns an ICellRanges object with a single range and a length of 1.
      • If the entire range is hidden, the method will return null.
      • The resulting ranges reflect the currently visible state of the sheet, including hidden rows, columns, or headers.
    • Groups the rows or columns of the range: each one moves one outline level deeper.

      Parameters

      • Optionalaxis: Axis

        Whether to group the rows or the columns. When omitted, entire rows group the rows, entire columns group the columns, and any other range groups both.

      • Optionaloptions: ITransaction.OperationOptions

      Returns this

      The current ICellRange.

      Error If a row or column in the range is already at the deepest level, 7. Nothing is grouped.

    • Insert a new, empty range within the sheet and shifts existing cells to accommodate it.

      Parameters

      Returns this

      The current ICellRange.

      Error If the insertion would cause data to exceed the maximum sheet size.

      By default the values will direction in whichever direction the selection shape is smaller. For example a selection with a 5 column by 1 row will direction Down (rows). Note - This will error if direction data will fall outsize of the max sheet size.

    • Inserts the contents of the source into the sheet, shifting existing cells to make space.

      Parameters

      Returns Promise<ICellRange | null>

      A promise that resolve to an ICellRange or 'null' when the copy has completed.

      • Behaves similarly to insert and copyFrom, but instead of inserting empty space at the range it also inserts the content of the source.
      • Will return null if nothing was inserted or the source doesn't have a range.
    • Returns true if there is any content within the range.

      Parameters

      Returns boolean

      'boolean' indicating if there is content.

      Some uses cases for this are checking for data to delete a sheet, checking for multiple values for merges.

    • Checks if the ranges is empty, meaning it has no values or formatting.

      Returns boolean

      Convenience getUsedRange() === null.

    • Returns true if the range is entire columns, such as B:D: it spans every row of the sheet.

      Returns boolean

      The counterpart of Office Scripts' isEntireColumn.

    • Returns true if the range represents both entire rows and entire columns.

      Returns boolean

    • Returns true if the range is entire rows, such as 2:4: it spans every column of the sheet.

      Returns boolean

      The counterpart of Office Scripts' isEntireRow.

    • Returns true if the range is invalid.

      Returns boolean

      Ranges can be invalid if a range is removed due to deleting rows or columns or if the range is created with invalid coordinates.

    • Indicates if the range is readonly only.

      Returns boolean

      Not an indicator of if the range is protected but rather if the range is being used in a way that doesn't support write operations. (e.g. the range is being provided as a listener source ICellRange.Event or the range belongs to a historical snapshot.)

    • Returns true if the range is a single cell.

      Returns boolean

    • Merges all cells within the selection ranges.

      Parameters

      Returns this

      The current ICellRange.

      If the ranges overlap then this operation will throw an exception

    • Removes duplicate rows based on specified columns.

      Parameters

      • Optionaloptions: RemoveDuplicatesOptions

        Configuration for the duplicate removal operation, including the columns to consider.

      Returns this

      ICellRange containing the rows that remain. This is the original range resized by the number of rows that were removed (the origin and the columns are unchanged).

      Error if the range has no data or if a columns entry is not within the range.

      This method mimics the "Remove Duplicates" feature in Excel.

      The duplicate rows are deleted rather than cleared, so the rows that remain keep their formatting, hyperlinks and comments. Only the range is compacted - the same number of rows is given back at the bottom of the range so that the cells below it stay where they are.

      A row with no values is still a row. The first blank row is unique and any that follow are duplicates of it. Blank rows after the last row with a value are left alone.

    • Sets or clears the comment on the range's first cell.

      Parameters

      Returns this

      The current ICellRange.

      A comment is on one cell, so a value goes on the range's top-left cell — updating the comment there if it has one, adding one otherwise — while null clears every comment within the range. The comment itself is the richer surface: getSheet().getComments() to add, and ICell.getComments to reach the one on a cell.

    • Applies a transformation to the cell range's values and writes the result back to the sheet.

      Parameters

      • callback: (range: IRange) => IRange

        A pure function that transforms the cell range's IRange.

      • Optionaloptions: ITransaction.OperationOptions

      Returns this

      Convenience wrapper around getValuesRange and setValues:

      setComputedValues(fn) ≡ this.setValues(fn(this.getValuesRange()))
      

      The callback receives the current values as an immutable IRange, and the returned IRange is written back to the sheet.

    • Sets the formula of each cell in the range.

      Parameters

      • formulas: readonly string[][]

        Formula text in row-major order, each with a leading =.

      • Optionaloptions: SetValuesOptions

      Returns this

      The same write as ICellRange.setValues: text with a leading = is entered as a formula, and an array smaller than the range writes only the cells it covers.

    • Sets one number format on every cell in the range.

      Parameters

      • numFmt: string | null

        The format code, or null to clear it.

      • Optionaloptions: UpdateOptions

      Returns this

    • Set the value(s) of one or more cells within a range.

      Parameters

      Returns this

      The current ICellRange.

      • null values will clear the corresponding cells.
      • undefined values will be ignored, leaving the existing cell values unchanged.
      • If an array is passed the values will be in row-major order. An array smaller than the range writes only the cells it covers.
      • If a single value is passed in it will repeat the entire range.
    • Expands the groups the range selects: those whose summary row or column is in the range or, when there are none, the innermost groups the range meets.

      Parameters

      • Optionalaxis: Axis

        Whether to expand row groups or column groups. Inferred when the range is entire rows or entire columns; required otherwise.

      • Optionaloptions: ITransaction.OperationOptions

      Returns this

      The current ICellRange.

      Error If the axis is not given and cannot be inferred.

      Groups nested inside that are collapsed stay collapsed.

    • Sort the given range.

      Parameters

      Returns this

      The current ICellRange.

      The sorting of various data types has a default priority of of boolean > string > number and dates are treated as numbers. If a boolean is used then this is a 'descending' flag. true then the sort is reversed (descending).

    • Parses the text in the selected column into multiple columns based on a delimiter.

      Parameters

      • Optionaloptions: string | TextToColumnsOptions

        Delimiter or Configuration for the split operation, including delimiter and handling of existing data.

      Returns this

      ICellRange containing the the newly split data

      Error if the destination cells are not empty and replaceExisting is false.

      This method mimics the "Delimited" mode of Excel's Text-to-Columns feature. By default, this operation is non-destructive (it will not overwrite existing data unless replaceExisting is true).

    • Returns the address as a string.

      Returns string

    • Ungroups the rows or columns of the range: each grouped one moves one outline level out. Rows or columns that are not grouped are left alone.

      Parameters

      Returns this

      The current ICellRange.