You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

datatables-export-document

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatables-export-document

Export your grid data to many document. Support doc, xls, pdf, csv, xml, html, and print out.

1.0.0
latest
Source
npm
Version published
Weekly downloads
47
-25.4%
Maintainers
1
Weekly downloads
 
Created
Source

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',
}

Keywords

datatables

FAQs

Package last updated on 24 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts