Work with Task Views

Aspose.Tasks for C++ API supports rendering project tasks to a variety of formats, such as PDF. Task usage can be rendered using Aspose.Tasks’ PresentationFormat 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:

  1. Create an instance of the Project class.
  2. Read the source MPP file.
  3. Initiate the SaveOptions object with required timescale settings.
  4. Set the presentation format to TaskUsage.
  5. Render the project to PDF output.
 1// Create project instance
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"TaskUsageView.mpp");
 4    
 5// Define the SaveOptions with required TimeScale settings as Days
 6System::SharedPtr<SaveOptions> options = System::MakeObject<PdfSaveOptions>();
 7options->set_Timescale(Aspose::Tasks::Visualization::Timescale::Days);
 8    
 9// Set the Presentation format to ResourceUsage
10options->set_PresentationFormat(Aspose::Tasks::Visualization::PresentationFormat::TaskUsage);
11    
12// Save the Project
13System::String outputProject = u"project_TaskUsageView_result_days_out.pdf";
14project1->Save(dataDir + outputProject, options);
15    
16// Set the Tiemscale settings to ThirdsOfMonths
17options->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
18    
19// Save the Project
20outputProject = u"project_TaskUsageView_result_thirdsOfMonths_out.pdf";
21project1->Save(dataDir + outputProject, options);
22    
23// Set the Timescale settings to Months
24options->set_Timescale(Aspose::Tasks::Visualization::Timescale::Months);
25    
26// Save the project
27outputProject = u"project_TaskUsageView_result_months_out.pdf";
28project1->Save(dataDir + outputProject, 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:

The following code example illustrates the usage of this property.

 1// Create project instance
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"TaskUsageViewWithDetails.mpp");
 4    
 5// Get Default view
 6System::SharedPtr<UsageView> view = System::DynamicCast_noexcept<Aspose::Tasks::TaskUsageView>(project1->get_DefaultView());
 7    
 8// Details header column will not be displayed
 9view->set_DisplayDetailsHeaderColumn(false);
10view->set_RepeatDetailsHeaderOnAllRows(false);
11view->set_AlignDetailsData(System::Drawing::StringAlignment::Near);
12project1->Save(dataDir + u"task usage1_out.pdf", Aspose::Tasks::Saving::SaveFileFormat::PDF);
13    
14// Display details header column
15view->set_DisplayDetailsHeaderColumn(true);
16    
17// Repeat details header on all assignments rows
18view->set_RepeatDetailsHeaderOnAllRows(true);
19view->set_AlignDetailsData(System::Drawing::StringAlignment::Far);
20project1->Save(dataDir + u"task usage2_out.pdf", Aspose::Tasks::Saving::SaveFileFormat::PDF);

Rendering Task Sheet 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:

  1. Create an instance of the Project class.
  2. Read the source MPP file.
  3. Initiate the SaveOptions object with required timescale settings.
  4. Set the presentation format to TaskSheet.
  5. Render the project to PDF output.
1// Create project instance
2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"TaskSheetView.mpp");
4    
5// Set presentation format Task Sheet and save project as PDF
6System::SharedPtr<SaveOptions> options = System::MakeObject<PdfSaveOptions>();
7options->set_PresentationFormat(Aspose::Tasks::Visualization::PresentationFormat::TaskSheet);
8project1->Save(dataDir + u"TaskSheetView_out.pdf", options);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.