jQuery Plugin To Export Table Data To CSV File - table2csv

File Size: 83.8 KB
Views Total: 56280
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Export Table Data To CSV File - table2csv

Just another jQuery based table to CSV converter which exports your html table into a downloadable CSV file.

Licensed under the GLP-3.0.

See also:

How to use it:

1. Load jQuery library and the jQuery table2csv plugin when needed.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="src/table2csv.js"></script>

2. Export your table into a downloadable CSV file.

$("table").table2csv();

3. Parse and output your table data in CSV format.

$("table").table2csv('output', {
  appendTo: '#out'
});

4. Specify the file name.

$("table").table2csv({
  filename: 'table.csv'
});

5. General settings with default values.

$("table").table2csv({
  separator: ',',
  newline: '\n',
  quoteFields: true,
  excludeColumns: '',
  excludeRows: ''
  trimContent: true // Trims the content of individual <th>, <td> tags of whitespaces. 
});

6. Return the csv as a string instead.

$("#table").table2csv('return');

Changelog:

v1.1.6 (2021-11-06)

  • Update dependencies

v1.1.5 (2021-11-02)

  • Update dependencies

v1.1.4 (2019-10-20)

  • Add action to return the csv as a string

v1.1.3 (2019-01-18)

  • Add BOM to the metadata of the downloaded file

2018-09-16

  • Fix bugs found after introducing tests

2018-07-18

  • Change MIME type to csv

2017-11-04

  • remove log messages

This awesome jQuery plugin is developed by OmbraDiFenice. For more Advanced Usages, please check the demo page or visit the official website.