export from scheduler to excel with date range selection

hello, I have configured the scheduler data export to excel.


Please tell me, how to implement export to Excel with a choice of dates for the export range.


the idea is this: the user sets the start and end dates, and all data that falls within this range is exported


3 Replies

RV Ravikumar Venkatesan Syncfusion Team May 13, 2022 03:39 PM UTC

Hi Sergei,


Greetings from Syncfusion support.


We have validated your query “export from the scheduler to excel with date range selection” at our end. You can export the appointments in the specific date range with help of the getEvents and exportToExcel methods of the Schedule as mentioned in the below code snippet.


[index.js]

  onExportClick() {

    const dates = this.scheduleObj.getCurrentViewDates();

    const msPerDay = 86400000;

    // Filtering appointments based on date range.

    const currentViewEvents = this.scheduleObj.getEvents(dates[0], new Date(dates[dates.length - 1].getTime() + msPerDay));

    // Passing the filtered appointments for exporting

    const exportValues = { customData: currentViewEvents };

    this.scheduleObj.exportToExcel(exportValues);

  }


Sample: https://stackblitz.com/edit/ej2-react-schedule-export-specific-range-events-in-excel?file=index.js


Kindly try the shared sample and let us know if you need any further assistance.


API:

getEvents method: https://ej2.syncfusion.com/react/documentation/api/schedule/#getevents

exportToExcel method: https://ej2.syncfusion.com/react/documentation/api/schedule/#exporttoexcel

customData parameter of exportToExcel method: https://ej2.syncfusion.com/react/documentation/api/schedule/exportOptions/#customdata


Regards,

Ravikumar Venkatesan



SK Sergei Kozlov May 17, 2022 06:31 AM UTC

Thanks for your answer


I have implemented a modal window in which the user selects an export date range.


this works for dates without repeating ( RecurrenceRule: null )


but:

when there is an event that is set to repeat (has a RecurrenceRule rule ) - the data is not filtered and all the dates of such an event that fall outside the specified export range are included in the export (the "includeOccurrences: true" prop - important for me).


Can you tell me how to apply a filter for recurring events so that the events that are specified by the date range of the export get into the export?

and one more question: how to set the style of cells in excel when exporting? set cell format (e.g. date format)?


thank!




RV Ravikumar Venkatesan Syncfusion Team May 17, 2022 03:51 PM UTC

Hi Sergei,


Thanks for the update.


Q1: Can you tell me how to apply a filter for recurring events so that the events that are specified by the date range of the export get into the export?

Based on your query we suspect that you need all occurrences of the recurrence event in the selected date range. So, we suggest you pass the includeOccurrences parameter of the getEvents method to true as mentioned below.


[index.js]

  onExportClick() {

    const dates = this.scheduleObj.getCurrentViewDates();

    const msPerDay = 86400000;

    // Filtering appointments based on date range.

    const currentViewEvents = this.scheduleObj.getEvents(dates[0], new Date(dates[dates.length - 1].getTime() + msPerDay), true);

    // Passing the filtered appointments for exporting

    const exportValues = { customData: currentViewEvents };

    this.scheduleObj.exportToExcel(exportValues);

  }


Sample: https://stackblitz.com/edit/ej2-react-schedule-export-specific-range-events-i-xx6zmn?file=index.js


Q2: how to set the style of cells in excel when exporting? set cell format (e.g. date format)?

Currently, we weren’t able to style the cells in excel when exporting events from the Schedule. Can you kindly share the real-time use case scenario of your requirement? Based on that we will log a feature request at our end.


Kindly try the shared sample and let us know if you need any further assistance.


Regards,

Ravikumar Venkatesan


Loader.
Up arrow icon