英文:
Office Word Task Pane Add-in - Is it possible to save a file locally?
问题
我尝试在运行taskpane.js中的命令时将文件保存到本地。
这个示例:https://learn.microsoft.com/en-us/office/dev/add-ins/word/get-the-whole-document-from-an-add-in-for-word?tabs=powerpoint 仅将文件发送到另一个服务器。
我想要做类似的事情,但是希望文件被抓取并保存到本地。我在文档https://learn.microsoft.com/en-us/javascript/api/word/word.document?view=word-js-preview 中找不到SDK文档中的任何方法。
英文:
I have tried to save a file locally when running the command in taskpane.js.
This example: https://learn.microsoft.com/en-us/office/dev/add-ins/word/get-the-whole-document-from-an-add-in-for-word?tabs=powerpoint it only sends the file to another server.
I want to do something similar where the file is grabbed, but it is instead saved locally. I cannot find any method in the SDK in the documentation here: https://learn.microsoft.com/en-us/javascript/api/word/word.document?view=word-js-preview
答案1
得分: 1
抱歉,您所要求的内容不可能实现。Office 加载项是一个网络应用程序,它面临与网络应用程序相同的安全限制。网络应用程序无法访问本地文件系统(除了一些有限的例外,如 cookies)。因此,您不能以您所想的方式在本地保存文件。
英文:
I'm afraid that what you are asking is not possible. An Office add-in is a web application and it faces the same security restrictions as a web application. Web apps cannot access the local file system (except for a few limited exceptions, like cookies). So, you can't save a file locally in the way that you have in mind.
答案2
得分: 1
这在Windows Office和Web上的Office中是可能的,除非使用Firefox。您可以使用window.showSaveFilePicker()
。我尚未尝试将其与Office.context.document.getFileAsync
连接,但我不明白为什么它不会起作用。
英文:
This is possible for Windows Office and Office on the web, except when using Firefox. You can use window.showSaveFilePicker()
.
I haven't tried hooking it up with Office.context.document.getFileAsync
, but I can't see why it wouldn't work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论