タスクの使用ビューをレンダリングします
Contents
[
Hide
Show
]JavaのAspose.Tasksは、PDFなどのさまざまな形式へのレンダリングプロジェクトタスクをサポートしています。タスクの使用は、日、3ヶ月、月、数ヶ月などの異なるタイムスケール設定を持つAspose.TasksのPresentionFormatを使用してレンダリングできます。
タスクの使用ビューをレンダリングする
この記事のコードスニペットは、割り当てられたリソースを備えたいくつかのタスクを備えたソースMPPファイルを読み取り、これらを次の手順を使用してPDFを出力します。
- プロジェクトリーダーのインスタンスを作成します。
- ソースMPPファイルをお読みください。
- 必要なタイムスケール設定でSaveOptionsオブジェクトを開始します。
- プレゼンテーション形式をTaskUsageに設定します。
- プロジェクトをPDF出力にレンダリングします。
1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
2// The path to the documents directory.
3String dataDir = Utils.getDataDir(RenderTaskUsage.class);
4//Read the source Project
5Project project = new Project(dataDir + "RenderMe.mpp");
6//Define the SaveOptions with required TimeScale settings as Days
7SaveOptions options = new PdfSaveOptions();
8options.setTimescale(Timescale.Days);
9//Set the Presentation format to ResourceUsage
10options.setPresentationFormat(PresentationFormat.TaskUsage);
11String days = "result_days.pdf";
12//Save the Project
13project.save(days, options);
14
15//Set the Tiemscale settings to ThirdsOfMonths
16options.setTimescale(Timescale.ThirdsOfMonths);
17String thirds = "result_thirdsOfMonths.pdf";
18//Save the Project
19project.save(thirds, options);
20
21//Set the Timescale settings to Months
22options.setTimescale(Timescale.Months);
23String months = "result_months.pdf";
24//Save the project
25project.save(months, options);
Rendering Details Column to Output in Task Usage View
The details column included in the MPP file can be rendered to the output using the View’s DisplayDetailsHeaderColumn property. The following code sample illustrates the usage of this property.
1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
2// The path to the documents directory.
3String dataDir = Utils.getDataDir(RenderTaskUsage.class);
4Project project = new Project(dataDir + "Advanced Tracking C_Start.mpp"); // attached test project
5// Default view in this mpp is TaskUsageView
6UsageView view = (UsageView) project.getDefaultView();// as TaskUsageView;
7
8// details header column will not be displayed
9view.setDisplayDetailsHeaderColumn(false);
10view.setRepeatDetailsHeaderOnAllRows(false);
11view.setAlignDetailsData(StringAlignment.Near);
12project.save("task usage1.pdf", SaveFileFormat.PDF);
13
14// display details header column
15view.setDisplayDetailsHeaderColumn(true);
16// Repeat details header on all assignments rows
17view.setRepeatDetailsHeaderOnAllRows(true);
18view.setAlignDetailsData(StringAlignment.Far);
19project.save("task usage2.pdf", SaveFileFormat.PDF);
20project.save("task usage2.pdf", SaveFileFormat.PDF);