Add-In: Embedding SharePoint content in iframe (xls, PDF)

New Contributor

We try to embed SharePoint content in an iFrame. Therefore we use the GUID of the doc to build the ifram URL.


Tested with 3 different files.

  1. .pptx

Working fine.
Iframe-URL is


Everything is working fine. Preview is available.

  1. .xls

Iframe gets blocked.
Iframe-URL is


Browser shows the following message:

Refused to display 'https://..._layouts/15/WopiFrame.aspx?sourcedoc={51bf3f39-addc-48aa-b9a0-7bd1b56d9f07}&action=embedview&wdStartOn=1' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

Its exactly the same URL as before, just the query parameters are different (different GUIDs).
When URLs get opened directly in the browser, you can see a small redirect. 
The PPTX gets redirected to‌/:p/r/‌sites/.../_layouts/15/WopiFrame.aspx?....
The XLS gets redirected to‌/:x/r/‌sites/.../_layouts/15/WopiFrame.aspx?....


QUESTION: Why does it get handled differently? How can we get the .xls to show up?

  1. .pdf

Iframe gets blocked.
Iframe-URL is

"Refused to display 'https://.../Shared Documents?RootFolder=%2Fsites%2Fsmarterpathtestingsite%2FShared Documents' in a frame because it set 'X-Frame-Options' to 'sameorigin'."

As it seems the URL doesnt work at all, it redirects to the Folder-View of that Sharepoint-Site. The same behavior when the URL gets opened up in the browser directly.


QUESTION: Is there any way to embed a PDF like this? In our local Dev environment it was working fine.

4 Replies
¨Have you tried the file viewer WebPart?

We are having a SharePoint Online Add-In, it is not about integrating in SharePoint sites.

Use interactivepreview action option.



@Linda Werner  Have you tried this? And if yes, is it working??