Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

JQuery fetching Excel Services data from app web

$
0
0

I have a project where I'm trying to fetch the contents from and Excel Spreadsheet in my SharePoint-Hosted app. I was trying to use JQuery to do it. (all the online documentation seems to point to a excel web part for using EWA).

I can use rest to get the spreadsheet data using this syntax:  https://[tenant].sharepoint.com/_vti_bin/ExcelRest.aspx/Shared%20Documents/users.xlsx/model/ranges('users')?format=atom

In a simple javascript sample here, I get html returned from the host web which asks me to request access to the site....

in the default.aspx of my SharePoint hosted app, I added the following JavaScript:

<scripttype="text/javascript">

        $(document).ready(

function() {

varrequestUri = _spPageContextInfo.siteServerRelativeUrl;

            requestUri +=

"/_vti_bin/ExcelRest.aspx/Shared%20Documents/users.xlsx/model/ranges('users')?format=html";

            $.ajax({

                type:

"GET",

                headers: {

"ACCEPT":"application/json;odata=verbose"},

                url: requestUri,

                contentType:

"text/html; charset=utf-8",

                dataType:

"html",

                success:

function(data, status) {

                   

varuserData = data;

                    alert(

"OK");

                },

                error:

function(xmlRequest) {

                   

varerror = xmlRequest;

                    alert(

'error: '+ xmlRequest.status +' \n\r '+

                    xmlRequest.statusText +

'\n\r'+

                    xmlRequest.responseText);

                }

            });

        });

</script>

I'm sure that I'm missing some security setting but I cannot find out what it is.

Any ideas?


Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>