Excel to HTML: publish a sheet as a table
When a schedule, price list or results sheet has to appear on a website, in a help center article or in a newsletter, retyping it cell by cell is slow and error-prone. This excel to html converter reads the workbook and writes a standard <table> with a <thead> built from the header row and one <tr> per data row, ready to paste into an HTML editor.
The markup contains no classes, inline styles or spreadsheet-specific attributes, so it picks up the styles of the page you paste it into. If you want a styled table out of the box, add one of the two built-in themes.
Example
A sheet named Schedule with the columns Day, Session and Room converts, with the default options, to:
<table>
<thead>
<tr>
<th>Day</th>
<th>Session</th>
<th>Room</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mon</td>
<td>Kickoff & goals</td>
<td>A1</td>
</tr>
</tbody>
</table>
Special characters such as &, < and > in cells are escaped, so text like Kickoff & goals displays correctly and a cell cannot inject markup into your page.
Layout options
- Auto – writes one flat table for a single sheet. When you tick Convert all sheets, it produces an outer table with one row per sheet: the sheet name in a
<th>and that sheet's table nested in the cell next to it. - Single flat table – always one table with a header row. Fine for one sheet; with several sheets it would squeeze the whole workbook into one very wide row, so convert sheets one at a time instead.
- Nested tables – for a single sheet, the same table in compact form with each row on one line (
<tr><td>Mon</td><td>…</td></tr>). The shorter markup is handy for email templates and CMS fields with size limits.
Styling options
No CSS outputs the bare table. Bordered adds a small <style> block above the table with collapsed 1px borders, cell padding, a blue header row with white text and a light highlight on row hover. Striped rows adds the same rules plus a light gray background on every second body row.
The style block targets the table, th and td selectors directly. That is convenient for a standalone page, but on a site with its own table styles it will affect other tables too. In that case pick No CSS and style the table through your own stylesheet or a class you add.
Web page or email?
For a web page or CMS, paste the table into the HTML or source view of the editor rather than the visual view, which would show the tags as text. For email, keep in mind that many mail clients drop or ignore <style> blocks, so borders and stripes may not survive; mail clients generally keep plain table structure. Test with the client your readers use.
The Preview tab renders the table as it will look in a browser. If you download while the Preview tab is active, you get a complete HTML page including the styling; from the Code tab you get the table markup alone.
What is carried over from Excel
Only cell values are converted. Fonts, fills, borders, column widths and conditional formatting are not read. Numbers appear as stored values without currency or thousands formatting, dates as YYYY-MM-DD, and a blank header cell becomes column1, column2 and so on, by position. Merged cells are not re-created as colspan or rowspan; the value appears only in the first cell of the merged range.
To build or edit a table by hand, the HTML table generator gives you a grid editor. If your data is already a CSV export, CSV to HTML does the same job from text, and Excel viewer lets you look through a workbook before deciding what to publish.
Privacy
The spreadsheet is read and converted inside your browser, and the file is not uploaded. Only the optional Save & Share feature stores content on our server.
Convert Excel to an HTML table in Python
Python has no built-in reader for .xlsx files; openpyxl is the usual choice. Load the workbook with data_only=True, otherwise a formula cell returns its formula text, such as =1+2, instead of the result saved in the file. iter_rows(values_only=True) then yields each row as a tuple of cell values. Empty cells come back as None, so replace them before you build the table, and pass all text through html.escape(). The example writes a small sample file first so that it runs as shown.
# pip install openpyxl
import html
from openpyxl import Workbook, load_workbook
wb = Workbook() # build a tiny sample file
wb.active.append(["product", "price"])
wb.active.append(["Tea & Code", 24.5])
wb.active.append(["Desk Lamp", None])
wb.save("sample.xlsx")
ws = load_workbook("sample.xlsx", data_only=True).active
print("<table>")
for row in ws.iter_rows(values_only=True):
cells = ("" if value is None else html.escape(str(value)) for value in row)
print(" <tr>" + "".join(f"<td>{cell}</td>" for cell in cells) + "</tr>")
print("</table>")
To turn a real workbook into a table without writing code, drop the file into the converter above.