ExportFile
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 aPromise). Requires the ExcelJS library to be passed as theengineoption 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 — synchronousexportPlugin.exportAsString('csv');exportPlugin.exportAsBlob('csv');exportPlugin.downloadFile('csv', { filename: 'MyFile' });
// XLSX — asynchronousawait exportPlugin.downloadFileAsync('xlsx', { filename: 'MyFile' });