Documentation

Styled Excel and PDF export

Try it live:

Three of the ten export formats need the Enterprise package: excel-list, excel-pivot and pdf. The other seven — CSV, JSON in three shapes, XML, print and clipboard — are free.

Everything structural is in the free core: flattening rows, building merged headers, resolving values, evaluating conditional-format rules. What Enterprise adds is the writing — ExcelJS and jsPDF, plus a streaming fallback for large sheets.

Turning it on

Importing anything from the Enterprise package registers the exporter. There is no configuration:

import { EnterprisePivotGrid } from '@kanunilabs/pivotgrid-react-enterprise';

The footer's download menu then enables the three paid entries. From code:

const ref = useRef<PivotGridRef<Sale>>(null);

ref.current?.exportData('excel-pivot', {
  fileName: 'Q4-revenue',
  applyFilters: true,
  expandAll: false,
  locale: 'tr-TR',
});

exportData returns a promise, so you can await it and catch a refusal:

try {
  await ref.current?.exportData('excel-pivot', { fileName: 'Q4' });
} catch (err) {
  // A Community grid refuses the three paid formats. See below.
}
OptionDefaultRead by the exporter
fileName'PivotExport'yes — the extension is appended
locale'tr-TR'pivot only; the flat list ignores it
applyFilterstrueyes — the rows the filters keep; false writes every source row
expandAll—yes
signal—only at chunk boundaries
onProgress—plumbed, never wired to any UI
headerBlock—excel-pivot and excel-list only — rows above the table, see below
freezeHeadertrueexcel-list: the header row frozen; excel-pivot: its own frozen pane. false turns either off
autoFiltertrueexcel-list only — Excel's filter on the header row. The pivot form never has one

ExportFormat and ExportOptions come from @kanunilabs/pivotgrid-core, not from the React package.

Rows above the table

headerBlock writes your own rows first and the table below them: a title, the date and time of the export, a note about the filters. It has the same shape as the DataGrid's headerBlock, so one object serves both grids. A cell is text, a number or a Date; a Date becomes a real Excel date showing the local day and time, formatted yyyy-mm-dd hh:mm unless the row's style.numFmt says otherwise. An empty cells array is a blank row.

import type { PivotExcelBandRow } from '@kanunilabs/pivotgrid-core';

const headerBlock: PivotExcelBandRow[] = [
  { cells: [new Date()], style: { numFmt: 'dd.mm.yyyy hh:mm' } },   // A1
  { cells: ['Sales by region'], merge: true, style: { font: { bold: true, size: 14 } } },
  { cells: [] },                                                       // the table starts on row 4
];

await ref.current?.exportData('excel-pivot', { fileName: 'Q4', headerBlock });
await ref.current?.exportData('excel-list', { fileName: 'Q4-list', headerBlock });

merge: true spans the row across the table's width; height sets the row height in points. The frozen pane of the pivot sheet moves down with the table, so it still sits under the column headers, and the header merges and row grouping move with it. The large-file .xls path writes the rows too. The buttons in the grid's own footer do not pass a headerBlock: call exportData from your own button for it. CSV, JSON, PDF and the other formats ignore it.

A plain number or text in these rows keeps the General format even above a list column formatted as a percentage or a date; give the row a style.numFmt for another one. A number, date or true/false value in an unmerged cell widens its column in the .xlsx file when it needs more room, so Excel shows it rather than #####; a text never widens a column, it runs on into the empty cells beside it. On a merged row, the cells past the table's width stay where they are, beside the merged title. A large band sits inside the frozen pane, since everything above the header row is frozen with it: keep it to a few rows, or set freezeHeader: false.

Frozen header and filter in the list

The excel-list file is a plain table, so it opens the way the DataGrid's list export does: the header row is frozen and carries Excel's auto-filter across its columns. With a headerBlock both sit on the table's own header row, below your rows. The large-file .xls path writes both too. Turn either off per call with the same option names the DataGrid uses:

await ref.current?.exportData('excel-list', { fileName: 'Q4-list', autoFilter: false });
await ref.current?.exportData('excel-list', { fileName: 'Q4-list', freezeHeader: false });

The excel-pivot file never gets an auto-filter: merged headers and total rows would make Excel's filter hide the wrong rows. Its frozen pane (under the column headers, beside the row headers) stays; freezeHeader: false turns it off. The large-file .xls pivot has no frozen pane at all.

Export right after a change

An export asked for while a change is still being computed (a filter, a field moved, an expand, new rows) waits for that change and writes its result, not the one on screen a moment earlier. Queued applyTransactionAsync batches are applied first. Every format waits, from the footer menu and from exportData alike. The wait has no time limit: a slow serverSource.compute is waited for too. Print and clipboard run after the wait, so a browser may refuse them when the click that asked for them is too long ago. If the grid is destroyed while an export waits, exportData rejects with an AbortError (the footer and the React ref drop it quietly).

How long a browser lets a click "count" was measured on 2026-11-14 in Chrome, Firefox and WebKit (Playwright, headless): a click handler waited 0, 3 or 6 seconds, then did what the export does.

After the clickChromeFirefoxWebKit
File download (CSV, JSON, XML, Excel, PDF), 0 / 3 / 6 ssavedsavedsaved
Print window (window.open), 0 sopensopensopens
Print window, 6 sblockedblockedopened (see below)
Clipboard (navigator.clipboard.writeText), 0 swrittenwrittenwritten
Clipboard, 6 srefusedrefusedrefused

So a slow computation does not lose a file: downloads went through even 6 seconds after the click, when the click no longer counted as one (navigator.userActivation.isActive was false). Print and clipboard need the click to be recent — about 5 seconds in Chrome and Firefox — and are refused after a long wait. Playwright's WebKit lets a page open windows without a click, so its 6-second print result does not tell what Safari's own pop-up blocker does; treat Safari like the other two. If a print or clipboard export may wait for a long computation, start it after the result is in: wait for isComputing to be false (below), then let the user click.

To show your own "updating" state, read getState().isComputing or pass onComputingChange: it is called with true when a change starts computing and with false when its result is in engineResult. isBuilding is the loader's flag and stays true a moment longer while the progress bar finishes.

<BasePivotGrid onComputingChange={(computing) => setUpdating(computing)} /* … */ />

The summary as a flat table (Enterprise)

getSummaryTable(controller) returns the pivot's summary as rows: one per combination of the deepest row level, beside it every shown data field (calculated fields included, helper fields not), with the filters applied and regardless of what is expanded on screen. The values are the grand-total column's — the column fields are summed over. It is computed when you call it, so a panel that is closed costs nothing; a blank summary (a division by zero) is null.

import { getSummaryTable, exportSummaryTable } from '@kanunilabs/pivotgrid-react-enterprise';

const { columns, rows } = await getSummaryTable(ref.current!.getController());
// columns: [{ id, caption, kind: 'row' | 'data', field }, …]
// rows:    [{ region: 'EMEA', city: 'Berlin', qty: 15, price: 10 }, …]

await exportSummaryTable(ref.current!.getController(), { fileName: 'summary', locale: 'tr' });

By default the values are the raw aggregates. With a summary display mode (percent of the grand total, running total, difference, …) the grid shows a different number: pass { display: true, locale } to get that shown value in rows and its text, formatted as the grid formats it, in formatted (one entry per row, keyed by data field id).

const { rows, formatted } = await getSummaryTable(controller, { display: true, locale: 'tr' });
// rows[0].qty === 97.6 (shown), formatted[0].qty === '%97,60'

exportSummaryTable writes the same rows to one worksheet with the data fields' number formats. Pass locale: it names the sheet and labels grouped date levels.

What this does not do

Size changes the file

excel-list past 100,000 rows stops producing a real .xlsx and starts producing SpreadsheetML with an .xls extension. Same menu item, same name, different file — and in that format every formatted number is written as a string, which Excel will not sum.

The pivot equivalent switches at 150,000 materialised cells and additionally drops conditional formatting, outline levels, frozen panes and column widths. (The large list file keeps its frozen header and filter.)

The grid does not warn on its own, but it asks you first: give onLargeExport (on the grid, or per call in exportData options) and it is called with { format, size, limit, unit } before the plain file is written. Return false — or a Promise of it, after your own "the formatting will be lost, continue?" dialog — and nothing is written.

<EnterprisePivotGrid
  onLargeExport={async ({ size, unit }) => confirmPlainExport(size, unit)}
  …
/>

The file will not match the screen

Absent from every export path:

  • cellTemplate output — the exporter writes the underlying value
  • theme colours
  • vertical header merges
  • dataFieldPosition: 'rows', which the grid honours and the exporters ignore
  • conditional rules other than expression
  • when several conditional rules match a cell, the screen merges them all; the export applies the first

Progress and cancellation are not reachable from the UI

The footer menu passes neither signal nor onProgress — both are fully plumbed and wired to nothing. You can only use them through your own ref.

Even then, cancellation is coarse: the signal is polled at chunk boundaries and not during the three most expensive calls, and aborting discards all work.

PDF

A wide pivot gets one accommodation: landscape orientation. No page breaking by column, no scaling, no per-column widths.

No font is registered, so non-ASCII text is at risk — worth checking with Turkish characters before you rely on it, given the default export locale is tr-TR.

Community refuses, and says so

A Community grid asked for one of the three paid formats gets a rejected promise naming the format and the package that provides it. The refusal happens before the exporting event, so nothing is left waiting on it, and the rejection is routed to your onError handler — or to console.error if you have none.

Until this shipped it was a console.warn and a resolved promise, fired after onExporting — so a spinner started on that event span forever with a clean console.

If your application registers its own exporter under one of those format ids, yours wins: the gate looks for a custom exporter first and steps aside.

It is an edition gate, not a licence gate

An unlicensed Enterprise build still exports — watermarked, not crippled. That is deliberate and matches DataGrid: a dead feature cannot be evaluated before purchase.

What the gate closes is the accidental path. The exporter registers itself into a module-level slot when the Enterprise package is imported, and that slot cannot tell which grid is asking — so one Enterprise import anywhere used to enable styled export for every grid in the bundle, Community ones included. The controller can tell, so the check lives there.

It is not DRM. exportPivotData, PivotExportService and getAdvancedExporter are public exports of the free package, so deliberate code can still reach the exporter. Narrowing that is a breaking change and belongs in a major version.