Back to Devexpress

How to: Load Holidays from the Outlook.hol file

windowsforms-3309-controls-and-libraries-scheduler-examples-date-and-time-how-to-load-holidays-from-the-outlookhol-file.md

latest1.8 KB
Original Source

How to: Load Holidays from the Outlook.hol file

  • Aug 01, 2019

If you have Microsoft® Outlook installed on your machine, it may be useful to obtain the holidays list, which is shipped with its installation. For example, if you’ve installed Microsoft Office 2013 English (United States) in default location, this file can be found in the following path:

C:\Program Files\Microsoft Office\Office15\1033\Outlook.hol

This file contains all known holidays for several countries (marked in square brackets and called as locations) in the following format:

…__[United States] 168__Christmas Day,2006/12/25 Christmas Day,2007/12/25 Christmas Day,2008/12/25 Christmas Day,2009/12/25 Christmas Day,2010/12/25 Christmas Day,2011/12/25 Christmas Day,2012/12/25 Christmas Eve,2006/12/24

XtraScheduler provides the supplementary OutlookHolidaysLoader class, which is intended to load holidays from the Outlook.hol file via its FromFile or FromStream methods. So, you may obtain a collection of days which are treated as holidays for the specified country, and add these holidays to the SchedulerControl.WorkDays collection of a Scheduler Control.

The code below demonstrates how this can be done.

csharp
OutlookHolidaysLoader loader = new OutlookHolidaysLoader();
HolidayBaseCollection holidays = loader.FromFile(OutlookHolidaysFilePath, Locations);
schedulerControl1.WorkDays.AddRange(holidays);
vb
Dim loader As New OutlookHolidaysLoader()
Dim holidays As HolidayBaseCollection = loader.FromFile(OutlookHolidaysFilePath, Locations)
schedulerControl1.WorkDays.AddRange(holidays)