{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.

This button requires a reasonably modern browser in order to operate (IE8 and 9 are not supported).

Browser support

The API methods used by this button are supported in the following browsers. If the browser being used does not support the requirements for this button, it simply will not be displayed.

  • Internet Explorer 10+
    • IE9 and older are not supported as they do not support the FileReader API available in newer browsers.
  • Edge: Yes
  • Chrome: Yes
  • Opera: Yes
  • Safari: No
    • Safari does not currently support the ability to download generated files (see WebKit bug 156056). As soon as this has been addressed in Safari it will be released here.

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:

$('#myTable').DataTable( {
	buttons: [
		'csvHtml5'
	]
} );

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

$('#myTable').DataTable( {
	buttons: [
		'csv'
	]
} );

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

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