Resource and Calendars

The Resource class exposes the Calendar property which is used to set or get the calendar for a resource. This property accepts and returns an Calendar object.

Working with Resource Calendars

To define a calendar for a resource in Microsoft Project:

  1. In the Resource Sheet, double-click the desired resource.
  2. Click the Change Working Time button.

Changing working times in Microsoft Project

changing working times in Microsoft Project

Setting Resource Calendar using Aspose.Tasks

The following code creates a standard calendar and resource and then assigns the calendar to the resource.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(ResourceAndCalendars.class);
 4
 5Project project = new Project(dataDir + "input.mpp");
 6ResourceCollection alRes = project.getResources();
 7for (Resource res : alRes) {
 8    if (res.get(Rsc.NAME) != null) {
 9        // code to display res.Calendar properties
10    }
11}

Getting Resource Calendar using Aspose.Tasks

The code below shows how to set resource calendars by traversing a project’s resources.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(ResourceAndCalendars.class);
 4
 5Project project = new Project();
 6Resource res = project.getResources().add("Resource1");
 7
 8// add standard calendar
 9Calendar cal = project.getCalendars().add("Resource1");
10res.set(Rsc.CALENDAR, cal);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.