This sample is an app for Office that reads and writes OData data to documents in an Office host application, such as Excel. This article provides sample code and procedures that show you how to design an app for office. The languages used are C# and TypeScript. The tools used to setup the sample are Visual Studio and the Azure Portal.
Table of contents:
- Open the sample and open the ExcelODataInterface.sln file in Visual Studio.
- Click Start or press F5 in Visual Studio.
- The first time that you use F5, you are prompted to grant permissions to the app. Click Trust It.
- In Start Action, select Internet Explorer to use an Office Online client, or select Office Desktop Client, then select Start Document to specify the kind of Office document to test with.
- The app page will show at the Excel right pane, choose “Products”, then, click “Connect”.
- The data will load in the Excel sheet, we can delete, compare and save data by the buttons in our app.
Key components of the sample
The Visual Studio solution contains the following:
- ODSampleData project, which contains the app's manifest configured to support hosting the app in Excel 2013, Excel Online.
- ODSampleData Web project, which contains the following components: home.aspx The main page of the app ODataHelper.cs A C# file to consume and update data using the OData. It contains the following parts: Parsing metadata from OData Getting data form OData Updating data to Odata
- Diff.ts A TypeScript file for solving differences
- UX.ts , UXHelpers.ts, UX.BulgingDiffPage.ts, UX.DiffPage, UXList.ts for UI element and data object
Modify the sample for your needs
The following procedures can help you to use your own data source.
- Open the web.config file in the ODSampleDataWeb project and change the ''
- Set the value of your data source url.
In our sample:
<add key="ida:ODataEndpointURL" value="http://services.odata.org/V3/(S(omlwdrfviuvthgrncrmyko1m))/OData/OData.svc/" /> <add key="ida:ODataMetadataURL" value="http://services.odata.org/V3/(S(omlwdrfviuvthgrncrmyko1m))/OData/OData.svc/$metadata" />
The first value is the data source location, the second one is the data format.
You can use your own data by replace the values here.
Please follow these instructions to create a Excel Add-In of your own:
See [How to: Create your first task pane or content app with Visual Studio] (http://msdn.microsoft.com/en-us/library/office/fp142161(v=office.15).aspx) General work flow
- Office 'Add-In' requests available data feeds from OData via OData Helper on Azure
- OData Helper on Azure parses the metadata and send the table information to the Office 'Add-In'. UI Helper will render the data feeds.
- User choose a table and its columns to connect
- OData Helper on Azure retrieves data by OData Helper on Azure in JSON format
- OData Helper on Azure parses the JSON into arrays and send to Agave app. Excel Helper will write the data into Excel table.
- Excel Helper will read data from Excel. Diff Helper will analyze the changed and then send updated records to OData Helper on Azure
- OData Helper on Azure make batched OData call with JSON payload and send to OData
Copyright (c) Microsoft. All rights reserved.