50240

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

Question:

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.

<pre class="lang-js prettyprint-override">Excel.run(function (context) { var workbook = context.workbook; //workbook.load or something ? }

Answer1:

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 <a href="https://msdn.microsoft.com/en-us/library/hh622722%28v=office.12%29.aspx" rel="nofollow">WOPI</a> 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 <a href="https://developer.microsoft.com/en-us/graph" rel="nofollow">Microsoft Graph</a>. Files stored in OneDrive include a <a href="https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/driveitem#properties" rel="nofollow">webUrl</a> property. If you open this URL it will automatically open the file in the correct application (Excel, Word, etc).

Answer2:

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).

Recommend

  • What is dotnet5.4 and net451 in class library?
  • Static variables in Android
  • Using Servlets and HTML
  • Backbone.js getting callback of render, within the view
  • JSF - Keep Faces Messages after redirect from @PostConstruct
  • SQL Server - Querying sysobjects
  • How should i track Objs in use, C#
  • How to create closure in loop and store it in variable for later execution
  • Bloomberg Data… Why doesn't Application.WorksheetFunction.BDH work?
  • Apache POI 3.17 in OSGi
  • Position Userform differently for each ActiveCell Clicked
  • How to debug office add-in for mac?
  • HALF_PTR Windows data type
  • Open an application in a space using applescripts
  • Is it safe to accept URL parameters for populating the `url_for` method?
  • Scala: Function returning an unknown type
  • Why can't UI components be accessed from a backgroundworker?
  • In C what exactly happens if i use () to initialize a double dimension array instead of the {}?
  • LiveData is abstract android
  • Synchronize windows folders
  • as3-flash: any way to access all the instances placed in different frames from document class?
  • Looking for good analogy/examples for monitor verses semaphore
  • Why use database factory in asp.net mvc?
  • How to write order and limit within cakephp joins array
  • How do I get HTML corresponding to current DOM tree?
  • How to use carriage return with multiple line?
  • JQuery Internet Explorer and ajaxstop
  • JSON response opens as a file, but I can't access it with JavaScript
  • Sencha Touch 2.0 Controller refs attribute not working?
  • Cancel a live stream “fast motion” catch-up in Flash
  • QLineEdit password safety
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • Change an a tag attribute in JavaScript based on screen width
  • How to include full .NET prerequisite for Wix Burn installer
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Is it possible to post an object from jquery to bottle.py?
  • UserPrincipal.Current returns apppool on IIS