Render/edit MS Office docs in browser with SharePoint or WOPI

1.6k Views Asked by At

I have a Rails application I want to do CRUD operation on user's documents online but I want to render MS Office (OpenXML-based) docs in the browser. I have heard about WOPI/SharePoint. How can I integrate it with my web app?

2

There are 2 best solutions below

2
On

What you're looking for is indeed called WOPI. To be precise, you want to integrate Office Online Server (WOPI client) with your application (WOPI host). This is how SharePoint's integration works as well (SharePoint plays the role of a WOPI host here).

You need to implement the following flow:

WOPI flow

Translated to your app - your Rails app will generate URLs pointing to the WOPI client and providing it with information about the MS Office files, authentication information, etc. Then, the WOPI client reaches for those files to your Rails app which will also need to implement the REST endpoints defined by MS-WOPI protocol (mainly CheckFileInfo, GetFile, and PutFile actions).

0
On

If you just want to provide view for the documents, that are publicily available, you could use office live viewer, or google docs viewer. You need to basically provide an URL to your document to those services.

I have found this site that has demos for online viewers currently available, you could check it out: https://xtai-umd.github.io/docs-viewer-demo/

SharePoint also has something called WopiFrame.aspx page (or WopiFrame2.aspx), that allows you to show documents like the site above, but with authentication. Please note that this will work only for the documents that are stored in the SharePoint (in the particular SharePoint where you use that WopiFrame.aspx, that is).

If you are developing SPFx web part, this is the way to go I think. Since in this case both are running in the context of SharePoint site, you don't really need to think much about security, it's all taken care of.

I mean, implementing your own WOPI server is not easy at all, and in addition to that you'll need Office Web Apps server, either installed on-premise in your organization, or the Microsoft's online one. To be able to use Microsoft's one you need to be a member of Cloud Storage program, as far as I know.

I would not recommend implementing custom WOPI server unless it is really needed for whatever reason (in my case, it was quite specific security requirements)