简体   繁体   English

Office getFileAsync函数的JavaScript API未调用回调

[英]JavaScript API for Office getFileAsync Function is not calling callback

I've developed a very simple taskPane add-in that I'd like to test in Excel Online. 我开发了一个非常简单的taskPane加载项,希望在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. 我将Visual Studio 2015和Javascript Api用于Office,并启动了一个新项目Office / Sharepoint->然后选择“任务窗格”选项。 The only thing I changed to the sample they build is in Home.js : 我更改为它们构建的示例的唯一内容是在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. 我还更改了清单,因此它的startAction指向InternetExplorer,并且我正在使用sharePoint Developer网站打开此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. 当我按下按钮时,只有这个:Agave.HostCall.IssueCall。 And I know it's 'stuck' in the getFileAsync function.. Could you please help me? 而且我知道它卡在了getFileAsync函数中。请您帮我一下?

您是否尝试过使用Excel的本地副本而不是在线Excel,只是为了查看这是否是问题所在?

您应该使用office.js版本1.1,因为1.1仅支持getFileAsync(),因此应将“ https://appsforoffice.microsoft.com/lib/1/hosted/office.js ”替换为“ https://”。 appsforoffice.microsoft.com/lib/1.1/hosted/office.js “。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM