Percentage Complete Calculations
Microsoft Project shows the percentage of a task that’s been completed. The percentage can be added manually, by a project manager, or automatically calculated by the application. Aspose.Tasks for Java supports several percentage calculations related to tasks.
Percentages
The Task class exposes several properties used to calculate percentages:
- PercentComplete represents the completed percentage of a task’s duration (integer).
- PercentWorkComplete represents the completed percentage of a task’s work (integer).
- PhysicalPercentComplete represents the completed percentage as entered by a project manager (integer).
To see the physical percent complete in Microsoft Project:
- On the Task Entry form, from the Insert menu, select Column.
- Add the column.
To see the completed percentage in Microsoft Project on the Task Entry form, double-click the desired column:
A task’s completed percentage in Microsoft Project, and, below it, it’s physical completion percentage.
Getting Percentages in Aspose.Tasks
The following example shows how to get the percentages of work relating to tasks using Aspose.Tasks.
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(PercentageCompleteCalculations.class);
4
5Project project = new Project(dataDir + "Input.mpp");
6
7TaskCollection alTasks = project.getRootTask().getChildren();
8for (Task tsk : alTasks) {
9 System.out.println(tsk.get(Tsk.PERCENT_COMPLETE));
10 System.out.println(tsk.get(Tsk.PERCENT_WORK_COMPLETE).toString());
11 System.out.println(tsk.get(Tsk.PHYSICAL_PERCENT_COMPLETE).toString());
12}