Microsoft Office

Overview

The Excel Adapter allows apps to use Excel as a local data editor. The app uploads tabular data into Excel, so that the user may view it and edit it in a familiar environment. Any changes can then be transmitted back to the app for validation, processing, auditing or long-term storage.

The Excel Adapter enables your app to interact with Excel in the following ways:

  • Send tabular data to Excel that will be inserted in a an empty worksheet in a new workbook.
  • Target a specific workbook and worksheet when sending data to Excel.
  • Specify custom location within the worksheet table and other options for the inserted data.
  • Subscribe for changes to the opened worksheet, receive and validate data in your app.

io.Connect Tab in the Excel Ribbon

The io.Connect Excel Adapter adds an "io.Connect" tab in the Excel ribbon which you can use to manually send a table region to you interop-enabled apps by pressing the "Send Region" button:

Send Excel Document

From the "Top Left" input field next to the "Send Region" button you can specify from which cell will region begins. The boundaries of the region that will be sent to your app are determined by the specified starting cell and the first empty cell horizontally (for rows) and vertically (for columns). If the "Live tracking" option is enabled, the Excel Adapter will send updates to your app automatically each time the value of a cell is updated.

To be able to receive and manage the Excel data in your interop-enabled app, you must register an Interop method with a specific object type in the method definition.

The following example demonstrates using the io.Connect JavaScript API to register an Interop method for handling Excel data:

// It's required to use this object type in order to be able to receive and manage Excel data.
const objectTypes = ["T42.ExcelPad.Receiver"];

// Method definition.
const definition = {
    name: "MyDataHandler",
    objectTypes
};

// Method handler.
const handler = (result) => {
    // Retrieving the name of the Excel file, the name of the sheet,
    // and the table data as a JSON.
    const { workbook, worksheet, dataAsJSON } = result;

    console.log(`Data received from Excel file "${workbook}" in sheet "${worksheet}".`);

    // The received data is represented as an array of objects.
    // Each object has a `row` property holding an array with the values of all cells in that row.
    // Empty cells in the row will hold `null` values.
    JSON.parse(dataAsJSON).forEach(data => console.log(data.row));
};

await io.interop.register(definition, handler);

It's possible to register multiple Interop methods for handling Excel data. If you register multiple methods, each from a different app, they can have the same or different names. If you register multiple methods from the same app, they must have different names. All registered methods must use the "T42.ExcelPad.Receiver" object type. To select a target app to which to send the Excel data, use the dropdown menu in the "io.Connect" tab. The menu displays all available Interop methods for handling Excel data and the names and instance IDs of the app instances that have registered them:

Available Methods