# Excel Export (JavaScript Event Calendar) | DayPilot Pro for JavaScript Demo

> Read more about [client-side Excel export](https://doc.daypilot.org/calendar/client-side-excel-export/).

## Links

- Canonical HTML: /demo/calendar/exportexcel.html
- Source HTML folder: /demo/calendar/
- Catalog root: /demo/
- Catalog: /demo/llms.txt

## Source

### Inline demo script 1

```javascript
const dp = new DayPilot.Calendar("dp", {
            // view
            startDate: DayPilot.Date.today(),
            durationBarVisible: false,
            showAllDayEvents: true,

            headerLevelHeights: [40, 80],
            viewType: "Week",  // "Resources" view type to show columns as resources
            columns: [
                {
                    name: "Big Cars", children: [
                        {name: "Big Car #1", id: "big1"},
                        {name: "Big Car #2", id: "big2"},
                        {name: "Big Car #3", id: "big3"},
                        {name: "Big Car #4", id: "big4"},
                    ]
                },
                {
                    name: "Small Cars", children: [
                        {name: "Small Car #1", id: "small1"},
                        {name: "Small Car #2", id: "small2"},
                        {name: "Small Car #3", id: "small3"},
                    ]
                }
            ],

            heightSpec: "Fixed",
            height: 300,

            // event creating
            onTimeRangeSelected: async (args) => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                dp.clearSelection();
                if (modal.canceled) {
                    return;
                }
                dp.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result
                });
                dp.message("Created");
            },

            onBeforeEventRender: args => {
                args.data.backColor = "#6aa84f";
                args.data.fontColor = "#ffffff";
                args.data.borderColor = "#3d6f3d";
            },

            exceljs: ExcelJS
        });

        dp.init();

        const app = {
            elements: {
                downloadButton: document.getElementById("download-button"),
                area: document.getElementById("area"),
            },
            init: function () {
                this.elements.downloadButton.addEventListener("click", (ev) => {
                    ev.preventDefault();
                    dp.exportAs("xlsx").download();
                });

                this.loadEventData();
            },
            loadEventData() {
                const events = [
                    {
                        start: DayPilot.Date.today().addHours(12),
                        end: DayPilot.Date.today().addHours(15),
                        resource: "small2",
                        id: DayPilot.guid(),
                        text: "Special event"
                    },
                    {
                        start: DayPilot.Date.today(),
                        end: DayPilot.Date.today().addDays(3),
                        resource: "small2",
                        id: DayPilot.guid(),
                        allday: true,
                        text: "All-day event 1"
                    }, {
                        start: DayPilot.Date.today().addDays(2),
                        end: DayPilot.Date.today().addDays(5),
                        id: DayPilot.guid(),
                        allday: true,
                        text: "All-day event 2"
                    },
                ];

                dp.update({events});
            }
        };

        app.init();
```

