export-data
Builds a serializable export request from the current view, date, and raw events, then sends it to a remote renderer URL or to an application callback. Use it to export the calendar to PDF, PNG, or a custom format such as XLSX. The action does not mutate calendar state and resolves even when no url is given (in that case nothing is sent).
The functionality is available in PRO Edition only
Usage
type ExportConfig = {
url?:
| string
| ((
data: ExportConfig,
records: CalendarEvent[],
helpers: ExportHelpers
) => void);
format?: string; // default "pdf"
fileName?: string; // default "events"
skin?: string; // default "willow"
paper?: {
fitSize?: boolean;
size?: string | { width: number; height: number };
landscape?: boolean;
styles?: string | string[];
margins?: { top?: number; bottom?: number; left?: number; right?: number };
header?: string;
footer?: string;
scale?: number;
};
excel?: {
sheetNames?: string[];
dateFormat?: string;
columns?: {
id: string;
label?: string;
width?: number;
hidden?: boolean;
}[];
};
data?: Record<string, any>;
};
type ExportHelpers = {
post(url: string, data: Record<string, string>): void;
serialize(value: any): string;
};
| Field | Type | Description |
|---|---|---|
url | string | function | A string endpoint receives a POST form; a function is called with the prepared request, the raw records, and export helpers. Omit to build the request without sending it. |
format | string | Output format. Default "pdf". |
fileName | string | Base name of the output file. Default "events". |
skin | string | Theme for the rendered output ("willow", "willow-dark", "print", "bw"). Default "willow". Stored at data.skin in the request. |
paper | object | Page setup for PDF/PNG rendering - size, orientation, margins, styles, header/footer, scale. |
excel | object | Column and sheet configuration for spreadsheet formats. |
data | Record<string, any> | Extra payload fields. Replaced by the handler-prepared data object in the sent request. |
The prepared data object carries the selected skin, the current view and date, the raw events from getEvents() (unbounded - masters and exceptions are sent unexpanded in recurring mode), and any captured eventContent/eventCss/cellCss presentation for currently rendered events and cells.
Trigger
Send to a remote renderer URL:
api.exec("export-data", {
url: "https://export.example/calendar",
format: "pdf",
paper: { landscape: true },
});
Handle the export yourself with a callback URL:
api.exec("export-data", {
format: "xlsx",
url: async (request, records) => {
const blob = await writeWorkbook(records, request.excel?.columns);
downloadBlob(blob, "events.xlsx");
},
});
The string form serializes the request and submits an ephemeral POST form targeting _blank with a single data field. The callback form receives (request, records, { post, serialize }); its returned promise is not awaited.
Observe
api.on("export-data", cfg => console.log("exporting", cfg.format));
Intercept
api.intercept("export-data", cfg => cfg.format !== "xlsx");
Returning false cancels the export before the request is built.
Component handler
<Calendar :onexportdata="cfg => console.log(cfg.format)" />