Tutorial : How to convert Excel tables to HTMLRédigé par BENKIRANE Fatima Ezzahra, Publié le 11 Octobre 2020, Mise à jour le Samedi, 18 Juin 2022 21:39
In this tutorial, we will explore several methods to convert Excel data to HTML, determine the advantages and disadvantages of each and guide you step by step through the conversion process.
Creating a table in HTML can be tedious. You must consider each empty cell, write the lines perfectly and be careful not to introduce errors when copying and pasting. As soon as the merged cells are part of the picture, things become very complicated. Why waste so much energy when you can do it in less than two minutes ?
Fortunately, there is a simple way to create an HTML table. All you need is a spreadsheet software like Microsoft Excel. Excel has excellent table creation features. It is often the best way to manage a simple list or database. There are sorting, filtering, automatic input and calculated field’s features.
To view spreadsheet data in an HTML table, you can use the native Excel feature to convert spreadsheets to web pages. If the generated code doesn’t seem clean, you can try online HTML editors or use dedicated online tools to convert Excel sheets to HTML.
Let’s start by converting Excel sheets into HTML tables that you can add to your website.
We will first see how to convert Excel cells to HTML table using formulas .
If you have a dataset that you want to convert to html array format and copy it to an html editor, you can process as following:
- Enter Html tags in a cell range as shown below :
- Then , proceed to the next cell which in our example is « H1», and enter the following formula:
=D1 & E1 & A1 & F1 & E1 & B1 & F1 & E1 & C1 & F1 & G1
- Press « Enter» and drag the formula to the other cells :
- Then you have to copy these formula cells and paste them as a value in another location. To do this, select the formula cells and press Ctrl + C :
- Select an empty cell from the current spreadsheet or another worksheet. Then right-click to select the « Paste as Value» option from the pop-up menu. See the screenshot below :
- Then you can copy the cell range into an html editor and enter the <table><tbody>and <tbody></table> tags separately at the beginning and end of the string range. See the screenshot below :
We’re done! Excel cells have been converted into an html table.
Now we will see how to convert Excel table to HTML using « Save as web page» method .
Using this method, you can save an entire file or part of it, such as a selected range of cells or a chart, to a static web page (.htm or .html) so that everyone can access your Excel data on the web.
You can use this feature to convert an Excel sheet into an HTML document. However, it adds a lot of extra code that can be useless if you try to convert a simple table. If you are familiar with HTML coding, you can remove these additional lines.
For example you created a 2019 sales report in Excel and now you want to export a chart to your company’s website so that your colleagues can view browser without opening Excel :
Here are the steps to convert Excel to HTML using « Save as a Web page »
- Open the Excel spreadsheet you want to convert.
- Click on the « File» menu on the ribbon and select « Save as » in the left pane.
- Select the folder in which you want to save the HTML file that will be generated.
- The « Save as » dialog box opens . Click on « Save as» drop-down list and choose one of the following options :
- Web page (*.htm; *.html) : This type will save the entire file or selection on a web page and create a supporting folder that will store all the page support files including images, chips and background textures .
- Single File web page (*.mht; *.mhtml) : this type will save the entire file or selection in a single file with supporting files embedded in the web page.
- Select the « Whole file»option next to the « Save » option in case you have multiple worksheets. If it is a simple table, select « Select: Sheet » :
- Click the « Publish» option and this will open the « Publish as a web page » dialog box .
- Select the portion(s) of your Excel file that you wish to export to a web page from the “Items to Publish” menu.In the drop-down list next to “Choose”, you have the following choices :
- Previously published items: you can select this option if you want to republish a spreadsheet or items that you have already published. If you prefer not to republish a certain item, select the item from the list and click the « Delete» button :
- Entire file : If you select this option the entire file will be published, including all spreadsheets and tabs to navigate between sheets .
- Entire worksheet or certain items : such as pivot tables, graphs, filtered ranges, and external data ranges. To do this, select « Items on SheetName » , then select « All contents » or specific items :
- Range of cells : Select this option in the drop-down list and then click on the « Collapse dialog» icon to select the cells you want to publish .
- Click the « Edit» button next to « Title : » and enter the desired title . This will add a title to the web page that will be displayed in the browser title bar :
- Click the « Browse » button next to « File name » and select the hard drive, folder, web folder, web server, HTTP site or FTP location where you want to save the generated web page.
- Select «AutoRepublish every time this file is saved» if you want to have the file or selected items automatically republished after each saving of the file :
- Select the "Open published Web page in browser" check box in case you want to view the web page right after saving.
- Click the Publishbutton and you are done!
Note : If you want to convert an Excel file to HML file for the first time, it is a good idea to save the web page on your local hard drive first so that you can make the necessary corrections before publishing the page on the web or on your local network.
In the following section , we will explain how to convert an Excel table to Html using an Html editor .
If you often need to export your Excel tables in HTML format, the two methods we have just explored may seem a bit too long.
The simplest method is to copy the cells from your Excel sheet and paste them into an HTML editor. This will automatically generate the required code for the HTML table. Here are the steps in detail:
- Open your excel sheet. Copy the cell range containing your data. You can use the Ctrl + Ckeyboard shortcut or right-click and select « Copy » :
- Now open any HTML editor. You can also use online HTML editors such as https://html-online.com/editor/. Open it and paste the copied cells into the box on the left side. Immediately when you paste it, the editor will generate your HTML code for the table as shown below :
- Now simply copy the HTML code generated by the Html editor and paste it onto your web page.
- Then you can edit the web table as you wish. The first thing to do is probably to remove the HTML Office formatting which is also copied and which you probably don’t need and makes the generated HTML code more difficult to read.
After converting an Excel spreadsheet to a web page, you can access the Html code to edit or copy it. To do this, follow the steps below:
- Navigate to the folder where you saved the HTML file .
- Then double click on it to preview the file in a browser.
- To copy the HTML code, right-click the file and choose « Open with».
- Select your HTML editor if it is installed on your PC or choose a standard text editor such as Notepador its alternatives:
Here is an overview of the appearance of HTML code using this method :
In this last section we will see some online tools to convert Excel to html table .
Another simple and quick method is to use an Excel to HTML converter, online or on the desktop. There are various online tools that allow you to convert your Excel documents to HTML. You simply need to import your Excel spreadsheet and they will display the HTML code. We will give you three examples of websites. Let’s check the steps for each :
Tableizer is an online tool for converting Excel tables to HTML. This online converter easily manages simple Excel tables with one click.
Simply copy your Excel table and paste it into the corresponding area and click on the « Tableize it! » button as shown below:
After that, simply copy the HTML code generated by the Tableizer converter and paste it to your web page. The best thing about using this tool (more than speed, simplicity and gratuity) is the preview window that shows what your Excel table will look like online:
The good thing about Tableizer is that the formatting is done with styles leaving the table data as clean as possible. It is simple to copy the code and then modify or delete the table layout.
As with all online tools, it may not work with large amounts of data and you may not want to use it with confidential data.
Now we will see another online converter tool .
- Launch https://conversiontools.io/convert/excel-to-html on your browser:
- Click on the « Browse» button, go to the Excel document you want to convert. You can also drag and drop the file:
- The « Run conversion» button will activate. Click on it to begin the conversion process:
- Click on « Download file » to download the generated file to your computer :
- To view the HTML code for the downloaded file, follow the steps mentioned above in the
« View web page code» section. To repeat, open the page in a standard text editor to display its code (here we used Notepad++) :
The use of this HTML converter is free. All you need to do is download your XLS, XLSX or ODS file and click on «Start conversion »:
Of course , the converter also supports any file you store on a cloud service such as Dropbox and Google Drive.
After a short time, you can download the converted file :
If you open the file directly in a browser, you can already see your table. Our result is displayed in the screen below (open in Google Chrome). It has perfectly preserved the shaping and fusion of the cells:
If you open the file in a text editor, you can copy the HTML code from the table and add it anywhere on your website. Here , we opened it in Notepad ++:
We explored a few options to convert Excel spreadsheets to HTML. Hopefully this will help you choose the technique according to your priorities - speed, cost or quality? The choice is always yours.