Read Timephased Data of a Resource

Aspose.Tasks for Java supports reading a resource’s timephased data from Microsoft Project (MPP) files.

Reading Timephased Resource Data The timephased data is retrieved using the Resource object’s TimeScaleData method. For time-phased data of resource work,

The following piece of code shows to read a resource’s time-phased data.

 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(ReadTimephasedData.class);
 4
 5// Read Microsoft Project template file
 6String fileName = "SampleProject.mpp";
 7
 8// Read the input file as Project
 9Project project = new Project(dataDir + "SampleProject.mpp");
10
11// Get the Resource by its ID
12Resource resource = project.getResources().getByUid(1);
13
14// Print Timephased data of ResourceWork
15System.out.println("Timephased data of ResourceWork");
16for (TimephasedData td : resource.getTimephasedData(project.get(Prj.START_DATE),
17        project.get(Prj.FINISH_DATE))) {
18    System.out.println("Start: " + td.getStart().toString());
19    System.out.println(" Work: " + td.getValue());
20}
21// Print Timephased data of ResourceCost
22System.out.println("Timephased data of ResourceCost");
23for (TimephasedData td : resource.getTimephasedData(project.get(Prj.START_DATE), project.get(Prj.FINISH_DATE),
24        TimephasedDataType.ResourceCost)) {
25    System.out.println("Start: " + td.getStart().toString());
26    System.out.println(" Cost: " + td.getValue());
27}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.