OfficeDev/Excel-Add-in-Bind-To-Table

Name: Excel-Add-in-Bind-To-Table

Owner: Office Developer

Description: Demonstrates how to use the JavaScript API for Office to bind an app to a named table in Microsoft Excel 2013 or Microsoft Word 2013, extract data from the table, react to events in the table, and set data back into the table.

Created: 2015-08-14 17:59:03.0

Updated: 2017-12-06 07:21:25.0

Pushed: 2018-01-31 20:32:26.0

Homepage: null

Size: 744

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Excel-Add-in-Bind-To-Table

Demonstrates how to use the JavaScript API for Office to bind an add-in to a named table in Microsoft Excel 2013 or Microsoft Word 2013, extract data from the table, react to events in the table, and set data back into the table.

Description

This add-in code sample binds a Stock Ticker add-in to a named table that is included in the solution project. The code that uses the Binding object of the JavaScript API for Office is included in the UpdateTable.js file of the solution. The code sample binds to a table named “Stocks” on the worksheet labeled “Sheet1.”

The sample demonstrates how to establish a binding between a region in an Office file ?a named table, in this case? and an add-in for Office. Once the binding has been established, the add-in adds a handler to the BindingDataChanged event of the binding. When the event handler executes, the add-in retrieves a selection of the data from the table. It then removes the event handler from the binding, updates the table, and then adds the event handler back to the binding.

For more information about the JavaScript API for Office and working with bindings, see Binding to regions in a document or spreadsheet.

Prerequisites

This sample requires the following:

Key components

The Stock Ticker sample add-in app contains the following:

Configure the sample

To configure the Stock Ticker, set the StartAction -> Start Document property of the CodeSample_BindingAppToTable project to 'Stocks.xslx'.

Build the sample

Choose the F5 key to build and deploy the add-in.

Run and test the sample

  1. Choose the F5 key to build and deploy the add-in.

  2. Insert the add-in into the Stocks.xlsx file when you debug the sample (Insert tab, Add-ins for Office button).

    Note

    If you save the workbook while debugging, the add-in is persisted in the workbook. If you do so, you won't have to reinsert the add-in into the workbook during future debugging sessions.

  3. In the add-in, choose Set binding.

  4. In the table on Stocks.xlsx, make a change to one of the values in the first column in the right.

Troubleshooting

If the app fails to install, ensure that the XML in your CodeSample_BindingAppToXLTable.xml file parses correctly.

If you change the code in the StockTicker.getStockQuotes method to call an external stock quote service, be aware that cross-domain scripting restrictions still apply.

If the app generates errors whenever you try to update the table, ensure that you have entered correct values for the tableName and bindingName variables in the UpdateTable.js file.

Change log

Related content

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.