Interface IWorkbookModel

The workbook model is the top level model that contains resources to a collection of the sheets, named ranges, and formulas.

interface IWorkbookModel {
    isIWorkbookModel: true;
    options: IWorkbookModelOptions;
    activateNextSheet(): ISheetModel;
    activatePreviousSheet(): ISheetModel;
    addListener(listener): RemoveListener;
    addRangeListener(address, listener, options?): RemoveListener;
    addSheet(sheetName?, index?): ISheetModel;
    close(): void;
    decodeAddress(address): SheetCellRangeCoords[];
    deleteSheet(key): ISheetModel;
    duplicateSheet(key?): Promise<ISheetModel>;
    find(findText, options?): SheetCoordsValuePair<ICellModel>;
    findValidSheetName(sheetName): string;
    fromJSON(json): void;
    getActiveAddressCoords(): SheetCellCoords;
    getActiveAddressCoordsA1(): string;
    getActiveSheetIndex(): number;
    getCell(address?): ICellModel;
    getNamedItems(): INamedItems;
    getProtection(): Readonly<WorkbookProtection>;
    getRange(address?): IWorkbookRange;
    getResources(): ISharedResourceCollection;
    getSheet(key?): ISheetModel;
    getSheetNames(): string[];
    getSheetRef(key, visibility?): SheetRef;
    getSheetRefById(id): SheetRef;
    getSheetRefs(visibility?): SheetRef[];
    getTheme(): IDocTheme;
    getTransactionStore(): TransactionStore;
    getView(): IWorkbookView;
    is1904DateSystem(): boolean;
    isClosed(): boolean;
    moveSheet(indexFrom, indexTo): ISheetModel;
    pushTransaction(description?): ITransaction;
    replace(findText, replaceText, options?): {
        count: number;
        next: SheetCellCoordsAddress;
    };
    set1904DateSystem(is1904Date): void;
    setActiveSheet(key): ISheetModel;
    setCell(address, value, options?): ICellModel;
    setProtection(protection): void;
    setSheetName(key, sheetName): ISheetModel;
    setSheetVisibility(key, visibility): ISheetModel;
    setTheme(theme): IDocTheme;
    setView(view): void;
    sheetStyle(): ISheetStyle;
    toJSON(): Promise<WorkbookJSON>;
}

Hierarchy (view full)

Implemented by

Properties

isIWorkbookModel: true

Used for runtime reflection.

This returns any custom workbook options that are provided in constructor.

Methods

  • Adds a sheet at the given index with the given name. This will throw an exception if the sheetName is invalid or already used.

    Parameters

    • Optional sheetName: string
    • Optional index: number

    Returns ISheetModel

    ISheetModel the newly added/created ISheetModel.

  • Close the workbook and release any resources. No further operations are allowed after a close

    Returns void

  • Will create a duplicate of the the specified sheet or the current active sheet if no sheet is specified.

    Parameters

    Returns Promise<ISheetModel>

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

    Parameters

    • sheetName: string

    Returns string

  • Load the state from a JSON

    Parameters

    Returns void

  • Returns the active cell as an A1 style reference

    Returns string

  • Returns the currently active sheet within the workbook

    Returns number

  • Return the getCell for the given address or the active cell if no address is specified.

    Parameters

    Returns ICellModel

    Remarks

    This will never return null.

  • Return the names of the ranges. These are sorted/filtered by type then by name.

    Returns INamedItems

  • Return the sheet for the given key. If no key is specified then the current active sheet is returned.

    Parameters

    Returns ISheetModel

  • Ordered list of sheetNames. This will only return SheetVisibility.Visible

    Returns string[]

  • Get the sheet reference.

    Parameters

    Returns SheetRef

    See

    SheetRef Will return null if not available ether because it was not found or did not match the visibility

  • Return a sheetRef by it's unique id.

    Parameters

    • id: number

    Returns SheetRef

  • Get all of the Sheet handles within the workbook for a given SheetVisibility. By default this will only return the visible sheets

    Parameters

    Returns SheetRef[]

  • Return the current transaction store for the workbook.

    Returns TransactionStore

    Remarks

    Custom transaction stores must be provided via the constructor.

  • Indicates if the model has been closed

    Returns boolean

  • Begins a transaction but puts it onto a global stack. This will batch all 'transactional' changes until they have all be committed or rolled back.

    Parameters

    • Optional description: string

    Returns ITransaction

    Remarks

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

  • Determine if dates should be 1904 instead of 1900 based

    Parameters

    • is1904Date: boolean

    Returns void

    Default Value

    false
    
  • Set the sheet to active. If this sheet was not Visible it will be made visible Fires onWorkbookSelectionChange

    Parameters

    Returns ISheetModel

  • Set the protection for the workbook.

    Parameters

    Returns void

    Remarks

    Pass null to clear all protections.

  • Set the current theme

    Parameters

    Returns IDocTheme

    Remarks

    If null sets back to the default theme. This will not fire theme updated event.

  • Views have their own lifecycle because in a collaborative environment each user can have their own view.

    Parameters

    Returns void