Monthly Archives: October 2014

Bookmarklet for Creating a CSV From an HTML Table

We have a wiki at work that we use for documentation called Confluence. It has the ability to export pages to Word or PDF, but a lacking feature is the ability to take a table and export it for Excel. So, I decided to create a bookmarklet that will allow you to select an HTML table on any web page and create a CSV file from that table that can be downloaded to your machine. Below is the bookmarklet. Just drag it to your bookmarks toolbar. Then give it a shot by clicking the bookmarklet and the below example table should get a link right before it that says “Export to CSV”. Click that link and you will be prompted to download the CSV version of that table. Let me know if it is useful for you.

On thing of note, this will not work correctly in Internet Explorer 9 and below as IE will not allow data uri’s for anything other than images.

Bookmarklet:
Export to CSV <- drag this to your bookmarks toolbar

Update:
09/16/2016 – Now works with IE 10+.
04/19/2016 – Fixed issue with tables that have header cells not on top.

Example Table:

Heading 1 Heading 2 Heading 3 Heading 4 Heading 5 Heading 6
Data 1, 1 Data 1, 2 Data 1, 3 Data 1, 4 Data 1, 5 Data 1, 6
Data 2, 1 Data 2, 2 Data 2, 3 Data 2, 4 Data 2, 5 Data 2, 6
Data 3, 1 Data 3, 2 Data 3, 3 Data 3, 4 Data 3, 5 Data 3, 6
Data 4, 1 Data 4, 2 Data 4, 3 Data 4, 4 Data 4, 5 Data 4, 6
Data 5, 1 Data 5, 2 Data 5, 3 Data 5, 4 Data 5, 5 Data 5, 6
Data 6, 1 Data 6, 2 Data 6, 3 Data 6, 4 Data 6, 5 Data 6, 6

Bookmarklet Source: