MPP to CSV in C#

When working with Microsoft Project files (MPP), converting them to CSV format can be essential for data analysis, sharing, or importing into other applications. In this guide, we’ll walk through how to convert MPP to CSV in C#, allowing for basic conversion, customization of delimiters, and exporting specific data views.

The headings below elaborate on different aspects of the conversion:

Why Convert MPP to CSV?

Converting MPP files to CSV offers several benefits:

  • Enhanced Compatibility: CSV is a universal format that can be opened in various applications, such as Excel, Google Sheets, and database systems, making MPP data more accessible for non-Project users.

  • Simplified Data Analysis: CSV format allows easy data manipulation and analysis, enabling project managers and analysts to extract insights without using specialized project management software.

  • Data Export Flexibility: CSV files support selective export of data (e.g., only tasks or resources), allowing customized views and specific data for different reporting or analysis needs.

MPP to CSV Conversion - C# API Installation

You can convert MPP file to CSV by installing Conholdate.Total for .NET by using the following NuGet installation command:

PM> NuGet\Install-Package Conholdate.Total

Convert MPP to CSV in C#

The simplest way to convert an MPP file to CSV involves loading the MPP file and saving it directly as a CSV without any customizations.

  • Create an instance of the Project class to load the input MPP file.
  • Render the output CSV file using the Save method.

The following code snippet explains how to convert MPP to CSV in C#:

Convert MPP to CSV with Custom Options in C#

To further customize your CSV output, such as changing the delimiter, we can use the CsvOptions class. This is especially useful if you need a different delimiter than the default semicolon or if you want to ensure compatibility with different applications.

The following steps show how to convert MPP to CSV with custom properties:

  • Load the input MPP file by initiating an object of the Project class.
  • Create CsvOptions class object.
  • Export the output CSV file.

The sample code below shows how to convert MPP to CSV with custom options using C#:

In this example, we set the TextDelimiter property to Comma, but you can also use options such as Semicolon, Space, or Tab by referencing the CsvTextDelimiter enumeration.

Convert Microsoft Project File to CSV with Different Views in C#

During MPP to CSV conversion, by default the Gantt Chart view determines which columns are exported. To export different data views, such as resources or assignments, you can adjust the DataCategory property in CsvOptions.

The code snippet below shows how to convert MPP to CSV with different views in C#:

In this example, setting DataCategory to Resources will export data relevant to project resources instead of tasks. You can also choose DataCategory.Assignments or DataCategory.Tasks to tailor the CSV output to your needs.

Get a Free License

You can get a free temporary license to test different features offered by the API. It lets you avoid the evaluation watermarks and several other evaluation restrictions so that you can test the capabilities as per your POC.

Summing up

Converting MPP files to CSV format in C# is flexible and easy. Whether you need a simple conversion, a custom delimiter, or specific views, it provides a versatile solution for managing your project data. With these options, you can customize your output for optimal compatibility and usability. If you need any assistance or information then please write to us at the forum.

See Also