Travaillez avec les vues des tâches

Aspose.Tasks pour l’API C ++ prend en charge les tâches de projet de rendu à une variété de formats, tels que PDF. L’utilisation des tâches peut être rendue à l’aide de la présentation de présentation de Aspose.Tasks avec différents paramètres de temps comme les jours, les tiers et les mois.

Rendre la vue d’utilisation des tâches

Le code d’extrait de code dans cet article lit un fichier MPP source qui a un certain nombre de tâches avec des ressources attribuées et les rend pour sortir PDF en utilisant les étapes suivantes:

  1. Créez une instance de la classe de projet.
  2. Lisez le fichier Source MPP.
  3. Lancer l’objet SaveOptions avec les paramètres de temps requis.
  4. Définissez le format de présentation sur Taskusage.
  5. Rendez le projet à la sortie PDF.
 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.