JavaScript Scheduler   Export to Excel Spreadsheet (XLSX)

The JavaScript Scheduler component supports client-side export to an Excel spreadsheet (xlsx format).

Available since 2025.1.6418.

Live Demo

Supported Features

  • Customization of background and font colors (time headers, row headers, cells, events, upper-left corner)

  • Frozen rows

  • Row header columns

  • Custom event height

  • Overlapping events

Dependencies

The Scheduler uses ExcelJS library (MIT license) to generate the Excel spreadsheet.

ExcelJS is not bundled: The reference to ExcelJS must be provided using the exceljs property of the Scheduler.

Quick Example

Configuration:

  • Set the ExcelJS reference using the exceljs property

Export:

  • Call the exportAs() method to get the export object: exportAs("xlsx")

  • The export object supports direct download using download("file.xlsx") or async BLOB access using toBlobAsync().

<script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.4.0/exceljs.min.js"></script>

<div id="scheduler"></div>

<button id="export">Export</button>

<script>

  const scheduler = new DayPilot.Scheduler("scheduler", {    
    exceljs: ExcelJS,
    onBeforeEventExport: args => {
      args.data.backColor = "#fafafa";
      args.data.fontColor = "#333333";
      args.data.borderColor = "#cccccc";
    },
    // ...
  });
  scheduler.init();

  const app = {
      init() {
          this.bindEvents();
      },
      bindEvents() {
          document.getElementById('export').addEventListener('click', (ev) => {
              const options = {
                  mime: "application/octet-stream",
                  area: "full",
              };
              scheduler.exportAs("xlsx", options).download("scheduler.xlsx");
          });
      }
  };
  app.init();

</script>

Exported Area

By default, the Scheduler exports the current view. You can opt to export the whole grid or specify custom resource and date range.

Full grid export:

scheduler.exportAs("xlsx", {
  area: "full"
}).download("scheduler.xlsx");

Current viewport:

scheduler.exportAs("xlsx", {
  area: "viewport"
}).download("scheduler.xlsx");

Frozen Rows and Columns

When you export the full Scheduler grid (area: "full"), the headers will be frozen in the output XLSX file, including top-frozen rows.

For other export areas, nothing will be frozen in the output XLSX file.

Adjusting Dimensions

Excel uses its own units for column widths and row heights.

The Scheduler translates the pixel measures to the Excel units. The output should roughly correspond to the dimensions displayed in the browser.

You can also provide custom unit conversion calculations:

  • to better adjust the dimensions to the target environment

  • to scale up/down

Custom width conversion function:

scheduler.exportAs("xlsx", {
  transformWidth: width => (width - 5) / 7
}).download();

Custom height conversion function:

scheduler.exportAs("xlsx", {
  transformWidth: height => height * 0.75
}).download();

Event Appearance

The following properties can be configued using onBeforeEventRender or onBeforeEventExport:

  • backColor

  • borderColor

  • fontColor

If the text includes a line break (\n), the Scheduler will enable word wrap for the target spreadsheet cell and the line break will be exported.

The colors must be in hex format (e.g., "#ffffff").

You can set custom event height in the data source. If there are multiple events in the target line within a row (see Event Placement Strategies for an explanation), the maximum event height will be used for all events in this line.

Output

You can export the XLSX file as a Blob using the getBlobAsync() method:

const blob = await scheduler.exportAs("xlsx").getBlobAsync();

You can also directly invoke the download using the download() method:

scheduler.exportAs("xlsx").download("scheduler.xlsx");

The default MIME type of the output is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. If needed (e.g., in Salesforce LWC), you can set custom MIME type using the mime property:

scheduler.exportAs("xlsx", {
  mime: "application/octet-stream"
}).download();

Limitations

Spreadsheets have only a single layer and all elements needs to match the grid. That limits the Scheduler representation in the output xlsx file.

Features that rely on multiple layers and more complex layout are not supported, including:

  • Active areas

  • Duration bar

  • Custom HTML

  • Event versions

  • Event stacking line height

  • Links

  • CSS (rounded corners, transparency, transformations…)