Работать с представлениями задачи
Aspose.Tasks для C ++ API поддерживает рендеринг задач проекта для различных форматов, таких как PDF. Использование задач может быть отображено с помощью Aspose.Tasks ‘PresentationFormat с различными настройками временного масштаба, такими как дни, третьи месяцы и месяцы.
рендеринговое представление об использовании задачи
Фрагмент кода в этой статье гласит исходный файл MPP, в котором есть несколько задач с назначенными ресурсами и делает их выводом PDF, используя следующие шаги:
- Создайте экземпляр класса проекта.
- Прочитайте исходный файл MPP.
- Инициируйте объект SavePtions с необходимыми настройками времени масштаба.
- Установите формат презентации в TaskUsage.
- Отправить проект в выход 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:
- Work
- Actual Work
- Actual Overwork time
- Baseline Work
- Baseline 1-10 Work
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:
- 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 TaskSheet.
- 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);