Skip to content

Instantly share code, notes, and snippets.

@randyburden
Last active November 8, 2021 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randyburden/25ad9a6a35a524180ff543ecb4b42069 to your computer and use it in GitHub Desktop.
Save randyburden/25ad9a6a35a524180ff543ecb4b42069 to your computer and use it in GitHub Desktop.
Export Table to CSV File

How to Export a Table to CSV

If you ever find yourself needing to export a table on a webpage you are viewing but they don't have a download or export to CSV button, use the following code to export the table to a CSV file.

  1. Use a Table to CSV browser extension like the following one. If that is not possible then following the instructions below:

  2. Open the browser's Developer Tools (F12 on Windows)

  3. Run the following command in the Console tab of the Developer Tools:

var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/table2csv@1.1.5/dist/table2csv.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

$(document).ready(function () {
  setTimeout(function() {
    $('table').first().table2csv();
  }, 200)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment