Easy Table To CSV Converter - jQuery table2csv
File Size: | 3.73 KB |
---|---|
Views Total: | 5086 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
Just another jQuery based table to csv converter & exporter that allows the user to download table records as a CSV file. Fast, lightweight and dead simple to use.
See also:
How to use it:
1. Import the latest version of jQuery library and table2csv.js into the html.
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"> </script> <script src="table2csv.js"></script>
2. Your HTML table must have thead
and tbody
elements:
<table class="table"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> </thead> <tbody> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> <tr> <td>John</td> <td>Doe</td> <td>80</td> </tr> </tbody> </table>
3. Export the HTML table to a CSV file.
$('table').table2csv();
4. Customize the file name. Default: table_records.csv
.
$('table').table2csv({ file_name: 'jqueryscript.csv' });
5. Specify the space (the number of rows) between header and body. Default: 1.
$('table').table2csv({ file_name: 'jqueryscript.csv', header_body_space: 0 });
This awesome jQuery plugin is developed by venkataramanab. For more Advanced Usages, please check the demo page or visit the official website.