csvFlash
Create and save a CSV file that contains the data from the table (Adobe Flash - deprecated).
Please note - this property requires the Buttons extension for DataTables.
Deprecated
As of v1.2.0 this feature has been deprecated. This feature has not yet been scheduled for removal, but its use is discouraged and the alternatives discussed below should be used.
As Flash is now being expunged from all browsers, the Flash buttons are only suitable for use in old browsers. As such, they will no longer see new features developed for them after Buttons 1.2.0. They will be removed from the distribution in the next major release.
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.
Please note that this button has a number of restrictions:
- Adobe Flash must be installed.
- The action for this button cannot be activated using the
button().trigger()
or key combination methods due to the security restrictions of Flash - The created file save dialogue must be shown and the file cannot be automatically opened.
The csvHtml5
method provides much greater flexibility and thus button is considered to be sunsetted, but is still provided for use with older browsers that do not support the APIs required for the csvHtml5
button type.
Adobe Flash is required for this button to operate. If Flash is not installed, or disabled, in the end user's browser this button will not appear. For a non-Flash alternative please see the csvHtml5
button type. Additionally the csv
will automatically select between this button and csvHtml5
depending on the features of the browser.
Options
This button can have the following options set in its configuration object to customise its actions and display:
Name | Type | Default |
---|---|---|
action | ||
Create and save a CSV file. | ||
className | buttons-csv buttons-flash | |
The button's class name. See | ||
customize Since: 1.1.1 | undefined | |
Function that can be used to modify the contents of the exported data. The function takes two parameters, the data as configured by the button and the button's configuration object. The value that the function returns is the value that will be used for the export. This can be particularly useful if you wish to add a company header or footer, description data or any other information to the exported data. As of Buttons 1.5.2 this function is passed three parameters:
| ||
escapeChar | " | |
Character to use as the escape character for CSV data. This will be prefixed to any data found in the fields which matches that set by the | ||
exportOptions | {} | |
Select the data to be gathered from the DataTable for export. This includes options for which columns, rows, ordering and search. Please see the | ||
extension | .csv | |
The extension to give the created file name. | ||
fieldBoundary | " | |
The character(s) used to enclose each field in the plain text representation of the table that is copied to the system's clipboard. This is automatically added at the start and end of each cell's data. | ||
fieldSeparator | , | |
The character(s) used to separate fields in the plain text representation of the table that is copied to the system's clipboard. | ||
filename | * | |
File name to give the created file (plus the extension defined by the | ||
footer | false | |
Indicate if the table footer should be included in the exported data or not. | ||
header | true | |
Indicate if the table header should be included in the exported data or not. | ||
newline | \n | |
The character(s) used to separate the lines of data. Please note that on Windows client's the default is | ||
text | CSV | |
The button's display text. The text can be configured using this option (see |
Examples
DataTables initialisation: Use the Flash CSV button:
$('#myTable').DataTable( {
buttons: [
'csvFlash'
]
} );
DataTables initialisation: Use the csv
button type to automatically select between the Flash and HTML button options.:
$('#myTable').DataTable( {
buttons: [
'csv'
]
} );
DataTables initialisation: Use the exportOptions
to save all data, regardless of filtering:
$('#myTable').DataTable( {
buttons: [
{
extend: 'csvFlash',
text: 'Copy all data',
exportOptions: {
modifier: {
search: 'none'
}
}
}
]
} );