Rendering Task Usage View
Contents
[
Hide
Show
]Aspose.Tasks for .NET supports rendering project tasks to a variety of formats, such as PDF. Task usage can be rendered using PresentationFormat of Aspose.Tasks with different timescale settings like Days, ThirdOfMonths and Months.
Rendering Task Usage View
The code snippet in this article reads a source MPP file that has a number of tasks with assigned resources and renders these to output PDF using the following steps:
- Create an instance of the Project class.
- Read the source MPP file.
- Initiate the SaveOptions object with required timescale settings.
- Set the presentation format to TaskUsage.
- Render the project to PDF output.
1Project project = new Project("New Project.mpp");
2
3// Define the SaveOptions with required TimeScale settings as Days
4SaveOptions options = new PdfSaveOptions();
5options.Timescale = Timescale.Days;
6
7// Set the Presentation format to ResourceUsage
8options.PresentationFormat = PresentationFormat.TaskUsage;
9
10project.Save("TaskUsageView_result_days_out.pdf", options);
11
12// Set the Timescale settings to ThirdsOfMonths
13options.Timescale = Timescale.ThirdsOfMonths;
14
15project.Save("TaskUsageView_result_thirdsOfMonths_out.pdf", options);
16
17// Set the Timescale settings to Months
18options.Timescale = Timescale.Months;
19
20project.Save("TaskUsageView_result_months_out.pdf", options);
Rendering Details Column to Output in Task Usage View
Details column included in the MPP file can be rendered to the output using the View’s DisplayDetailsHeaderColumn property. This includes the list of following supported fields:
- Work
- Actual Work
- Actual Overwork time
- Baseline Work
- Baseline 1-10 Work
The following code sample illustrates the usage of this property.
1Project project = new Project("New Project.mpp");
2
3// Get Default view
4UsageView view = project.DefaultView as TaskUsageView;
5
6// Details header column will not be displayed
7view.DisplayDetailsHeaderColumn = false;
8view.RepeatDetailsHeaderOnAllRows = false;
9view.AlignDetailsData = StringAlignment.Near;
10project.Save("task usage1_out.pdf", SaveFileFormat.PDF);
11
12// Display details header column
13view.DisplayDetailsHeaderColumn = true;
14
15// Repeat details header on all assignments rows
16view.RepeatDetailsHeaderOnAllRows = true;
17view.AlignDetailsData = StringAlignment.Far;
18project.Save("task usage2_out.pdf", SaveFileFormat.PDF);