Tuesday, April 15, 2014

How To Create An Excel Data Sharing App

This post shows how easy it was to create the Excel Data Sharing app with the Flatmerge API and the Apps For Office API.

To create an Office App, download the Office Developer Tools for Visual Studio 2013 http://msdn.microsoft.com/en-us/library/office/dn510410(v=office.15).aspx. Install any updates. The current version is 1.1 (October, 2013), which has some very important updates. (1.0.1 is currently in NuGet and does not have some important features you will need.).

The Flatmerge Excel app is a "Task Pane App" which means it is an app that sits in a pane to the right of the Excel Window. Walk through the steps and Visual Studio will create your Hello World Task Pane app in just a few minutes http://msdn.microsoft.com/library/office/fp142161(v=office.15)#FirstAppWordExcelVS_Create.

The app interacts with Office (Excel in our case) through the Office Javascript API. The method getDataAsync is used to grab data from Excel and do something with it.

asyncResult.value.getDataAsync({ coerciontype: Office.CoercionType.Table, valueFormat: Office.ValueFormat.Formatted}, function (asyncResult2) {...


Here, we use the getDataAsync method and pass in the Table coerciontype option to specify the data as an Excel table, and the valueFormat: Formatted to use the formatted values instead of the raw data. This valueFormat option is new in V1.1 of the API, which makes it easy to get dates and times from Excel instead of the underlying integer date stored.

Flatmerge's upload API call takes in the Excel data and loads it up for sharing.
<form action="http://flatmerge.azurewebsites.net/Upload" method="post" enctype="multipart/form-data">
<input type="hidden" id="token" id="token" value="abcxyz" />
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="submit" />
</form>

(http://flatmerge.azurewebsites.net/Home/About)

This call is also asynchronous, but returns an initial success or failure result that is handled in the getDataAsync's callback and pops up a toast at the bottom of the Task Pane App. If the toast says "Upload successful", your Excel table can be shared with any other Excel user, or other apps easily.


Since the Office App is just HTML, Javascript, and CSS, it is easy to change colors, add logos, call external APIs, or do anything you want. 

When you create your own Office app, you can immediately install it locally and on friends and colleagues machines. Submit it to the Office App Store for public distribution http://dev.office.com

(The Flatmerge Excel Data Sharing App is free. Back us on Kickstarter)

No comments:

Post a Comment