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: 

38 thoughts on “Bookmarklet for Creating a CSV From an HTML Table

  1. B

    Hello, when I click on the Export to CSV link (after clicking the bookmarklet), the resulting csv file only contains the first column.

    All of my tables have only two columns with the left column acting as a “header” and right column containing data/values.

    I am using Chrome (on Windows), with Confluence 5.8.8.

    Any help would be appreciated. Cheers!

    Reply
  2. Tom

    Thanks for this — works as advertised with OS X Chrome.

    Thoughts on why it doesn’t work with Safari?

    Thanks again!

    Reply
  3. Luke

    There seems to be a problem with exporting tables that contain merged cells.

    I have a LOT of merged cells in the table I want to export, since it would be very confusing to look at otherwise. But the bookmarklet doesn’t seem to be very friendly with merged cells. I doubt that can be fixed, can it?

    Works just fine for “normal” tables though, so thanks anyways

    Reply
    1. davin Post author

      Hmm … not sure how the best way would be to handle tables with merged cells as those would not translate nicely to csv. I’ll think on it.

      Reply
  4. Ike

    Brilliant. This makes getting data out of Confluence “Page property report” macros a painless task. Thank you!

    Reply
  5. Robert V

    Thank you very much. You saved my bacon. I am a non-technical PM and was gnashing my teeth trying to sum up our progress for management until I found your utility.

    Reply
  6. Dmitry

    Hey there,

    great job! Just one thing: could you publish a version with “;” as separator instead of “,”? I found the part in the code but can’t figure out how to change it in the boomarklet 🙁

    Best Regards
    Dmitry

    Reply
  7. Kelly B

    I thrashed for a bit trying to find a solution until I found your bookmarklet. Worked great with Chrome Version 53.0.2785.143 (64-bit) — thank you!

    Reply
  8. Martins

    I seem to have encoding issues. My confluence is set to UTF-8 in general settings, and if I understand it correctly, your script is supposed to export UTF-8, but the export clearly has some artifacts, and it does not match what I see on the screen in confluence. Even  s are replaced with  . Is there a way you could help me troubleshoot this?

    Reply
  9. Sheila

    Hi. This has been very useful, but for some reason I now cannot “drag and drop” the export to cvs bookmarklet to my favorite bar. I am using IE, but in other browsers I was unable also. This was not a problem previously. Do you have any suggestions for help or where I can find something similar.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *