Trabajar con vistas de tareas

Aspose.Tasks for C ++ API admite la representación de tareas del proyecto a una variedad de formatos, como PDF. El uso de la tarea se puede representar utilizando el formato de presentación de Aspose.Tasks con diferentes configuraciones de tiempo como días, terceros y meses.

Vista de uso de tareas de representación

El fragmento de código en este artículo lee un archivo MPP de origen que tiene una serie de tareas con los recursos asignados y los hace para obtener PDF utilizando los siguientes pasos:

  1. Cree una instancia de la clase de proyecto.
  2. Lea el archivo MPP de origen.
  3. Inicie el objeto SaveOptions con la configuración de la escala de tiempo requerida.
  4. Establezca el formato de presentación en Taskusage.
  5. Renderizar el proyecto a la salida 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.