프로젝트 페이지 다루기
Aspose.Tasks for .NET은 프로젝트의 총 페이지 수를 가져올 수 있습니다. GetPageCount 메서드는 Aspose.Tasks.Visualization 네임스페이스는 프로젝트의 총 페이지 수를 반환하며, 이를 다음을 기준으로 렌더링하는 옵션을 제공합니다: Timescale.Days, Timescale.Months or Timescale.ThirdsOfMonths.
프로젝트의 페이지 수 가져오기
해당 Project 클래스는 GetPageCount 메서드를 제공합니다.
다양한 시간 척도:
Timescale.Days
– 작업과 자원을 일별로 표시합니다.Timescale.Months
– 월 단위로 집계합니다.Timescale.ThirdsOfMonths
– 각 월을 3등분합니다.
프로젝트를 PDF로 저장하려면:
- Microsoft Project 파일을 로드합니다.
- 선택적 시간 척도 설정과 함께 GetPageCount 메서드를 사용하여 프로젝트의 총 페이지 수를 가져옵니다.
프로그래밍 샘플: 프로젝트의 페이지 수 가져오기
다음 코드 줄은 C#을 사용하여 이를 수행하는 방법을 보여줍니다.
1Project project = new Project("New Project.mpp");
2
3// Get number of pages, Timescale.Months, Timescale.ThirdsOfMonths
4int iPages = project.GetPageCount();
5iPages = project.GetPageCount(Timescale.Months);
6iPages = project.GetPageCount(Timescale.ThirdsOfMonths);
다른 보기의 페이지 수 가져오기
Aspose.Tasks for .NET은 다음 보기를 Resource Usage, Resource Sheet및 Task Usage 보기를 PDF로 렌더링할 수 있습니다. 또한 각 보기별로 페이지 수를 계산할 수 있습니다. 이 프로그래밍 샘플은 프로젝트의 사용 보기를 렌더링하고 렌더링된 출력의 페이지 수를 가져오는 과정을 보여줍니다.
예제: 보기의 페이지 수 가져오기 (C#)
1Project project = new Project("New Project.mpp");
2
3// Get number of pages, Months and ThirdsOfMonths
4Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.Days)));
5Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.Months)));
6Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.ThirdsOfMonths)));
날짜 범위로 페이지 수 필터링
특정 날짜 범위(시작–종료)의 페이지 수를 계산해야 하는 경우,
Aspose.Tasks는 다음과 같은 오버로드를 제공합니다. GetPageCount
이 오버로드 메서드는 DateTime
매개변수를 허용합니다.
프로그래밍 샘플: 시작 및 종료 날짜를 기준으로 페이지 수 가져오기
1Project project = new Project("New Project.mpp");
2
3ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.PNG)
4{
5 SaveToSeparateFiles = true,
6 PageSize = PageSize.A3,
7 Timescale = Timescale.Months,
8 StartDate = project.Get(Prj.StartDate) - TimeSpan.FromDays(10),
9 EndDate = project.Get(Prj.FinishDate) + TimeSpan.FromDays(30)
10};
11int pageCount = project.GetPageCount(
12 PageSize.A3,
13 Timescale.Months,
14 project.Get(Prj.StartDate) - TimeSpan.FromDays(10),
15 project.Get(Prj.FinishDate) + TimeSpan.FromDays(30));
16
17Console.WriteLine(pageCount);