Can we load Excel file in Office.js Add-in

2019-03-02 18:24发布

I am trying to load a Excel file in Excel online.

By loading a file I mean lets say I receive an Excel file from a service which I need to show on the current workbook.

The file location can be a url or any folder in my site.

Excel.run(function (context) {
 var workbook = context.workbook;
 //workbook.load or something ?
}

标签: office-js
2条回答
放荡不羁爱自由
2楼-- · 2019-03-02 18:48

Add-ins are scoped to the document and are intended to extend the functionality of the Office application, not as a mechanism for opening documents themselves.

What you're describing is what WOPI is intended for. The WOPI protocol provides an interface between Office and the document storage.

While you can implement your own WOPI client, it isn't a trivial process. A far simpler approach is to leverage the user's OneDrive via Microsoft Graph. Files stored in OneDrive include a webUrl property. If you open this URL it will automatically open the file in the correct application (Excel, Word, etc).

查看更多
倾城 Initia
3楼-- · 2019-03-02 19:14

If you are looking to open an workbook through a link/path, that is not possible yet in the web add-ins as the scope of the add-in is limited to the workbook. It is something in our roadmap to support cross workbook scenario. If you are looking to embed the workbook in a browser, Marc's response has the answer (works for OneDrive, SharePoint only).

查看更多
登录 后发表回答