DataTables Export Plugin
Export your grid data to many document.
Support doc, xls, pdf, csv, xml, html, and print
Example
var dt = $('#example-table').DataTable();
$('body').on('click', '#btn-export', function(e) {
$.fn.DataTable.Export.word(dt, {
filename: 'customer-lists',
title: 'Report',
message: 'Customer lists',
header: [
'ID',
'Name',
'Position',
'Join Date',
'Salary'
],
field: [
0,
1,
4,
5,
8
]
});
});
Export to other document types
To Word (.doc) $.fn.DataTable.Export.word(dataTable, config)
To Excel (.xml) $.fn.DataTable.Export.excel(dataTable, config)
To CSV (.csv) $.fn.DataTable.Export.csv(dataTable, config)
To PDF (.pdf) $.fn.DataTable.Export.pdf(dataTable, config)
To XML (.xml) $.fn.DataTable.Export.xml(dataTable, config)
To HTML $.fn.DataTable.Export.html(dataTable, config)
To Print $.fn.DataTable.Export.print(dataTable, config)
*) for pdf you must integrate pdfmake plugin (pdfmake.js and vfs_fonts.js)
Config
{
filename: '...',
title: '...',
message: '...',
header: [
'ID',
'Name',
'...'
],
field: [
0,
1,
4,
5,
'...'
],
field: [
'employe_id',
'name',
'....'
],
'orientation' => 'landscape',
'separator' => ','
'download' => 'download'
'pageSize' => 'A4',
}