Skip to main content
Access via:io.excel

Excel API.

Properties (2)

Property Type Default Required Description
addinStatus⚓︎ boolean x

Flag indicating the status of the Excel Adapter. If true, the Excel Adapter is available and you can use the Excel API.

sheets⚓︎ Sheet[] x

Retrieves all Excel worksheets currently tracked by the Excel Adapter, including worksheets opened by the app and worksheets discovered in Excel.

6 Methods

getWorkbooks()⚓︎

() => Promise<Book[]>

Retrieves all open workbooks in Excel.

getWorksheets()⚓︎

() => Promise<Sheet[]>

Retrieves all worksheets from all open workbooks in Excel.

onAddinStatusChanged()⚓︎

(callback: (connected: boolean) => void) => UnsubscribeFunction

Notifies when the Excel Adapter status has changed. Returns an unsubscribe function.

Parameters (1)

Name Type Required Description
callback⚓︎ (connected: boolean) => void

Callback function for handling the event. Receives as an argument a Boolean value indicating the status of the Excel Adapter.

Example

office.excel.onAddinStatusChanged((connected) => {
    if (connected) {
        console.log("Excel is available");
    } else {
        console.log("Excel is closed or addin is not working");
    }
});

onNewWorksheet()⚓︎

(callback: (sheet: Sheet) => void) => UnsubscribeFunction

Notifies when a new worksheet is discovered in Excel that wasn't previously opened by the app. Returns an unsubscribe function.

Parameters (1)

Name Type Required Description
callback⚓︎ (sheet: Sheet) => void

Callback function for handling the event. Receives the new worksheet as an argument.

openSheet()⚓︎

(sheetData: OpenSheetConfig) => Promise<Sheet>

Opens a new Excel worksheet.

Parameters (1)

Name Type Required Description
sheetData⚓︎ OpenSheetConfig

Configuration for opening the Excel worksheet.

Example

const options = {
    columnConfig: [
        { header: "Symbol", fieldName: "symbol" },
        { header: "Price", fieldName: "price" },
    ],
    data: [
        { price: 100, symbol: "AAPL" },
        { price: 200, symbol: "GOOG" },
    ],
    options: {
        workbook: "MyWorkbook",
        worksheet: "MyWorksheet",
    },
};

const mySheet = await office.excel.openSheet(options);
console.log(mySheet);

ready()⚓︎

() => Promise<API>

Resolves when the Excel Adapter has finished registering its internal Interop methods that provide the Excel API functionality. Resolves with the Excel API object.