1.0.0 • Published 8 years ago

datatables-export-document v1.0.0

Weekly downloads
53
License
MIT
Repository
github
Last release
8 years ago

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();

// Export to Word Document
// On element with id="btn-export" clicked
$('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: '...',
    
    // document title
    title: '...',
    
    // document description
    message: '...',
    
    // header title
    header: [
        'ID',
        'Name',
        '...'
    ],
    
    // field
    field: [
    	0,
    	1,
    	4,
    	5,
    	'...'
    ],
    // or
    field: [
    	'employe_id',
    	'name',
    	'....'    	
    ],
    
    // orientation (pdf and word only)
    'orientation' => 'landscape',
    
    // separator (csv only)
    'separator' => ','
    
    // for pdf only
    'download' => 'download' // or 'open' for preview
    'pageSize' => 'A4',
}