How to Convert an Excel Spreadsheet to an HTML Table
There are two ways to convert an Excel spreadsheet file to an HTML table. One is to create the table using the webpage wizard built into Excel. The main caveat is that the output file requires extensive clean up before it can be embedded in your website.
The other way is to use the Had2Know.org CSV to HTML converter (linked here and explained below) to convert a plain text spreadsheet (.csv instead of .xls or .xlsx) into HTML code. To use this method, the spreadsheet cells cannot contain any commas. Both methods are explained below.
Method 1Click the office button (Excel 2007 and later) or the File tab (Excel 2003) and click Save As. In the drop down menu you will see Webpage as one of the file formats. Select this option and save the file to your desktop.
After you save the file as a webpage, right click on it and select Open With, then choose Notepad or another plain text editor. You will now see the HTML code of your spreadsheet in the form of an HTML table, plus a lot of other code that needs to be deleted.
Look for the <table ...> tag after the <body> tag. Delete all the code preceding the <table> tag, including the <body> tag. Now look for the </table> tag before the </body> tag. Delete all the code after the </table> tag, including the </body> tag.
Next, look at the style codes within the <table> and <td> tags. You may see style attributes such as height="", width="", style="", align="" or class="". These should be deleted so you can replace them with your own CSS style properties.
Finally, look at the remaining code between the <table> and </table> tags. If you see any <col ...> tags, delete them. If you see <![if ...]>
and <![endif ...]> tags, delete them and everything between them.
The only pairs of HTML tags that should remain are
The HTML code is now in a form that can be embedded in another webpage.
Method 2Check the cells of your spread sheet to make sure that none of them contain commas. If they do, replace the commas with another symbol or simply delete them. At the end of this process you can re-add the commas to the cells of the HTML table.
Click the Office button or the File tab and click Save As. In the drop down menu, look for the option that says CSV Comma Delimited. Select this option and save the file to your desktop.
Right click on the file and select Open With, then select Notepad or another plain text editor. You will see a plain text document where the cells are separated by commas and spreadsheet rows are separated by line breaks. Make sure that none of the rows ends with a comma.
Copy and paste the contents of this document into the Had2Know.org CSV to HTML Table Converter. The online tool will output the HTML code for a simple table that contains all of your spreadsheet data.
© Had2Know 2010