none
Office 13: Data retrival into Agave Pane RRS feed

  • Question

  • To show the data in Agave the data source should be in the same sheet which it is hosted on.

    If there is a requirement to pull data from any other sheet other than the hosted sheet, is it possible using Agave?

    What are the available options?

    • Moved by Hila ShemerModerator Thursday, July 19, 2012 9:07 PM This question is related to apps for Office (From:Office 2013 Preview for Developers)
    Wednesday, July 18, 2012 1:00 PM

Answers

  • Hi Prabhas,

    This a great question - Thanks for posting it!

    First, I'd like to mention that the official name is now apps for Office ("Agave" was a codename and we no longer use it to refer to the technology).

    Now back to your question - yes, it is possible to pull data from one Excel spreadsheet into an app inserted in a different sheet. The data source does not have to be on the same sheet the app is inserted to. The way to do it is by creating a Binding to the region in the spreadsheet you'd like to pull data from.

    What are Bindings? Bindings allow access to different data types such as text, ranges, and tables. Once a Binding is established, you can read and write to the bounded region without the user having to make a selection. You can access the Binding object and its contnent at a later time (it is also persisted in the document itself). Below is a code snippet showing how to create a new Binding and display its type and id in a DIV.

    Office.context.document.bindings.addFromSelectionAsync(Office.BindingType.Text, { id: 'myBinding' }, function (asyncResult) {
        if (asyncResult.status == Office.AsyncResultStatus.Failed) {
            write('Action failed. Error: ' + asyncResult.error.message);
        } else {
            write('Added new binding with type: ' + asyncResult.value.type + ' and id: ' + asyncResult.value.id);
        }
    });

    // Function that writes to a div with id='message' on the page.
    function write(message){
        document.getElementById('message').innerHtml += message + '<br/>';
    }

    To learn more, read our developer documentation on Binding to regions in a document or spreadsheet

    Thanks,

    Hila

    Thursday, July 19, 2012 6:11 PM
    Moderator