This page covers a next version of Handsontable, and is not published yet.

This page covers a non-latest version of Handsontable.

# ExportFile

# Description

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]
});

# Members

# ExportOptions

Source code (opens new window)

ExportFile.ExportOptions : object

Properties

Name Type Default Description
[exportHiddenRows] boolean false Include hidden rows in the exported file.
[exportHiddenColumns] boolean false Include hidden columns in the exported file.
[columnHeaders] boolean false Include column headers in the exported file.
[rowHeaders] boolean false Include row headers in the exported file.
[columnDelimiter] string "," Column delimiter.
[range] string "[]" Cell range that will be exported to file.

# Methods

# downloadFile

Source code (opens new window)

exportFile.downloadFile(format, options)

Exports table data as a downloadable file.

Param Type Description
format string Export format type eq. 'csv'.
options ExportOptions Export options.

# exportAsBlob

Source code (opens new window)

exportFile.exportAsBlob(format, options) ⇒ Blob

Exports table data as a blob object.

Param Type Description
format string Export format type eq. 'csv'.
options ExportOptions Export options.

# exportAsString

Source code (opens new window)

exportFile.exportAsString(format, options) ⇒ string

Exports table data as a string.

Param Type Description
format string Export format type eq. 'csv'.
options ExportOptions Export options.

# isEnabled

Source code (opens new window)

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

Last Updated: Nov 20, 2024