{hero}

csvHtml5

Since: Buttons 1.0.0

Create and save a CSV file that contains the data from the table (HTML5).
Please note - this property requires the Buttons extension for DataTables.

Description

This button provides the end user with the ability to save the table's data into a locally created Comma Separated Values (CSV) file. That file can then be used by variety of programs including spreadsheet and data analysis applications.

If your table has a header or footer with multiple rows, these will all be included in the export. If the header or footer contains colspan or rowspan cells, they will be filled in by an empty string, since CSV is a plain text file and has no way to represent cells that span over others.

Options

This button can have the following options set in its configuration object to customise its actions and display, in addition to those options which are available for all buttons (e.g. buttons.buttons.text):

Examples

DataTables initialisation: Use the HTML5 CSV button:

new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: ['csvHtml5']
		}
	}
});

DataTables initialisation: Use the csv button type to alias the HTML button options.:

new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: ['csv']
		}
	}
});

DataTables initialisation: Use the exportOptions to save all data, regardless of filtering:

new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: [
				{
					extend: 'csvHtml5',
					text: 'Copy all data',
					exportOptions: {
						modifier: {
							search: 'none'
						}
					}
				}
			]
		}
	}
});