Skip to content

CSV, XLSX, print and complete exports

APIResultScope
pivot.exportCsv(options)StringCaptured currently loaded logical report
pivot.exportXlsx(options)Uint8ArraySame loaded scope, grouped headers and supported native number formats
pivot.getVisibleExportData(options)Detached export dataCapture for local writers; not a complete remote fetch
buildPivotPrintTable(input)Escaped HTML stringSupplied resolved result; does not open a print dialog
`pivot.exportFullReport(‘csv’‘xlsx’, options)`Result containing content

A server viewport may contain only a window. Neither local writers nor exporting the loaded model fetch missing server groups. Use complete export for that requirement.

import { buildPivotPrintTable } from '@revolist/pivot/headless';
const captured = pivot.getVisibleExportData({
resourceLimits: { maxExportDataCells: 100000 },
});
const printable = buildPivotPrintTable({
...captured, resourceLimits: { maxExportUtf8Bytes: 2000000 },
});
// Place printable in the application's print surface and invoke its print flow.

Local captures detach owned headers/records from later grid changes. Captured policy ceilings cannot be raised by writer options; the stricter ceiling wins. Application nested payloads/formatters retain their documented atomic boundaries. Headless helpers exportVisiblePivotToCsv and exportVisiblePivotToXlsx accept supplied columns/body/pinned records; see the executable writer example.

CSV optionDefaultMeaning
columnDelimiter,Cell separator
rowDelimiterCRLFRow separator
bomfalsePrefix UTF-8 BOM
headerPathDelimiter/Flatten grouped captions
resourceLimitsAll omitted/unboundedPhysical output counters

CSV preserves raw numeric output and escapes delimiters/quotes. XLSX keeps numeric values and supported native Excel measure formats; arbitrary appearance/conditional formatting is not workbook styling. Print HTML contains escaped resolved cells. None of these writers improves binary64 arithmetic precision.

const abort = new AbortController();
try {
const result = await pivot.exportFullReport('xlsx', {
signal: abort.signal,
limits: { maxRows: 5000, maxCells: 100000 },
onProgress: progress => console.log(progress.phase, progress.receivedBytes),
});
// Save result.content through the host download flow after success.
} catch (error) {
console.error(error); // Offer smaller scope or retry; retain the current report.
}
// Wire a Cancel control to abort.abort().
Complete-export limitDefault/library ceilingUnits
maxRows10000Body plus total rows
maxColumns256Flattened columns including labels and expanded measures
maxCells500000Physical rows × columns
maxBytes16000000Response JSON and formatted output byte ceiling

Complete-export limits are positive integers; applications can lower them, not raise the library ceilings. This differs from optional zero-valid local resource counters. Refuse excess output; never silently truncate a complete report.

The backend echoes requestId and queryKey, declares complete: true, scope: 'complete-filtered-report', and an atomic-at-export snapshot ID. It must read domains, counts, facts and totals from one authorized operation-owned snapshot. This is an export-time guarantee, not necessarily the data version of an earlier screen. Dataset-version consistency across requests needs an explicit host contract.

The request retains filters, ranking, sorting, collapse/totals/value orientation and labels while excluding viewport offsets/limits. Other must be reaggregated from original facts. SDK validation rejects incomplete/stale/mismatched output. Authentication, authorization, actual driver snapshots/deadlines/cancellation and server resource release remain backend obligations.

Cancellation settles public export promises and blocks stale downloads even if a custom adapter ignores its signal. It cannot guarantee that such an adapter stopped its database query. Background job infrastructure is deferred. See the complete protocol and remote deployment guide.