Office.context.document.getFileAsync不适用于Word应用程序中的在线办公室 [英] Office.context.document.getFileAsync is not working for office online in word application

查看:197
本文介绍了Office.context.document.getFileAsync不适用于Word应用程序中的在线办公室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我们正在开发Office 365的加载项。主机是字和功率点。我们几乎完成了它的开发,并在不同版本的桌面客户端和mac和windows的实时办公室中进行了测试。它
在所有地方工作得很好,但只在Windows上的现场办公室表现异常。而且非常精确地说它在网上言语异常。在深入研究这个问题后,我们确定了根本原因,这是一个微软内置库
的声明,名为office.js




Office.context.document.getFileAsync(" pdf",{sliceSize:65536},function(fileResult){





当我们使用我们的加载项进行word在线调试时去执行这个调用,它卡住了在任何地方都没有任何回应。在powerpoint online中它完美无缺,并且在mac和所有桌面客户端上都可以完美地适用于两个主机。



在寻求微软文档的帮助时,我来到这个链接:



https://dev.office.com/reference/add-ins/shared/filetype-enumeration#support-details



表示Word-Office Online(在浏览器中)缺少"Y"。我认为这是我们问题的根本原因。



请告诉我们我们的假设是否合适?



如果它是正确的,那么就解决这个问题。是否有一些可靠的解决方案或方法可以尽快解决这个问题。



我们计划在上周发布我们的插件,但我们因此而陷入困境。



请大家帮忙。



问候,



Azhar Majeed

Hi,

We are undergoing the development of an add-in of Office 365. Its hosts are word and power-point. We are almost done with its development and tested it on different versions of desktop clients and in live office for mac and windows as well. It is working perfectly fine everywhere but behaving abnormally only in live office on windows. And to be very precise it abends in word online. After digging into the problem we pin point the root cause which is this statement of a microsoft built-in library called office.js

Office.context.document.getFileAsync("pdf", { sliceSize: 65536 }, function (fileResult) {


When we use our add-in for word online debugger go to execute this call, it stuck somewhere and respond nothing. In powerpoint online it works perfect and on mac online and all desktop clients it works for both hosts perfectly.

On seeking help from microsoft documentation I came accross this link:

https://dev.office.com/reference/add-ins/shared/filetype-enumeration#support-details

which shows that "Y" is missing against Word - Office Online (in browser). I perceive it as root cause of our problem.

Please let me know either our assumption is right or not?

If it is right then give some resolution to this problem. Is there some solid solution or way around available to solve this issue as soon as possible.

We had plan to release our add-in last week but we are stuck just because of this.

Kindly assist on this.

Regards,

Azhar Majeed

推荐答案

Hello Azhar,

Hello Azhar,

根据  https://dev.office.com/reference /add-ins/shared/document.getfileasync

iPad上的Word | Office.FileType.Compressed,Office.FileType.Text |

Word on iPad|Office.FileType.Compressed, Office.FileType.Text|

因此Word Online中支持Office.FileType.Pdf。

So Office.FileType.Pdf is supported in Word Online.

以下代码适用于我。我添加一个断点来检查结果状态。它成功显示以PDF格式获取文件。 请测试代码是否适合你。

And the following code works for me. I add a breakpoint to check the result status. It shows successfully to get the file in PDF.  Please test if the code works for you.

 function downloadPDF() {
        Word.run(function (context) {
            
            // Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
            return context.sync()
                .then(function () {
                    Office.context.document.getFileAsync(Office.FileType.Pdf,
                        function (result) {
                            if (result.status == "succeeded") {
                                var myFile = result.value;
                                var sliceCount = myFile.sliceCount;
                                showNotification("File size:" + myFile.size + " #Slices: " + sliceCount);
                                // Now, you can call getSliceAsync to download the files, as described in the previous code segment (compressed format).

                                myFile.closeAsync();
                            }
                            else {
                                showNotification("Error:", result.error.message);
                            }
                        }
                    );
                });
        })
            .catch(errorHandler);
    }

问候,

Celeste


这篇关于Office.context.document.getFileAsync不适用于Word应用程序中的在线办公室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆