How to limit appointment data based on a date range in Blazor Scheduler?
Step 1: By default, the whole event collection bound to the Scheduler gets exported as an excel file.
Step 2: To export only specific events of Scheduler or some custom event collection, you need to pass those custom data collection as a parameter to the ExportToExcelAsync method through the CustomData option.
Step 3: Filter the appointment data based on StartTime and EndTime. When using ExportToExcelAsync, you need to filter the data and pass the filtered data in CustomData within the ExportOptions.
public async TaskOnExportToExcel()
{
DateTime startDate = new DateTime(2020, 1, 8);
DateTime endDate = new DateTime(2020, 1, 9);
var filteredData = DataSource.Where(x => x.StartTime >= startDate && x.EndTime <= endDate).ToList();
List<ExportFieldInfo> exportFields = new List<ExportFieldInfo>();
exportFields.Add(new ExportFieldInfo { Name = "Id", Text = "ScheduleID" });
exportFields.Add(new ExportFieldInfo { Name = "Subject", Text = "subject" });
exportFields.Add(new ExportFieldInfo { Name = "StartTime", Text = "sStart" });
exportFields.Add(new ExportFieldInfo { Name = "EndTime", Text = "sEnd" });
exportFields.Add(new ExportFieldInfo { Name = "Description", Text = "descr" });
ExportOptions options = new ExportOptions() { ExportType = ExcelFormat.Xlsx, FieldsInfo = exportFields, CustomData = filteredData };
await ScheduleRef.ExportToExcelAsync(options);
}
Sample: https://blazorplayground.syncfusion.com/LtBzDTCcrjbKMqfV
See Also: https://blazor.syncfusion.com/documentation/scheduler/exporting#exporting-custom-event-data
Conclusion
I hope you enjoyed learning about how to limit appointment data based on a date range while excel exporting in Blazor scheduler.
You can refer to our Blazor Scheduler feature tour page to know about its other ground breaking feature representations and documentation , and how to quickly get started for configuration specifications. You can also explore our Blazor Scheduler example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!