Class: ExportFile

ExportFile

The plugin enables exporting table data to file. It allows to export data as a string, blob or a downloadable file in
CSV format.

See the export file demo for examples.

Example
const container = document.getElementById('example');
const hot = new Handsontable(container, {
  data: getData()
});

// access to exportFile plugin instance
const exportPlugin = hot.getPlugin('exportFile');

// export as a string
exportPlugin.exportAsString('csv');

// export as a blob object
exportPlugin.exportAsBlob('csv');

// export to downloadable file (named: MyFile.csv)
exportPlugin.downloadFile('csv', {filename: 'MyFile'});

// export as a string (with specified data range):
exportPlugin.exportAsString('csv', {
  exportHiddenRows: true,     // default false
  exportHiddenColumns: true,  // default false
  columnHeaders: true,        // default false
  rowHeaders: true,           // default false
  columnDelimiter: ';',       // default ','
  range: [1, 1, 6, 6]         // [startRow, endRow, startColumn, endColumn]
});

Methods

downloadFile(format, options)

Exports table data as a downloadable file.

Parameters:
Name Type Description
format String

Export format type eq. 'csv'.

options ExportOptions

Export options.

exportAsBlob(format, options)

Exports table data as a blob object.

Parameters:
Name Type Description
format String

Export format type eq. 'csv'.

options ExportOptions

Export options.

exportAsString(format, options)

Exports table data as a string.

Parameters:
Name Type Description
format String

Export format type eq. 'csv'.

options ExportOptions

Export options.

isEnabled(){Boolean}

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true than the ExportFile#enablePlugin method is called.

Returns: {Boolean}

Type Definitions

ExportFile.ExportOptionsobject

Properties:
Name Type Argument Default Description
exportHiddenRows boolean <optional>
false

Include hidden rows in the exported file.

exportHiddenColumns boolean <optional>
false

Include hidden columns in the exported file.

columnHeaders boolean <optional>
false

Include column headers in the exported file.

rowHeaders boolean <optional>
false

Include row headers in the exported file.

columnDelimiter string <optional>
&#39,&#39

Column delimiter.

range string <optional>
[]

Cell range that will be exported to file.