Oracle Primavera P6 is a project, program and portfolio management software. It is used for planning, managing and executing large engineering projects. In certain cases, we may need to convert the Primavera P6 project into Microsoft Project programmatically. In this article, we will learn how to convert a Primavera XML to an MPP file using C#.
The following topics shall be covered in this article:
- C# API to Convert Primavera XML to MPP
- Convert Primavera P6 XML to MPP
- Import Primavera XML to MPP File
C# API to Convert Primavera XML to MPP
To convert Primavera XML to an MPP file, we will be using the Aspose.Tasks for .NET API. It allows reading and writing MPP/XML files without requiring Microsoft Project to be installed. Moreover, it allows converting and saving MPP files to the supported file formats.
The Project class of the API represents a project. The Save(string, SaveFileFormat) method of this class saves the project data to the file. It provides the CopyTo(Project) method that saves the project data to the file. The SaveFileFormat defines enumeration for saving project format selection.
Please either download the DLL of the API or install it using NuGet.
PM> Install-Package Aspose.Tasks
Convert Primavera P6 XML to MPP using C#
We can easily convert Primavera P6 project XML into an MPP file by following the steps given below:
- Load the XML file using the Project class.
- Save the MPP file using the Save() method. It takes the output MPP file path and the SaveFileFormat as arguments.
The following sample code shows how to convert Primavera P6 XML to MPP in C#.
Import Primavera XML to MPP File using C#
We can easily import Primavera P6 project data from XML into an MPP file by following the steps given below:
- Firstly, load the XML file using the Project class.
- Next, load the MPP template file using the Project class.
- After that, call the CopyTo() method.
- Finally, save the project as an MPP file using the Save() method. It takes the output MPP file path and the SaveFileFormat as arguments.
The following sample code shows how to import Primavera P6 project data from XML to MPP in C#.
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
Conclusion
In this article, we have learned how to:
- load Primavera P6 project XML file;
- copy data from P6 XML to blank MPP project file;
- save loaded XML as MPP in C#.
Besides converting Primavera XML to MPP, you can learn more about Aspose.Note for .NET API using the documentation. In case of any ambiguity, please feel free to contact us at our free support forum.