DayPilot.Calendar.exportAs

The exportAs() method exports the JavaScript Calendar component in the specified format and returns a DayPilot.Export helper.

Declaration

DayPilot.Calendar.exportAs(format[, options]);

Parameters

  • format ("svg" | "png" | "jpeg" | "xlsx") - export format

  • options.area ("viewport" | "full") - exported area; if not specified, "viewport" is used

Image export options:

  • options.quality (number) - output JPEG quality; applies only when format is "jpeg"; if not specified, 0.92 is used

  • options.scale (number) - output scale; if not specified, 1 is used; use 2 to magnify the output to 200%

Excel export options:

  • options.mime (string) - custom MIME type for the exported file; the default is "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

  • options.transformWidth (function) - converts a pixel value to Excel column width units; the default is (width) => (width - 5) / 7

  • options.transformHeight (function) - converts a pixel value to Excel row height units; the default is (height) => height * 0.75

Excel export is available since 2026.1.6816. It only supports full grid export, so the options.area value is ignored.

Return Value

Returns a DayPilot.Export object.

For image export, the object provides the following methods:

  • toElement() - returns a DOM element with the image (<svg> or <img>)

  • toHtml() - returns the DOM element as HTML

  • toDataUri() - returns a data URI string with SVG or image data

  • toBlob() - returns a Blob object

  • download(filename) - forces download of the exported image

  • print() - prints the exported image using the browser print dialog

For Excel export, the object provides only the following methods:

  • download(filename) - initiates immediate download of the XLSX file

  • toBlobAsync() - returns a Promise<Blob> object

Example

const exportResult = dp.exportAs("png");
exportResult.download("calendar.png");

See Also

Export [doc.daypilot.org]

DayPilot.Calendar Class

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript