SheetXL - v1.0.2
    Preparing search index...

    Interface IWorksheet

    An IWorksheet represents a collection of elements (such as ranges, tables, etc) contained within and visualized through a view.

    This interface provides methods for accessing its elements and event handling.

    Most interactions with a sheet are done using either a range or ranges.

    While a sheet can be used stand-alone it is typically used within the context of a workbook.

    interface IWorksheet {
        isISheet: true;
        isIWorksheet: true;
        addAutoTable(address?: ICellRange, options?: AddAutoTableOptions): ITable;
        addHorizontalPageBreak(
            pageBreakRange: ICellRange.Address,
            options?: ITransaction.OperationOptions,
        ): IPageBreak;
        addListeners(
            listeners: IWorksheet.IListeners,
            options?: IListener.Options,
        ): Remove;
        addVerticalPageBreak(
            pageBreakRange: ICellRange.Address,
            options?: ITransaction.OperationOptions,
        ): IPageBreak;
        beginCommit(options?: string | ITransaction.OperationOptions): ITransaction;
        calculate(full?: boolean): Promise<ICalculation.Status>;
        close(): void;
        createCell(
            update: ICell.Update,
            coords?: FixableCellCoords,
            options?: CreateCellOptions,
        ): ICell;
        createFormula(
            expression: string,
            coords?: Partial<CellCoords>,
            options?: CreateFormulaOptions,
        ): IFormula;
        delete(): void;
        doBatch<R = any>(
            callback: (commit: ICommit, sheet: this) => R | Promise<R>,
            options?: string | ITransaction.OperationOptions,
        ): R | Promise<R>;
        duplicate(): Promise<IWorksheet>;
        evaluate(
            formula: string,
            options?: EvaluateOptions & Partial<CellCoords> & CreateFormulaOptions,
        ): Promise<Scalar | IRange<Scalar>>;
        find(options: string | FindOptions): Iterator<ICell>;
        getAnomalies(options?: GetAnomaliesOptions): ICellRegions;
        getAutoTable(): ITable | null;
        getCalculation(): ICalculation;
        getCell(address?: ICell.Address): ICell;
        getCellControls(): ICellControlCollection;
        getCharts(): IChartCollection;
        getCodeName(): string | null;
        getColumnHeaders(): ISheetHeader;
        getColumnWidthAsFontUnit(pixelWidth: number): number;
        getComments(): ICommentCollection;
        getConditionalFormats(): IConditionalFormatCollection;
        getDataValidations(): IDataValidationCollection;
        getEntireCoords(): Coords;
        getEntireRange(options?: ICellRange.GetRangeOptions): ICellRange;
        getFonts(): IFontCollection;
        getHorizontalPageBreaks(): IPageBreak[];
        getId(): string;
        getIndex(): number;
        getKind(): "worksheet";
        getModules(): IModuleCollection;
        getMovables(): IMovableCollection;
        getName(): string;
        getNames(): INamedCollection;
        getOutline(): IOutline;
        getPageLayout(): IPageLayout;
        getPicture(): IPicture | null;
        getPivotTables(): IPivotTableCollection;
        getProtectedRanges(): IProtectedRangeCollection;
        getProtection(): IWorksheetProtection;
        getRange(
            address?: ICellRange.Address,
            options?: ICellRange.GetRangeOptions,
        ): ICellRange;
        getRangeAt(
            rowStart: number,
            columnStart: number,
            rowEnd?: number,
            columnEnd?: number,
            options?: ICellRange.GetRangeOptions,
        ): ICellRange;
        getRangeAtBounds(
            bounds: Bounds,
            options?: ICellRange.GetRangeOptions,
        ): ICellRange;
        getRanges(
            address: ICellRanges.Address,
            options?: ICellRange.GetRangeOptions,
        ): ICellRanges;
        getRegions(
            features?: ICellRange.Feature | readonly ICellRange.Feature[],
            options?: GetRegionsOptions,
        ): ICellRegions;
        getResources(): IResourceCollection;
        getRowHeaders(): ISheetHeader;
        getRuntime(): IRuntime;
        getSelectedCell(): ICell;
        getSelectedRange(options?: ICellRange.GetRangeOptions): ICellRange;
        getSelectedRanges(options?: ICellRange.GetRangeOptions): ICellRanges;
        getSelection(): IRangeSelection;
        getSparklineGroups(): ISparklineGroupCollection;
        getStats(options?: GetStatsOptions): IRangeStats;
        getStrings(): IStringCollection;
        getStyles(): IStyleCollection;
        getSyncScroll(): SyncScroll | null;
        getTabColor(): IColor;
        getTables(): ITableCollection;
        getTransactions(): IStore;
        getUsedRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
        getVersionId(): number;
        getVerticalPageBreaks(): IPageBreak[];
        getView(): IWorksheetView;
        getVisibility(): ISheet.Visibility;
        getWorkbook(): IWorkbook | null;
        isClosed(): boolean;
        isConditionalFormatCalculationEnabled(): boolean;
        isDeleted(): boolean;
        isExcludedFromPublishing(): boolean;
        isTransitionFormulaEntry(): boolean;
        isTransitionFormulaEvaluation(): boolean;
        removeAllHorizontalPageBreaks(
            options?: ITransaction.OperationOptions,
        ): void;
        removeAllVerticalPageBreaks(options?: ITransaction.OperationOptions): void;
        scrollTo(
            coords: Partial<IRange.Coords>,
            options: ScrollToOptions,
        ): Promise<boolean>;
        select(options?: ITypes.SelectOptions): Promise<IWorksheet>;
        setEntireSize(
            size?: Partial<EntireSize> | null,
            options?: ITransaction.OperationOptions,
        ): this;
        setIndex(index: number): this;
        setName(name: string, options?: ITransaction.OperationOptions): this;
        setPicture(
            picture: string | IResource | IResourceCollection.AddOptions | null,
            options?: ITransaction.OperationOptions,
        ): this;
        setTabColor(color: string | IColor | null): this;
        setView(view: IWorksheetView): this;
        setVisibility(
            visibility?: boolean | ISheet.Visibility,
            options?: ITransaction.OperationOptions,
        ): IWorksheet;
        toJSON(options?: ToJSONOptions): Promise<IWorksheet.JSON>;
        whenCalculationReady(): Promise<ICalculation.Status>;
        whenFontsReady(): Promise<void>;
        whenReady(): Promise<void>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    isISheet: true

    For runtime type checking.

    isIWorksheet: true

    For runtime type checking.

    • Batches all 'transactional' changes until they have all be committed or rolled back.

      Parameters

      • Optionaloptions: string | ITransaction.OperationOptions

        Description of the operation or additional options. Used for tracking undo/redo and history. Default Value User Operation.

      Returns ITransaction

      Any changes that are made to this object will be reflected in the local record but not committed to the transactional store until the batch is popped.

      Useful for operations that are longer running but generally not recommended as it keeps a transaction open. doBatch is the preferred option.

    • Recalculates THIS sheet — Excel's "Calculate Sheet" (Shift+F9) / Worksheet.Calculate.

      Parameters

      • Optionalfull: boolean

        When true, recalculate every formula on the sheet. Otherwise only the ones whose inputs changed (plus volatiles), which is what Excel's Shift+F9 does.

      Returns Promise<ICalculation.Status>

      Distinct from getEntireRange().calculate(full), which marks the range dirty first and is therefore always a FORCE for those cells. This is the dirty-respecting sheet-scoped pass.

      Only the SEED is scoped to this sheet: dependents on other sheets still recalculate, and volatiles are still workbook-wide. Excel leaves both stale; being more current is the safe direction, and the volatile registry is drained per pass, so skipping them would deregister them outright.

    • Free all resources associated with the sheet.

      Returns void

      • Called by workbooks when the workbook is is closed.
      • This is different than delete which removes the sheet from the workbook.

      IWorksheet.addListeners for closeEvent

    • Creates a cell that is not including at a coordinate but adopts all rendering.

      Parameters

      Returns ICell

      A detached ICell

      • Useful for previewing values such as tooltip, or what typed text would be entered as.
      • Does not add to the sheet but provides a standalone ICell.
      • If the coords are passed it will return disconnect cell update for that value.
    • Parses a formula expression and returns a transient formula object anchored to this sheet.

      Parameters

      • expression: string

        The formula expression to parse.

      • Optionalcoords: Partial<CellCoords>

        Optional anchor coordinates.

      • Optionaloptions: CreateFormulaOptions

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

      Returns IFormula

      This is a convenience method for getCalculation().createFormula(expression, coords, options); like everything reached through the sheet's getCalculation, a bare reference (A2) resolves against THIS sheet rather than the selected one.

    • Removes from a container. This is usually the Workbook. If this is being used standalone this operation will throw an exception.

      Returns void

    • Performs a set of operations as one: one commit, one undo step, one round of events.

      Type Parameters

      • R = any

      Parameters

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

        Performs the operations. Handed the commit being written and sheet, this sheet bound to the batch.

      • Optionaloptions: string | ITransaction.OperationOptions

        Description of the operation or additional options. Used for undo/redo and history.

      Returns R | Promise<R>

      Work through sheet rather than this one: what is reached through it is part of the batch, as for IWorkbook.doBatch.

    • Returns a promise that will resolve to a copy of the current sheet.

      Returns Promise<IWorksheet>

    • Evaluates a formula in the context of the sheet and returns the resulting value.

      Parameters

      Returns Promise<Scalar | IRange<Scalar>>

      This is similar convenience method for getCalculation().createFormula(expression).evaluate(options).

    • Returns the ICalculation anchored to this sheet.

      Returns ICalculation

      The engine itself is workbook-wide; this is a view over it that supplies THIS sheet as the context whenever a caller doesn't name one. So an expression parsed or evaluated through it resolves a bare reference (A2) against this sheet — not against whichever sheet happens to be selected.

      That matters for anything anchored by coords alone, e.g. sheet.getCalculation().createFormula('=A2+B2', cell.getCoords()): reached through the workbook (IWorkbook.getCalculation) the same call has no sheet context and falls back to the active cell's sheet, which makes the parse depend on UI selection state. Pass an explicit coords.scope to override the anchor (a cross-sheet reference is unaffected either way — it names its own sheet).

    • Returns a ICell at the specified address.

      Parameters

      • Optionaladdress: ICell.Address

        Address of the cell. Omit for the selected cell — selection is modeled by the SDK (not a UI mode), and many operations default to it. getSelectedCell remains the explicit form.

      Returns ICell

    • Returns the charts on this sheet.

      Returns IChartCollection

      A view over IWorksheet.getMovables: every chart is the content of a movable, which is what places and names it. Read-only for now — a chart is added by adding a movable with chart content.

    • The sheet's VBA code name, or null if it has none.

      Returns string | null

      null
      

      The identifier VBA binds a sheet through — Sheet1.Range("A1") in a macro resolves by code name, never by tab name. It is a second, independent identity for the sheet: renaming the tab does not change it, and it is not the sheet's position. Excel's default happens to look positional (Sheet1, Sheet2, …) but drifts from position the moment sheets are reordered, inserted or deleted, so it can only be carried — never derived.

      Present on any workbook that has, or has ever had, a VBA project: it survives the project being stripped, so an .xlsx saved down from an .xlsm still carries code names. A workbook that never had one has none, and this is null throughout.

      Read-only. SheetXL preserves what a file declared and never mints one — a code name is assigned by the VBA editor, and inventing one would create a binding target no macro refers to. There is deliberately no setCodeName.

    • Returns the coords for the entire sheet.

      Returns Coords

      This is a lightweight call to IWorksheet.getEntireRange().getCoords().

    • Returns the IFontCollection the sheet measures text with.

      Returns IFontCollection

      Fonts are shared: every sheet, with or without a workbook, returns the same collection, so a face loaded for one is loaded for all.

    • The manual page breaks before rows, in order. The same as getPageLayout().getHorizontalPageBreaks().

      Returns IPageBreak[]

      The counterpart of Office Scripts' Worksheet.getHorizontalPageBreaks.

    • The sheet's id: what formulas and operations identify it by. Unique among all in-memory sheets.

      Returns string

    • Returns the current index of the IWorksheet within its container.

      Returns number

      Will return -1 if not in a Workbook or other sheet container.

    • Returns the modules this sheet owns.

      Returns IModuleCollection

      A sheet's modules are stored by the sheet rather than tagged with its name, so the state a tag would allow — a module left behind pointing at a sheet that no longer exists — cannot occur: delete the sheet and its modules go with it, which is also what Excel does.

      These modules are scoped to the sheet (IModule.getScope), and scope is a visibility rule: a function declared here is not callable from a cell formula, on this sheet or any other. Only globally scoped modules contribute to the formula namespace.

      The VBA document module for this sheet lands here, joined to it by IWorksheet.getCodeName — for a document module the module name is the code name.

      As with IWorkbook.getScripts, the collection filters to TypeScript unless asked otherwise; imported VBA is read with getItems({ language: 'vba' }).

    • Returns the display name for the sheet.

      Returns string

    • The INameds visible from this sheet — what a formula written here can refer to.

      Returns INamedCollection

      The global items (every table among them, since a table name is always global) plus this sheet's own scoped names, with shadowing resolved: where a sheet-scoped name and a global share a name, only this sheet's is returned, because that is the one a formula here resolves to. Another sheet's scoped names are never included.

      Everything is anchored to THIS sheet, not the selected one: getByName resolves against it, and getByRanges reads unqualified coords as being on it — which is what lets this sheet's own selection be passed straight in.

      Use IWorkbook.getNames for every name in the workbook (a name manager), and IWorksheet.getTables for the tables that LIVE on this sheet — scope here is visibility, never location, so a table anchored to another sheet is still visible from this one.

    • The row and column groups on this sheet, and how they are laid out.

      Returns IOutline

    • How the sheet is laid out on printed pages: paper, orientation, scale, margins, headers and footers, the print area and the rows and columns repeated on every page.

      Returns IPageLayout

      The counterpart of Office Scripts' Worksheet.getPageLayout. The manual page breaks are part of it (IPageLayout.getHorizontalPageBreaks).

    • Returns the picture interface for the sheet.

      Returns IPicture | null

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

      Parameters

      • rowStart: number
      • columnStart: number
      • OptionalrowEnd: number
      • OptionalcolumnEnd: number
      • Optionaloptions: ICellRange.GetRangeOptions

      Returns ICellRange

      ICellRange.getRangeAt for relative coordinates.

    • Returns the uniform regions for the requested features across the whole sheet.

      Parameters

      Returns ICellRegions

      The partition operator belongs on the thing partitioned, and "where are the blocks in this sheet" is the question an agent actually has — the ICellRange flavor is how you constrain that query, not how you start it.

      Equivalent to getEntireRange().getRegions(…): the partition reads the feature indexes, so it costs the used cells rather than the address space.

    • Returns the runtime used for this sheet.

      Returns IRuntime

      This can not be set on the IWorksheet. This is managed by the sheet's container.

    • Returns the selected cell.

      Returns ICell

      This is a convenience method for 'getSelection().getCell()'.

    • Returns the current selection.

      Returns IRangeSelection

      This allows for listening to selection changes and advanced navigation.

    • Returns the sparkline groups on this sheet.

      Returns ISparklineGroupCollection

      A sparkline is a small chart drawn in a cell, over its value. Each group shares one type and one set of properties across its sparklines.

    • Returns the statistics for the used cells of the sheet.

      Parameters

      • Optionaloptions: GetStatsOptions

        Iterator options the stats are created with — most usefully { onError: 'ignore' } so aggregate reads degrade instead of faulting on error values.

      Returns IRangeStats

      Equivalent to getUsedRange().getStats(…) except null-safe — an empty sheet returns empty statistics (getSize() === 0) rather than forcing the caller to branch on getUsedRange returning null.

    • The sheet's synchronized scrolling, or null when it has none.

      Returns SyncScroll | null

      The file's sheetPr syncHorizontal, syncVertical and syncRef. Carried, not acted on: the anchor is kept as written and does not move with inserts or deletes.

    • Return a custom color or null if no custom color has been set.

      Returns IColor

      null
      
    • Returns the current shared resources.

      Returns IStore

    • Every committed update gives the record a new, strictly increasing version id.

      Returns number

      Used with getId to uniquely identify a version of the record.

      The id is an identity, not a per-record count: ids are drawn from a single store-wide sequence bumped once per commit, so all records written in the same commit share an id and a given record's ids increase but are not sequential.

      Records are immutable so a restore/revert doesn't change them — it repoints, and the version id reported is the one for the snapshot the store is currently at. Version ids are never reused: a write after an undo receives an id higher than any previously issued, so a stale reader can always detect the change.

    • The manual page breaks before columns, in order. The same as getPageLayout().getVerticalPageBreaks().

      Returns IPageBreak[]

    • Returns the current view settings View settings determine how the sheet is displayed and interacted with (e.g., frozen panes, zoom level, selection) but do not affect the underlying data itself.

      Returns IWorksheetView

      The IWorksheetView object representing the current view settings.

    • Returns true if the sheet has been closed.

      Returns boolean

    • Whether conditional formats on this sheet are recalculated as the sheet changes.

      Returns boolean

      true
      

      Excel exposes this only to VBA (Worksheet.EnableFormatConditionsCalculation). It is carried so a workbook that turned it off keeps it off when saved; SheetXL still evaluates conditional formats either way.

    • Returns if the sheet has been deleted from its container.

      Returns boolean

    • Whether this sheet is left out when the workbook is published (to SharePoint Excel Services).

      Returns boolean

      false
      

      The file's sheetPr/@published="0". Carried, not acted on.

    • Whether formulas on this sheet are entered by Lotus 1-2-3 rules ("Transition formula entry" in Excel's Lotus compatibility settings).

      Returns boolean

      false
      

      VBA's Worksheet.TransitionFormEntry. Carried so a workbook that set it keeps it when saved; SheetXL parses formulas by Excel's rules either way.

    • Whether formulas on this sheet are evaluated by Lotus 1-2-3 rules ("Transition formula evaluation" in Excel's Lotus compatibility settings).

      Returns boolean

      false
      

      VBA's Worksheet.TransitionExpEval. Carried so a workbook that set it keeps it when saved; SheetXL evaluates by Excel's rules either way.

    • Attempt to scroll the range into view.

      Parameters

      Returns Promise<boolean>

    • Set the entire size of the sheet: where its last column and row are.

      Parameters

      • Optionalsize: Partial<EntireSize> | null

        The number of columns and rows. 'fit' ends that axis where the sheet's content does, and keeps it there: an insert grows the sheet instead of being refused for pushing content off the end, and a delete shrinks it. A number fixes the axis at that size. An axis left out keeps its size and whether it fits; null resets both to the default.

      • Optionaloptions: ITransaction.OperationOptions

      Returns this

      sheet.setEntireSize({ width: 4, height: 'fit' }); // columns A:D, rows to the last used row
      
    • Reorders the IWorksheet with in the container. This is generally the tab order within an IWorkbook but may be the zIndex if the ISheets are movable. This only affects visual listings of the sheets (but selection doesn't change).

      Parameters

      • index: number

      Returns this

      This is zero-based.

    • See the tab color for the sheet.

      Parameters

      • color: string | IColor | null

        The color

      Returns this

      • If set to null the color will revert to the default.
      • The tab color is not used by the sheet but rather by the workbook.
    • Returns when all calculations are complete and there are no pending calculations.

      Returns Promise<ICalculation.Status>

      • Also waits for the load-time start: the pass ICellContainerOptions.calcOnLoad asks for. This is the settle point after constructing from JSON.
      • Otherwise a convenience method for getCalculation().ready(), which starts the engine if it has not been started.
    • Returns when every font the sheet measures with has loaded and every autofit that was taken with a stand-in meanwhile has been taken again.

      Returns Promise<void>

      Measuring never waits: a style naming a face not yet loaded measures with a related or built-in one and the lookup starts the load, the way a browser paints with a fallback until a web font arrives. This is the point after which sizes are final. Fonts are shared, so this also waits for faces other sheets and workbooks started loading; a load that fails leaves its stand-in and still settles.

      The same point as IWorkbook.whenFontsReady; a sheet without a workbook has it here.