1
votes

I've developed a very simple taskPane add-in that I'd like to test in Excel Online. I used Visual Studio 2015 and Javascript Api for Office, and I started a new project Office/Sharepoint --> Then I selected the Task Pane option. The only thing I changed to the sample they build is in Home.js :

/// <reference path="../App.js" />

(function () {
    "use strict";

    // The initialize function must be run each time a new page is loaded
    Office.initialize = function (reason) {
        $(document).ready(function () {
            app.initialize();

            $('#get-crazy').click(getCrazy);
        });
    };

    // Reads data from current document selection and displays a notification
    function getCrazy(){
        Office.context.document.getFileAsync(Office.FileType.Compressed, {sliceSize: 2097152},
            function (result) {
                if (result.status === Office.AsyncResultStatus.Succeeded) {
                    console.log("I'm here :D ");
                } else {
                    app.showNotification('Error:', result.error.message);
                }
            }
        );
    }
})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <title></title>
    <script src="../../Scripts/jquery-1.9.1.js" type="text/javascript"></script>

    <link href="../../Content/Office.css" rel="stylesheet" type="text/css" />
    <script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>

    <!-- To enable offline debugging using a local reference to Office.js, use:                        -->
    <!-- <script src="../../Scripts/Office/MicrosoftAjax.js" type="text/javascript"></script>  -->
    <!-- <script src="../../Scripts/Office/1.1/office.js" type="text/javascript"></script>  -->

    <link href="../App.css" rel="stylesheet" type="text/css" />
    <script src="../App.js" type="text/javascript"></script>

    <link href="Home.css" rel="stylesheet" type="text/css" />
    <script src="Home.js" type="text/javascript"></script>
</head>
<body>
    <div id="content-header">
        <div class="padding">
            <h1>Welcome</h1>
        </div>
    </div>
    <div id="content-main">
        <div class="padding">
            <button id="get-crazy"> SURPRISE! </button>
        </div>
    </div>
</body>
</html>

I've also changed the manifest so its startAction points out to InternetExplorer and I'm using a sharePoint Developer site to open this Excel Online. When I run the code I get this messages:

XML5619: Incorrect document syntax.
Line: 1, Column 1
SEC7111: HTTPS security is compromised by res://ieframe.dll/http_500.htm
SEC7111: HTTPS security is compromised by res://ieframe.dll/ErrorPageTemplate.css
SEC7111: HTTPS security is compromised by res://ieframe.dll/errorPageStrings.js
SEC7111: HTTPS security is compromised by res://ieframe.dll/httpErrorPagesScripts.js
SEC7111: HTTPS security is compromised by res://ieframe.dll/info_48.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/bullet.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/bullet.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/down.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/down.png
SEC7111: HTTPS security is compromised by res://ieframe.dll/background_gradient.jpg

And when I press the button I only have this: Agave.HostCall.IssueCall. And I know it's 'stuck' in the getFileAsync function.. Could you please help me?

2

2 Answers

0
votes

Have you tried using a local copy of Excel, rather than Excel online, just to see if this is the problem?

0
votes

You should use office.js version 1.1, as getFileAsync() just supported by 1.1, so you shoud replace the "https://appsforoffice.microsoft.com/lib/1/hosted/office.js" by "https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js".