jQuery Plugin To Export Table To Other Document Types - tableExport

jQuery Plugin To Export Table To Other Document Types - tableExport
File Size: 12.3 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

tableExport is a lightweight yet customizable jQuery plugin for exporting your html table to other types of documents: CSV, XLS, TXT and SQL. You can specify which table columns to export. Custom filename and head/column delimiters are supported as well.

How to use it:

1. Include jQuery library and the jQuery tableExport plugin on the webpage as usual.

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

2. Create a list of links to export your html table to specified document types.

<ul>
  <li><a onclick="exportTo('csv');" href="javascript://">CSV</a></li>
  <li><a onclick="exportTo('txt');" href="javascript://">TXT</a></li>
  <li><a onclick="exportTo('xls');" href="javascript://">XLS</a></li>
  <li><a onclick="exportTo('sql');" href="javascript://">SQL</a></li>
</ul>

3. Initialize the plugin with default options.

function exportTo(type) {

  $('.table').tableExport();

}

4. Customize the file name.

function exportTo(type) {

  $('.table').tableExport({

    // table_26-05-2016
    filename: 'table_%DD%-%MM%-%YY%'
  });

}

5. Select specific columns to export.

function exportTo(type) {

  $('.table').tableExport({

    cols: '2,3,4'
    
  });

}

6. Customize the separators for titles and columns when exporting

function exportTo(type) {

  $('.table').tableExport({

    cols: '',
    head_delimiter: ';',

  });

}

7. Callback functions.

function exportTo(type) {

  $('.table').tableExport({

    onbefore: function(t){},
    onafter: function(t){}

  });

}

Change log:

2017-01-16

  • Fixed examples, add Bower.json and etc.

2016-12-01

  • Fixed code, so that the date parsing function is working

2016-11-29

  • fixed for firefox

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