将文档从本地文件系统加载到Office Online [英] Load document from local filesystem to Office online

查看:261
本文介绍了将文档从本地文件系统加载到Office Online的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想直接从Word的本地文件系统中直接加载/保存文件(而不将其上传到onedrive).由于这不是默认功能的一部分,因此我试图确定是否可以通过插件来实现.

I would like to load/save a file directly from the local filesystem in Word online (without uploading it to onedrive). Since this is not part of the default functionality I am trying to determine if this would be possible with an addin.

加载部分:

Document 对象可访问body save方法,但是(对于我而言)有关负载的文档尚不清楚:Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

The Document object gives access to body load and save Methods however the documentation is unclear (to me) for load:Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

似乎有可用的选项,例如insertFileFromBase64insertOoxml,但不清楚它们是否仅在(Windows)桌面版本或在线版本中.参见问题

It seems there are options available like insertFileFromBase64 and insertOoxml but unclear if those are only in (Windows) Desktop version or also in Online version. See this question

保存部分:

这似乎更容易一些,因为已经具有Download功能来获取文档的副本.

This seems to be the easier bit as there already is a Download functionality to get a copy of the document.

不是在寻找完整的解决方案,只是有可能",也许还有一些指向使用哪种方法的指针.

Not looking for complete solution, just a "is it possible" and perhaps a few pointers to what methods to use.

推荐答案

可能我的回答有很多假设,如果我写错了,请更正我,但我认为您想做的是WORD加载项(任务窗格加载项),它具有以下功能:

probably I am doing many assumptions with my answer, please correct me if I am wrong but I think what you want to do is a WORD Add-in (a task pane add-in) that exposes the following functionalities:

  1. 将当前文档上载到OneDrive for Business(基本上就是您所说的"Office Online"或任何其他云存储库.
  2. 连接到OneDrive或任何云存储库并打开,使用户能够选择单词File并在当前文档或新文档上打开它.

,如果这两个假设是正确的,我认为您实际上可以构建具有此类功能的加载项.顺便说一句,请注意,在Word体验中,您实际上可以从OneDrive保存和加载Word文件,因此,我不确定我是否理解"这不是默认功能的一部分"的意思.

and if those 2 assumptions are correct, i think you can actually build an add-in with such functionalities. BTW note that within the Word experience you can actually save and load Word files from OneDrive, so i am not sure i understand what you mean by "this is not part of the default functionality" .

无论如何,这里是您可以使用API​​进行的操作

Anyways here is what you can do with API:

  1. 您可以获取当前文件,docx,pdf或txt 等效项,为此,您需要使用getFileAsync方法.这 方法会为您提供编码为base64的文件,然后您可以上传 无论您需要什么.您也可以根据需要对文件进行切片.这里 是如何使用API​​的好例子.. li>
  2. 打开当前文档中的文件.为此,有效地,您需要使用document.body.insertFileFromBase64方法.此方法适用于Windows,在线,Mac和iOS的Word.在此处中查看示例.
  1. You can get the current file, either the docx, pdf or txt equivalents, for this you need to use the getFileAsync method. This method gives you the file encoded as base64 and you can then upload it wherever you need. you can slice the file as well if needed. Here is a good example on how to use the API.
  2. To open a file in the current document. For this, effectively, you need to use the document.body.insertFileFromBase64 method. This method works in Word for Windows, Online, Mac and iOS. Check out a sample here.
  1. 最后有一个PREVIEW API,您可以尝试在其他窗口中实际打开文档.检查 createDocument 功能. (请注意,您需要使用预览API 如此处所述 ).
  1. Finally there is a PREVIEW api you can try to actually open the document in a different window. Check out the exercise #8 on this lab. Using the createDocument functionality. (note that you need to use the preview APIs as described here).

现在,为了连接到OneDrive并上传或获取文件以及浏览文件夹结构,您需要针对一个驱动器使用graph API. 这是一个很好的示例,说明了如何进行身份验证以及如何调用图.

Now in order to connect to OneDrive and upload or get files as well as navigating the folder structure you need to use the graph API against one drive. Here is a good example on how to authenticate and make calls to the graph.

我知道这是一堆信息,但是应该把您带向正确的方向.

I know this is a bunch of information but should put you in the right direction.

感谢和快乐的编码!

这篇关于将文档从本地文件系统加载到Office Online的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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