Options
All
  • Public
  • Public/Protected
  • All
Menu

An object that represents an open workbook in Excel.

Hierarchy

  • ExcelWorkbook

Index

Methods

activate

  • activate(): Promise<void>
  • Activates the first window associated with the workbook, bringing it in to focus.

    Note: activating a workbook deactivates the currently activated workbook.

    Returns Promise<void>

addEventListener

  • Adds a listener for the specified workbook-level event.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    throws

    EventError if specified event is not supported.

    Parameters

    • eventName: string

      Type of the workbook-level event to listen for.

    • listener: ExcelWorkbookEventListener

      Function called when the specified event occurs.

    Returns Promise<void>

  • Adds a listener that is called when the workbook is activated.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • eventName: "activate"

      Name of the event fired when the workbook is activated.

    • listener: WorkbookActivatedEventListener

      Listener function called when the event occurs.

    Returns Promise<void>

  • Adds a listener that is called when a worksheet is added to the workbook.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • eventName: "addWorksheet"

      Name of the event fired when a worksheet is added to the workbook.

    • listener: WorksheetAddedEventListener

      Listener function called when the event occurs.

    Returns Promise<void>

  • Adds a listener that is called when the workbook is closed.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • eventName: "close"

      Name of the event fired when the workbook is closed.

    • listener: WorkbookClosedEventListener

      Listener function called when the event occurs.

    Returns Promise<void>

  • Adds a listener that is called when the workbook is deactivated (i.e. another workbook is activated).

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • eventName: "deactivate"

      Name of the event fired when the workbook is deactivated.

    • listener: WorkbookDeactivatedEventListener

      Listener function called when the event occurs.

    Returns Promise<void>

  • Adds a listener that is called when a worksheet is deleted from the workbook.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • eventName: "deleteWorksheet"

      Name of the event fired when a worksheet is deleted from the workbook.

    • listener: WorksheetDeletedEventListener

      Listener function called when the event occurs.

    Returns Promise<void>

addWorksheet

  • Adds a new worksheet to the workbook.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Returns Promise<ExcelWorksheet>

    The worksheet that was created.

close

  • close(): Promise<void>
  • Closes the workbook.

    If the workbook has any unsaved changes, Excel displays a "Save" prompt before closing the workbook.

    Note: After calling this function, do not attempt to use this workbook or any child worksheet objects. Doing so will likely result in an AdapterError since the underlying object/file is no longer available.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Returns Promise<void>

getName

  • getName(): Promise<string>
  • Gets the name of the workbook.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Returns Promise<string>

    The workbook name.

getProperty

  • getProperty<T>(propertyName: string): Promise<null | T>
  • Gets the value of a property from the Excel PIA Workbook interface.

    Refer to the Workbook interface properties documentation for a list of valid property names. The property name is case-sensitive so be sure to enter it exactly as it appears in the documentation.

    Note: only properties that are a value type or a string are supported and can be retrieved using this function.

    throws

    AdapterError if the requested property is not a supported type, or if an exception is thrown by the adapter process, typically by the Excel PIA.

    Type parameters

    • T = any

      The type of the property whose value to get.

    Parameters

    • propertyName: string

      The name of the property whose value to get.

    Returns Promise<null | T>

    The value of the property or null if the requested property does not exist.

getWorksheetByName

  • getWorksheetByName(worksheetName: string): Promise<null | ExcelWorksheet>
  • Gets a worksheet with a given name.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • worksheetName: string

      The name of the worksheet to get.

    Returns Promise<null | ExcelWorksheet>

    The worksheet matching the provided name, or null if no matching worksheet was found.

getWorksheets

  • Gets all worksheets belonging to the workbook.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Returns Promise<ExcelWorksheet[]>

    All worksheets belonging to the workbook.

removeEventListener

  • Removes a previously added listener for the specified workbook-level event.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    throws

    EventError if provided listener function does not match any added event listener.

    Parameters

    Returns Promise<void>

save

  • save(): Promise<void>
  • Saves the workbook to disk.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Returns Promise<void>

saveAs

  • saveAs(filePath: string): Promise<void>
  • Saves the workbook to the file path provided.

    throws

    AdapterError if an exception is thrown by the adapter process, typically by the Excel PIA.

    Parameters

    • filePath: string

      Full path (including file name) where the workbook should be saved.

    Returns Promise<void>

Generated using TypeDoc