Skip to content

Plugin: ExportFile

Description

The ExportFile plugin lets you export table data as a string, blob, or downloadable file.

Supported formats:

  • CSV ('csv') — synchronous, no additional setup required.
  • XLSX ('xlsx') — asynchronous (returns a Promise). Requires the ExcelJS library to be passed as the engine option in the plugin settings.

See the export file demo for examples.

Example

import ExcelJS from 'exceljs';
const hotRef = useRef(null);
...
<HotTable
ref={hotRef}
data={getData()}
exportFile={{ engines: { xlsx: ExcelJS } }}
/>
const hot = hotRef.current.hotInstance;
const exportPlugin = hot.getPlugin('exportFile');
// CSV — synchronous
exportPlugin.exportAsString('csv');
exportPlugin.exportAsBlob('csv');
exportPlugin.downloadFile('csv', { filename: 'MyFile' });
// XLSX — asynchronous
await exportPlugin.downloadFileAsync('xlsx', { filename: 'MyFile' });