Home Ask Login Register

Developers Planet

Your answer is one click away!

AlexB February 2016

Excel Task Pane add-in to show content from external source

I am trying to build an Excel/Word task pane add-in that should show content from our site. The content/data is passed in XML format.

What I have tried to do is the following:

Office.initialize = function (reason) {
    $(document).ready(function () {

        $.support.cors = true;

        var data = '';

            type: "GET",
            contentType: "application/json; charset=utf-8",
            url: 'http://addons.mysite.com/excel-taskpane-data.php',
            data: data,
            dataType: "json",
            success: onQuerySuccess,
            error: onQueryError

        function onQuerySuccess(res, statusText) {
            console.log('success!!' + res.statusText);
        function onQueryError(res, statusText){
            console.log('failed!!' + res.statusText);



As you can understand from the code above I was just checking if connection could be made to the external source, but I am getting "Access Denied" in the console.

I am not really sure how should I request data from an external source and whether it is possible at all?

Please help


Michael Saunders February 2016

Yes, you can make Ajax HTTP requests from Office web add-ins such as your Excel/Word task pane. They work exactly the same as they would on a normal web page, except we have an additional requirement of using "https" rather than "http" to access the endpoint.

I can't identify the cause of your specific issue without information about the actual endpoint you're calling. Start by just trying your code on a normal web page and access it normally with a web browser. Once you have that working, then point an add-in to the page. That should fix your issue, but if you still have a problem where the exact same code is working in a normal browser and failing in an add-in, let us know.

Benoit Patra February 2016

You mentioned 'external' so I bet http://addons.mysite.com/ is not the domain that serves your web add-in. To make it work you have to check several things.

  1. Serving with Https. As written by Michael make sure you use https. Mixed content (mixing of http and https) is blocked by most server and Office web add-ins can only be served with https.
  2. Make sur your PHP web api supports CORS. I am no PHP expert so here is a small link
  3. Try to specify https://addons.mysite.com as AppDomain The sandboxed iFrame allow only request and navigation on the same domain (the one that you use to serve you web-addin). But you can specify some exceptions see here. It works with navigation and I am not sure it works with XHR...
  4. If step 3 did not work try to use JSON/P techniques as described here JSON/P with Office add-ins

Post Status

Asked in February 2016
Viewed 1,559 times
Voted 13
Answered 2 times


Leave an answer

Quote of the day: live life