MicrosoftプロジェクトファイルをCSV形式に変換する方法

この記事では、Microsoftプロジェクトファイルを変換するための詳細な指示とコードサンプルを提供します。フィルタリング、ソート、エンコード、デリミッター設定、ヘッダーの可視性などのさまざまなエクスポートオプションも実証されています。

MSプロジェクトファイルをCSVに変換

Microsoft Project ProjectをCSV(Comma分離値)形式に変換するには、 savefileformat列挙または csvoptionsクラスを使用するには、2つの方法があります。

SaveFileFormatを使用して、MS Project MPPファイルをCSV形式に変換するために、デフォルト設定でCSV形式に変換するため。

  1. 新しいプロジェクトインスタンスを作成し、MPPファイルをロードします。
  2. Project.saveメソッドを使用してプロジェクトをCSVに変換し、savefileformat.csvを引数として指定します。

To convert MPP files with a non-default settings the CsvOptions class can be used. The CsvOptions class allows specification of additional export parameters while rendering project pages to CSV.

  1. Create a new project instance and load the MPP file.
  2. Convert the project to CSV using the Project.Save method and pass the CsvOptions instance as the argument.

Presented below is .NET example showing how to change text delimiter using the options:

How to change the view while convert MPP to CSV

By default the Gantt Chart view is used to decide what column headers will be exported. To change the view the DataCategory property can be used:

How to sort tasks while converting to CSV

By using CsvOptions one can tune the export parameters e.g. control the view to export and/or filter exported tasks. Lets take a look at some of the options available.

For example, one can customize the sorting order of the tasks by assigning a custom comparer to the TasksComparer property. Presented below is the example where tasks sorted by name are exported reversed order:

How to Filter Tasks While Convert to CSV

In order to filter the exported tasks one can specify the task filter by assigning a custom condition to the TasksFilter property:

How to change delimiter while converting to CSV

CSV is a text format that uses text delimiters to split data fields. To change the text delimiter one can set the TextDelimiter property to one of the next values:

The available delimiters are defined in CsvTextDelimiter enumeration.

Presented below is the example in which data fields are being split by tab symbol:

How to change encoding while converting to CSV

By default CSV is being exported in Encoding.Default encoding. To change the encoding the Encoding property can be used:

How to hide column headers while converting to CSV

By default column headers are being exported in CSV format. To suppress export of column headers the IncludeHeaders property can be used:

In summary, Aspose.Tasks for .NET provides a flexible and extensible API for exporting project data to CSV format. The CsvOptions class allows customization of output according to specific project requirements, such as task filtering, sorting, and text encoding.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.