Embed Microsoft Word and Excel Documents in HTML Web Page

In most cases, a hyperlink is used to link word or excel documents on the web page that allow users to download these files on the local drive. Word or Excel documents can’t be displayed directly on the browser like PDF. The HTML tag can be used to embed PDF documents on the web page. But MS Office files are required a third-party service to embed word documents on the web page. This tutorial will explain how to embed MS word and excel files on the web page using HTML.

The Office Web Viewer service is an easy and effective way to embed Word and Excel files in the HTML page and display word/excel documents on the browser. You can display word and excel documents in the HTML web page using the Office Web Viewer link.

Some advantages of the Office Web Viewer link:

  • Embed word (doc/docx) files in HTML.
  • Embed excel (xls/xlsx) files in HTML.
  • Display .doc/.docx/.xls/.xlsx files on the web page.
  • View the word and excel documents from the website.

Create Office Web Viewer Link:
To embed MS Office documents in the HTML page, specify the document URL (absolute URL) in the src parameter of the Office Web Viewer link.

https://view.officeapps.live.com/op/embed.aspx?src=<Document_URL>

Note: The <Document_URL> should be an absolute URL of the document that you want to embed. Also, the document must be accessible publicly on the internet.

Embed Word and Excel File in HTML

The HTML iframe tag is used to display a web page in HTML. We will use <iframe> tag to embed word/excel document in HTML web page using Office Web Viewer link.

Use the following code to embed Word file in the HTML web page:

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=https://www.codexworld.com/files/Brochure.docx' width='100%' height='650px' frameborder='0'></iframe>

Use the following code to embed Excel file in the HTML web page:

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=https://www.codexworld.com/files/assignment-tracker.xlsx' width='100%' height='650px' frameborder='0'></iframe>

You can use the above code to embed and display all types of the Microsoft Office documents (.doc, .docx, .xls, .xlsx, .ppt, .pptx) in HTML.

Do you want to get implementation help, or enhance the functionality of this script? Click here to Submit Service Request

Leave a reply

keyboard_double_arrow_up