Automate Simple Tasks with Python: Excel Table to HTML Table using the python Dominate Module


Sometimes a database is really not necessary. Why not try a simple excel sheet

Coded this in an hour; sips on coffee though 9:06:34 PM

I generated the excel workbook using a website called Mockaroo. Today’s task is to convert a basic excel sheet table into an HTML table. I broke the task into sub tasks which were then later translated into functions.



  1. Convert Excel Table into one dimensional List containing dictionaries
  2. Convert List into HTML document
  3. Save HTML string into a file with “.html” extension
  4. Done

The Excel Sheet looked like this:


The code generated an HTML table (using the style.css – see below) that looked like this:

The power of automation
The excel table data was extracted and converted into a simple table.

The files: excel style

This is the code

You could expand the code to make it more flexible like:

  • Getting the HTML file name from the command line
  • Create different tables based on different sheets in a workbook
  • Create different HTML files based on different workbook (in a given directory)
  • Convert HTML Table into Excel Sheet (well basically webscraping; using the python module: BeautifulSoup)

If you have any questions, write them in the comment section.

See you soon!

error: Content is protected !!