조회수 작업

특정보기 데이터 읽기

보기는 프로젝트 또는 일부 측면 (리소스, 작업 등)의 그래픽 표현을 제공합니다. 예를 들어, Gantt 차트는 프로젝트 진행 상황과 계획을 그래픽으로 표현합니다.

Microsoft 프로젝트의 간트 차트

Microsoft Project를 사용하면 바 스타일 정보, 그리드 라인 속성, 진행 라인 속성, 시간 규모 정보, 페이지 속성 등과 같은 다른 뷰의 속성을 사용자 정의 할 수 있습니다. 이러한 모든 속성은 MPP 파일에 저장됩니다. .NET 용 astasks는 view 클래스 또는 상속자를 사용하여 모든 속성에 개별적으로 액세스 할 수있는 기능을 제공합니다. 이 기능은 Microsoft Project 2003, 2007, 2010, 2013, 2016, 2019 및 2021 MPP 파일 형식에 지원됩니다.

Configure Gantt Chart View by Showing Selected Custom Fields

Extended attributes added to a project may be assigned to a task. It may be desirable to add this custom field to a saved MPP file’s default view, or you might want selected custom fields to be shown automatically rather than selecting them manually. This article describes how to achieve this by customizing the Table of a Project.

Customizing Timescale Tier Labels according to Current Culture Information

Aspose.Tasks for .NET API provides the capability to customize Timescale tier labels according to the current CultureInfo of the machine. The DateTimeConverter(DateTime date) delegate provides a converter method to convert date to a string in view timescale tiers. In addition, TimescaleTier.DateTimeConverter enables rendering of date in the desired format.

Customizing Timescale settings for a specific view and render a view using these settings

The TimeScaleTier class makes it possible to set the Timescale settings for a view of a project. The below example shows how to achieve this objective using the Aspose.Tasks for .NET API

 1Project project = new Project();
 2
 3// Retrieve project's Gantt chart view
 4GanttChartView view = (GanttChartView)project.Views.First(v => v.Name == "&Gantt Chart");
 5
 6// Set Time Scale count
 7view.BottomTimescaleTier.Count = 2;
 8view.BottomTimescaleTier.ShowTicks = false; 
 9view.BottomTimescaleTier.Unit = TimescaleUnit.Days;
10view.BottomTimescaleTier.Label = DateLabel.DayDdd;
11
12view.MiddleTimescaleTier.Count = 1;
13view.MiddleTimescaleTier.ShowTicks = false;
14view.MiddleTimescaleTier.Unit = TimescaleUnit.Weeks;
15view.MiddleTimescaleTier.Label = DateLabel.WeekDddDd;
16
17// Add some test data to project
18Task task1 = project.RootTask.Children.Add("Task 1");
19Task task2 = project.RootTask.Children.Add("Task 2");
20task1.Set(Tsk.Duration, task1.ParentProject.GetDuration(24, TimeUnitType.Hour));
21task2.Set(Tsk.Duration, task1.ParentProject.GetDuration(40, TimeUnitType.Hour));
22
23PdfSaveOptions saveOptions = new PdfSaveOptions();
24saveOptions.ViewSettings = view;
25
26// Timescale.DefinedInView options should be specified in order to render project using timescale settings 
27// defined in view (in view.BottomTimescaleTier and view.MiddleTimescaleTier properties in this example).
28// Otherwise predefined settings are used when one of Timescale.Days, Timescale.Months, Timescale.ThirdsOfMonths values is used.
29saveOptions.Timescale = Timescale.DefinedInView;
30project.Save("SetTimeScaleCount_out.pdf", saveOptions); 

Support for Text Styling

Text styling can be applied to a Gantt Chart View using TableTextStyle as shown in the following code sample.

Save MPP using the specific Project’s view

The following code example demonstrates the ability to save the MPP to graphical format using the specific view from project’s views. The feature can be useful when several views were defined for the same View screen in MPP project.

1Project project = new Project(Paths.TestdataPath + "TestViews.mpp");
2var view = project.Views.First(v => v.Name == "Customized Resource &Sheet");
3// We can set view's properties before use.
4view.PageInfo.PageSettings.IsPortrait = false;
5PdfSaveOptions saveOptions = new PdfSaveOptions();
6saveOptions.ViewSettings = view;
7project.Save("output.pdf", saveOptions);

Working with bar styles of Gantt chart view

The following code example demonstrates how to modify task’s bar styles for Gantt chart view.

 1Project project = new Project(Paths.TestdataPath + "TestGanttChartView.mpp");
 2var ganttChartView = (GanttChartView)project.Views.First(v => v.Name == "Gantt &Chart");
 3PdfSaveOptions saveOptions = new PdfSaveOptions();
 4saveOptions.Timescale = Timescale.DefinedInView;
 5saveOptions.ViewSettings = ganttChartView;
 6
 7// Bar styles can be either task-specific (located in GanttChartView.CustomBarStyles)
 8// of category-specific (located in GanttChartView.BarStyles)
 9
10foreach (GanttBarStyle ganttBarStyle in ganttChartView.CustomBarStyles)
11{
12    if (ganttBarStyle.ShowForTaskUid != 11)
13    {
14        continue;
15    }
16
17    // For demonstration purposes we are modifying style for Task with Unique ID = 11
18 
19    ganttBarStyle.LeftField = Field.TaskName;
20    // Here we set custom converter to control which text should be rendered inside the task bar.
21    ganttBarStyle.InsideBarTextConverter = task => "Hours rem.: " + (int)task.Get(Tsk.RemainingWork).TimeSpan.TotalHours;
22}
23
24foreach (GanttBarStyle ganttBarStyle in ganttChartView.BarStyles)
25{
26    if (!ganttBarStyle.ShowForCategories.Contains(GanttBarShowFor.Milestone))
27    {
28        continue;
29    }
30
31    // For demonstration purposes we are modifying styles applicable to milestone tasks.
32
33    ganttBarStyle.RightField = Field.TaskActualFinish;
34    // Here we can customize text drawn at the top of task's bar using user provided delegate.
35    ganttBarStyle.TopBarTextConverter = task => task.Get(Tsk.ActualStart).Day.ToString();
36}
37
38project.Save("output.pdf", saveOptions);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.