how-to
How to export a data grid to Excel from JavaScript
Last updated 22 September 2026
Call grid.export.excel() and it resolves to a real .xlsx workbook,
not a renamed CSV. Give it a fileName and it downloads on its own; give it no
arguments at all and it still writes a styled sheet with the grid's current column order and
sort carried over.
Below is a live grid with a Download button and two options: whether the export follows the quick filter or takes every row regardless, and whether the Margin column, hidden from the grid itself, comes with it.
The code
One button, reading two checkboxes at the moment it is clicked. Every other value comes straight from the grid, so the file always matches what a reader was actually looking at.
document.getElementById('download').addEventListener('click', () => {
grid.export.excel({
fileName: 'product-catalogue',
rows: allRowsChecked ? 'all' : 'visible',
hiddenColumns: includeHiddenChecked ? 'hidden' : 'omit',
});
});
Try the standalone page or read the full source on GitHub, loaded by script tag with no build step.
Two things to know
rows: 'all'exports every row regardless of the current filter; the default,'visible', exports only what the filter leaves.- A column the grid hides is left out of the file by default.
hiddenColumns: 'hidden'carries it in anyway, itself marked hidden in the workbook for a round trip back in.
See the full Excel export demo for frozen panes, named sheets and cell fills, or the developer guide for everything else the grid does.