SheetXL - v0.3.20
    Preparing search index...

    Interface IWorkbook

    An IWorkbook represents a collection of sheets, along with shared resources.

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

    Most interactions with a workbook or sheet are done through a workbook range.

    interface IWorkbook {
        isIWorkbook: true;
        options: IWorkbook.ConstructorOptions;
        addListeners(listeners: IListeners, options?: IListener.Options): Remove;
        beginCommit(options?: string | OperationOptions): ITransaction;
        close(): void;
        doBatch<R = any>(
            callback: (commit: ICommit) => R | Promise<R>,
            options?: string | OperationOptions,
        ): R | Promise<R>;
        find(text: string, options?: FindOptions): Iterator<ICell>;
        findValidSheetName(sheetName: string): string;
        getCalculation(): ICalculation;
        getNames(): INamedCollection;
        getNextSheet(index: number): ISheet;
        getPreviousSheet(index: number): ISheet;
        getProtection(): IWorkbookProtection;
        getRange(
            address: ICellRange.Address,
            options?: GetRangeOptions,
        ): ICellRange;
        getRanges(
            address: ICellRanges.Address,
            options?: GetRangeOptions,
        ): ICellRanges;
        getResources(): IResourceCollection;
        getScripts(): IScript;
        getSelectedCell(): ICell;
        getSelectedRange(options?: GetRangeOptions): ICellRange;
        getSelectedRanges(options?: GetRangeOptions): ICellRanges;
        getSelectedSheet(): ISheet;
        getSelectedSheetIndex(): number;
        getSheet(name: string, visibility?: Visibility): ISheet;
        getSheetAt(index: number, visibility?: Visibility): ISheet;
        getSheets(): ISheetCollection;
        getStrings(): IStringCollection;
        getStyles(): IStyleCollection;
        getTheme(): ITheme;
        getTransactions(): IStore;
        getUUID(): string;
        getView(): IWorkbookView;
        isClosed(): boolean;
        isDate1904(): boolean;
        isValidSheetNameCharacter(character: string): boolean;
        replace(
            cells: Iterator<ICell>,
            replace: ICell.Update | ((original: ICell) => ICell.Update),
            options?: ReplaceOptions,
        ): ReplaceResults;
        setDate1904(date1940: boolean): this;
        setTheme(theme: ITheme): ITheme;
        setView(view: IWorkbookView): this;
        toJSON(excludeData?: boolean): Promise<JSON>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    isIWorkbook: true

    For runtime type checking.

    Returns any custom workbook options that are provided in constructor.

    Methods

    • Add Listeners.

      Parameters

      Returns Remove

      IListener.ISource.addListeners

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

      Parameters

      • Optionaloptions: string | 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.

    • Close the workbook and release any resources.

      Returns void

      No further operations are allowed after a close.

    • Provides a mechanism to perform a set of operations in a batch.

      Type Parameters

      • R = any

      Parameters

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

        A callback that performs multiple operations all within the same transaction.

      • Optionaloptions: string | OperationOptions

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

      Returns R | Promise<R>

    • Given the name return a valid name that closely matches.

      Parameters

      • sheetName: string

        The string to validate.

      Returns string

    • Returns the next sheet in the sheets collection. If the last one it will return the first.

      Parameters

      • index: number

      Returns ISheet

      If there is only 1 sheet this will return the current sheet.

    • Returns the previous sheet in the sheets collection. If the first one it will return the last.

      Parameters

      • index: number

      Returns ISheet

      If there is only 1 sheet this will return the current sheet.

    • Returns ranges scoped to a sheet.

      Parameters

      Returns ICellRange

      When accessing ranges from the IWorkbook ranges include a sheet name. This enables cross-sheet references when working at the workbook level.

      Some examples of cross-sheet reference are:

      • Linking data and formulas across multiple sheets.

      • Consolidating data from different sheets for analysis or reporting.

      • Performing calculations or comparisons that involve values from multiple sheets.

    • Returns any user defined functions stored with the workbook.

      Returns IScript

    • Returns the selected cell.

      Returns ICell

    • Returns the currently active sheet within the workbook.

      Returns ISheet

    • Returns the currently active sheet index within the workbook.

      Returns number

    • Returns the sheet for the given name.

      Parameters

      • name: string

        The name of the sheet.

      • Optionalvisibility: Visibility

        The visibility of the sheet.

      Returns ISheet

    • Returns the sheet at the given offset.

      Parameters

      • index: number

        A 0-based index of the sheet.

      • Optionalvisibility: Visibility

        The visibility of the sheet.

      Returns ISheet

    • Returns the current shared resources.

      Returns IStore

    • A unique identifier for the record. This will never change.

      Returns string

      This enables the record to be identified across transactions and users in a collaborative environment.

    • Returns the current view settings.

      View settings determine how specific workbook level elements are displayed but does not affect the underlying data itself.

      Returns IWorkbookView

    • Indicate if the current character is a valid character for a sheetName.

      Parameters

      • character: string

        The string to validate.

      Returns boolean

    • Determine if dates should be 1904 instead of 1900 based.

      Parameters

      • date1940: boolean

        default value false

      Returns this

    • Set the current theme.

      Parameters

      Returns ITheme

      • If null sets back to the default theme.
      • Does not fire a theme updated event.
    • Views have their own lifecycle because in a collaborative environment each user can have their own view.

      Parameters

      Returns this

    • Serialize the workbook to a JSON.

      Parameters

      • OptionalexcludeData: boolean

        If true only meta data about the workbook will be saved.

      Returns Promise<JSON>