Import and export
Handsontable DataGrid exports its data to Excel (.xlsx) and CSV files, and imports Excel workbooks. Two plugins do the work, with no library to install: ExportFile writes files, and ImportFile reads them. This page shows which guide covers your task.
Pick a guide
| Task | Format | Plugin | Guide |
|---|---|---|---|
| Download the grid as a workbook, with cell types, styling, and formulas | XLSX | ExportFile | Export to Excel |
| Load a workbook the user picked into the grid | XLSX | ImportFile | Import from Excel |
| Detect column types in CSV rows, pasted text, or API data | None; rows in memory | ImportFile | Infer column types |
| Download the grid’s values as text | CSV | ExportFile | Export to CSV |
| Load a CSV file | CSV | None; the recipe parses it with PapaParse | Import from CSV or Excel recipe |
| Download the grid as a PDF file | None; the recipe uses jsPDF | Export to PDF recipe | |
| Copy and paste between the grid and other apps | Clipboard | CopyPaste | Clipboard |
Turn the plugins on
Both plugins are part of registerAllModules().
- The
ImportFileplugin is on unless you setimportFile: false. - The
ExportFilemethods work whatever theexportFilevalue. SetexportFileto any value, for exampleexportFile: true, to add the Export item to the context menu.
Engines
Excel files are read and written by an engine. The built-in engine needs no library, and you can inject ExcelJS instead. XLSX engines compares the two and covers bundle size, limits, and security.
What a file cannot carry
A workbook can hold things the grid has no place for, such as pictures or pivot tables, and the grid can hold things an Excel file cannot store. Instead of failing, an import or export reports each one under a key, in a console warning and, for an import, on result.dropped. The Dropped features reference explains every key.
Related articles
Related guides
Related API reference
Plugins