{hero}

excel

Since: Buttons 1.0.0

Create and save an Excel CSV file that contains the data from the table.
Please note - this property requires the Buttons extension for DataTables.

Description

This button type serves as a proxy that will automatically detect if the excelHtml5 button can be used based on the browser's capabilities and the libraries available on the page.

This is provided as an option since the HTML5 button type requires a reasonably modern browser which may not always be available to the end user.

If the requirements of the excelHtml5 button are not satisfied, no button will be presented to the end user. For the requirements of each button type, please refer to its own documentation.

Styling and customisation

For information on how you can customise the created XLSX file, please refer to the Customisation section in the excelHtml5 button documentation.

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 excel button type to automatically alias the HTML button options.:

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

DataTables initialisation: Use the exportOptions to save only the data shown on the current DataTable page:

new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: [
				{
					extend: 'excel',
					text: 'Save current page',
					exportOptions: {
						modifier: {
							page: 'current'
						}
					}
				}
			]
		}
	}
});