Save Grid as XLSX
Trigger a browser download of the current worksheet as an .xlsx file.
Pro only.
saveAsXlsxis a no-op in the Lite edition and emits aconsole.warn.
Basic usage
import { createReogrid } from '@reogrid/pro';
const { worksheet } = createReogrid('#grid');
// ...populate the grid...
worksheet.saveAsXlsx({
filename: 'report.xlsx',
sheetName: 'Q1 2026',
});
Defaults: filename: 'reogrid.xlsx', sheetName: 'Sheet1'.
Trigger from a button (React)
import { Reogrid, type ReogridInstance } from '@reogrid/pro/react';
import { useRef } from 'react';
export default function App() {
const ref = useRef<ReogridInstance>(null);
return (
<>
<button onClick={() => ref.current?.worksheet.saveAsXlsx({ filename: 'export.xlsx' })}>
Download XLSX
</button>
<Reogrid ref={ref} style={{ width: '100%', height: 500 }} />
</>
);
}
What gets exported
| Included | Notes |
|---|---|
| Cell values | Strings, numbers, booleans |
| Formulas | With cached computed results (Excel re-evaluates on open) |
| Styles | Font, color, alignment, background |
| Number formats | Built-in Excel codes + custom |
| Merged cells | Preserved as xlsx merges |
| Borders | All four sides per cell |
| Row heights / column widths | Exact pixel → point conversion |
| Conditional formatting | cellIs, expression, containsText rules |
| Images | Embedded media (xlsx drawing parts) |
Round-trip: loadXlsx → saveAsXlsx preserves all of the above.
Export without downloading
To build the xlsx bytes without triggering a download — for example to attach to a form post or send to a server:
import { buildXlsxFromSnapshot } from '@reogrid/pro';
const snapshot = worksheet.getExportSnapshot();
const bytes: Uint8Array = buildXlsxFromSnapshot(snapshot, 'Sheet1');
await fetch('/api/upload', {
method: 'POST',
headers: { 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' },
body: bytes,
});