Skip to main content

export-data

The functionality is available in PRO Edition only

PRO

Assembles the current board view into an export payload and dispatches it to either a remote export service (PDF/PNG) or a host-supplied function (e.g. for client-side xlsx generation). PRO feature.

Usage

type ExportConfig = {
url?:
| string
| ((
data: ExportConfig,
records: KanbanCard[],
helpers: ExportHelpers
) => void);
format?: string;
fileName?: string;
skin?: string;
paper?: PaperConfig;
excel?: ExcelConfig;
};
FieldTypeDescription
urlstring | functionTransport selector. A string URL POSTs a hidden form to the export service. A function receives the payload directly. Omitting url assembles but doesn't dispatch.
formatstringExport format: "pdf", "png", "xlsx", etc. Default: "pdf".
fileNamestringOutput file name (without extension). Default: "tasks".
skinstringServer-side theme. Default: "willow".
paperPaperConfigPDF/PNG page options (see below).
excelExcelConfigExcel-specific options (see below).

PaperConfig:

FieldTypeDescription
fitSizebooleanFit content to page size
sizestring | { width: number; height: number }Page size (e.g. "A4")
landscapebooleanLandscape orientation
stylesstring | string[]Extra CSS; URLs are fetched and inlined
margins{ top?, bottom?, left?, right? }Page margins in px
headerstringPage header HTML
footerstringPage footer HTML
scalenumberRender scale factor

ExcelConfig:

FieldTypeDescription
sheetNamesstring[]Sheet names in the workbook
dateFormatstringDate format string
indent"native" | "spaces"Indentation style

ExportHelpers (passed to function transports):

FieldTypeDescription
post(url: string, data: Record<string, string>) => voidHidden-form POST helper
serialize(value: any) => stringJSON serializer with Date handling

Trigger

import { version } from "@svar-ui/react-kanban";

api.exec("export-data", {
url: "https://svar-export.webix.io/kanban/" + version,
format: "pdf",
skin: "print",
});

Export to xlsx using a function transport:

api.exec("export-data", {
url: (cfg, records, helpers) => {
// build xlsx from records client-side
},
format: "xlsx",
});

Observe

api.on("export-data", ev => {
console.log("Export triggered:", ev.format);
});

Intercept

api.intercept("export-data", ev => {
// cancel export for empty boards
const state = api.getState();
return state.viewData.columns.some(c => c.cards.length > 0);
});

Component handler

<Kanban
cards={cards}
columns={columns}
onExportData={(ev) => console.log("Exported:", ev.format)}
/>