View as Markdown

API reference: @salmonui/export/pivot

exportPivotfunction

import { exportPivot } from '@salmonui/export/pivot';
function exportPivot(source: PivotExportSource, options: PivotFileExportOptions & {
    readonly format: 'csv';
}, handlers?: PivotExportHandlers<string>): Promise<ExportFile<string> | null>;

function exportPivot(source: PivotExportSource | readonly PivotExportSource[], options?: PivotFileExportOptions & {
    readonly format?: 'xlsx' | 'pdf';
}, handlers?: PivotExportHandlers): Promise<ExportFile | null>;

function exportPivot(source: PivotExportSource | readonly PivotExportSource[], options?: PivotFileExportOptions, handlers?: PivotExportHandlers<Uint8Array | string>): Promise<ExportFile<Uint8Array | string> | null>;

Exports a pivot result (or a window source, paged) as XLSX (default; several results become one sheet each, or xlsx.layout: 'stacked'), PDF or CSV. XLSX: an outlined sheet with stacked merged column headers, row outline levels, number formats from model.formats, subtotal and grand total styles, conditional formats and the cell hook. PDF: the same table with the column headers repeated on every page, then one page per chart image. CSV: one header line of column paths (2024 / Sum of Amount, the labels of every column header level joined), then raw numbers, or the formatted texts with csv.values: 'formatted'. Resolves to { fileName, mimeType, data }, or null when onBeforeExport prevents it.