Hello Question regarding embed url for excel files

Aithan Gimenez 25 Reputation points
2025-03-16T12:03:13.1666667+00:00

I tested displaying files via iframe specifically excel files like the code below.
the first iframe won't work, but the second iframe works for excel file?

  1. What's the scope or limitation for this embed links?
  2. I tried video, powerpoint, csv, text, pdf, and it all works via the first iframe url method, I'm just curious if this not only applies to excel files but to other files that I haven't tested yet? Do these apply for the following file types:
    a. Excel files (.xlsx, .xls, .xlsm, .xlsb) b. Word documents (.docx, .doc, .rtf) c. PowerPoint presentations (.pptx, .ppt) d. OneNote notebooks (.one) e. Visio diagrams (.vsdx, .vsd) f. Project files (.mpp)
  3. For your Information, the top iframe url method is the given embed code by sharepoint itself, so i thought it would work but it did not.
<h1>Excel embed</h1>
<iframe src="https://mydomain/personal/username/_layouts/15/embed.aspx?UniqueId=[uniqueId here]&action=view" width="640" height="360" frameborder="0" scrolling="no"></iframe>

<h1>Excel doc.aspx, sourcedoc instead of uniqueId, with action=embedview</h1>
<iframe src="https://mydomain/personal/username/_layouts/15/doc.aspx?sourcedoc=[uniqueId here]&action=embedview" width="640" height="360" frameborder="0" scrolling="no"></iframe>
Microsoft 365 and Office SharePoint Development
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2025-03-17T06:36:28.75+00:00

    Hi @Aithan Gimenez ,

    Per my test, I could reproduce your issue. We will need to use Doc.aspx?sourcedoc={uid} to dsiplay the excel. I would recommend you to genrate embed code by Excel spreadsheet. Please refer to the following steps

    1.Upload the Excel spreadsheet to the SharePoint Online document library first. 

    2.Open the Excel file in the Web browser (Excel Online) >> Click on File >> Share >> Embed.

    User's image

    3.In the Embed window, choose the content from the Excel spreadsheet you want to show, such as a Table, Range of Cells, or full workbook. You can customize further by setting other preferences by setting the respective checkboxes on the embed page. Copy the embed code generated once done.

    User's image

    And the generated code also use the format like your second url

    Refer to this Microsoft Documentation for further help in setting parameters to the HTML iframe code.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.