The exportAs() method exports the Scheduler in the specified format ("svg", "png", "jpeg", "xlsx").

Export to Excel spreadsheet (XLSX) is supported since version 2025.1.6418.

Declaration

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

Parameters

  • format - export format: "svg", "png", "jpeg", or "xlsx"

  • options.area - exported area: "viewport", "full", or "range"; the default value is "viewport"

  • options.dateFrom - start date (applies only to area: "range")

  • options.dateTo - end date (applies only to area: "range")

  • options.resourceFrom - start resource (applies only to area: "range")

  • options.resourceTo - end resource (applies only to area: "range")

Image export options:

  • options.quality - output JPEG quality (applies only to format: "jpeg"); the default value is 0.92

  • options.scale - output scale; the default value is 1 (use 2 for 200% output)

Excel export options:

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

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

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

Return Value

Returns a DayPilot.Export object that provides the following methods:

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

  • toHtml() - returns the DOM element as HTML

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

  • toBlob() - returns a Blob object

  • download(filename) - initiates immediate download of the exported image

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

For Excel export, the returned object has only the following methods:

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

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

JavaScript

const image = dp.exportAs("png", { area: "full" });
image.download("scheduler.png");

const spreadsheet = dp.exportAs("xlsx");
spreadsheet.download("scheduler.xlsx");

Angular

Use a template reference and ViewChild in an existing component. Invoke exportImage() from a button after initialization.

<daypilot-scheduler [config]="config" #scheduler></daypilot-scheduler>
@ViewChild("scheduler") scheduler!: DayPilotSchedulerComponent;
config: DayPilot.SchedulerConfig = {};

exportImage() {
  this.scheduler.control.exportAs("png", {area: "full", scale: 2}).download("scheduler.png");
}

React

const scheduler = useRef(null);
function exportImage() {
  scheduler.current.exportAs("png", {area: "full", scale: 2}).download("scheduler.png");
}

<DayPilotScheduler
  controlRef={control => { scheduler.current = control; }}
/>

Vue

<script setup>
import {ref} from "vue";
const scheduler = ref(null);
function exportImage() {
  scheduler.value.control.exportAs("png", {area: "full", scale: 2}).download("scheduler.png");
}
</script>

<template>
  <DayPilotScheduler ref="scheduler" />
</template>

Keep the component’s existing date, data and layout options. Angular imports ViewChild and the DayPilot component type; React imports useRef. Vue uses the DayPilot component already registered or imported by the application.

Bitmap Export Errors

PNG and JPEG export can throw an error with name: "DayPilot.ExportError" and code: "BITMAP_EXPORT_FAILED" if the bitmap cannot be created or encoded. This is a structured error object, not a public constructor.

  • stage: "dimensions", "allocation", "drawing" or "encoding"

  • format: output MIME type

  • width, height, scale: requested logical dimensions and scale

  • pixelWidth, pixelHeight: requested bitmap dimensions

  • surface: "main" or "group"; surfaceWidth and surfaceHeight: dimensions of the failed surface

  • cause: optional underlying error

Native canvas SecurityError exceptions keep their original identity. Image and font loading must be handled separately. The exporter does not automatically reduce scale or paginate a large image; choose a smaller area or scale when appropriate.

See Also

DayPilot.Scheduler Class

Client-Side Export [doc.daypilot.org]

Client-Side Excel Export [doc.daypilot.org]

Client-Side PNG Export [doc.daypilot.org]

Client-Side JPEG Export [doc.daypilot.org]

Client-Side SVG Export [doc.daypilot.org]

Printing [doc.daypilot.org]

Availability

Availability of this API item in DayPilot editions:

ProductLitePro
DayPilot for JavaScript