Microsoft Project Files Conversion Via C#

Convert Microsoft Project MPP, MPT, MPX to PDF, Excel, HTML and Images including BMP, JPG, PNG, TIFF to build cross-platform .NET applications.

Microsoft Project application is to assist project managers for complete planning, tracking progress, assigning resources and analyzing workloads. And whenever there is need to handle Microsoft Project MPP, MPT, MPX files within company .NET solution without installing Microsoft Project, .NET Project file handling API is there to do all this. It can easily manage, create, modify documents as well as convert to other files. Below code works perfactly well and can easily be integrated within the solution.

Microsoft Project to PDF Conversion

Microsoft Project to PDF conversion, Process is, Load the Microsoft Project file MPP, MPT or MPX using Project class . Call the save method and with output PDF file and SaveFileFormat .PDF as parameters. During conversion process all the tasks, resources, and resource assignment data will be rendered.

C# Code for Microsoft Project to PDF Conversion

1. // load the file to be converted

2. var prjectToHTML = new Project(dir + "template.mpp");

3. // save in different formats

4. prjectToHTML.Save(dir + "output.html", SaveFileFormat.HTML);

Convert Microsoft Project to Images JPG, PNG, BMP, TIFF

Converting Microsoft Project files MPP, MPT, MPX to image formats is almost same, the only difference is SaveFileFormat extension and image format. So Just load the file using Project class and call the save method while passing the relevant output image format and SaveFileFormat as parameters. If there is need for additional Image settings, API provides ImageSaveOptions to save rendered images in JPG, PNG, BMP or TIFF files.

C# Code for Converting Microsoft Project to Image Formats

1. // load project file

2. var projectToImages = new Project(dir + "template.mpp");

3. // create ImageSaveOptions with desired Image format currently MPP to JPG

4. var ImageOptions = new ImageSaveOptions(Aspose.Tasks.Saving.SaveFileFormat.JPEG)

5.  {
    CustomPageSize = new SizeF(2200, 1100),
    HorizontalResolution = 96f,
    VerticalResolution = 96f,

    JpegQuality = 70

    };

6. // render data to image format

7. projectToImages.Save(dir + "output.jpg", ImageOptions);

Microsoft Project to HTML Conversion

Process of conversion of Microsoft Project to HTML is almost same as of PDF, the only difference is SaveFileFormat HTML extension. So Just load the file using Project class and call the save method while passing the relevant output HTML file and SaveFileFormat.HTML as parameters.

C# Code for Microsoft Project to HTML Conversion

1. // Read the input Project MPP file
2. Project projectToCSV = new Project("Project.mpp");

3. // Initialize CsvOptions class instance
4. Aspose.Tasks.Saving.CsvOptions CSVOpts = new Aspose.Tasks.Saving.CsvOptions();
5. CSVOpts.TextDelimiter = Aspose.Tasks.Saving.CsvTextDelimiter.Semicolon;

6. // Save output CSV file
7. projectToCSV.Save("output.csv", CSVOpts);

Convert Microsoft Project to Excel XLSX, CSV File

.NET MS Project Files API proivdes XlsxOptions for converting Project to XLSX and CsvOptions for converting MPP, MPT, MPX to CSV files. Developers can specify relevant options by using these classes. All other process is same.

C# Code for Microsoft Project to CSV Conversion

1. // load the file to be converted

2. var prjectToHTML = new Project(dir + "template.mpp");

3. // save in different formats

4. prjectToHTML.Save(dir + "output.html", SaveFileFormat.HTML);