Importing and Exporting Projects to Primavera

Primavera Proprietary Exchange Format (XER), developed by Oracle Inc., is widely used in the Primavera P6 Project Management solution. In many enterprise environments, project data needs to be exchanged between Microsoft Project and Primavera, which use different internal formats.

Aspose.Tasks for .NET provides a reliable way to import and export projects between these systems, supporting XER, XML (P6XML), MPX, and Primavera databases (including SQLite standalone DBs). This ensures smooth collaboration when multiple project management platforms are involved.

Importing Data from Primavera File

Importing Data from Primavera XML File Formats

Aspose.Tasks can import Primavera XML similar to Microsoft Project XML and MPP formats. The Project class provides the capability of loading such type of file using the same constructor as used for other Project files.

1Project project = new Project("Project.xml");
2ProjectFileInfo info = Project.GetProjectFileInfo("Project.xml");
3Console.WriteLine(info.ProjectFileFormat);

Importing Data from Primavera MPX File Formats

This example demonstrates how to load a project stored in MPX format.

1Project project = new Project("Primavera1.mpx");
2ProjectFileInfo info = Project.GetProjectFileInfo("primavera1.mpx");
3Console.WriteLine(info.ProjectFileFormat);

Reading Project UIDs from Primavera XML file

A Primavera XML file may contain multiple projects, each having its own UID. Aspose.Tasks for .NET API provides the capability to read all such UIDs from the project and then load a project using a specific id from the list of UIDs.

1PrimaveraXmlReader reader = new PrimaveraXmlReader("Project.xml");
2List<int> listOpProjectUids = reader.GetProjectUids();

Reading Primavera XML file with Multiple Projects

The following example shows how to handle Primavera XML files containing multiple projects.

1PrimaveraXmlReadingOptions options = new PrimaveraXmlReadingOptions();
2options.ProjectUid = 4557;
3// Returns project with special Uid
4Project project = new Project("Project.xml", options); 

Importing Project Data From Primavera Database

Aspose.Tasks for .NET API provides the capability to read Project data from Primavera Database. The following example code shows how to use the Project class for reading from the database.

 1SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();
 2sb.DataSource = "192.168.56.3,1433";
 3sb.Encrypt = true;
 4sb.TrustServerCertificate = true;
 5sb.InitialCatalog = "PrimaveraEDB";
 6sb.NetworkLibrary = "DBMSSOCN";
 7sb.UserID = "privuser";
 8sb.Password = "***";
 9
10// Initialize a new instance of the PrimaveraDbSettings class with connection string and project id
11PrimaveraDbSettings settings = new PrimaveraDbSettings(sb.ConnectionString, 4502);
12
13// Initialize a new instance of the Project class
14Project project = new Project(settings);

Support for Primavera SQLite Database

Standalone Primavera P6 SQLite databases are also supported, enabling offline project data access.

1const int projectId = 4502;
2// Create Primavera DB Settings using connection string and project id
3PrimaveraDbSettings primaveraDbSettings = new PrimaveraDbSettings("Data Source=\\PPMDBSQLite.db", projectId);
4primaveraDbSettings.ProviderInvariantName = "System.Data.SQLite";
5// Create new project using primavera db settings
6Project project = new Project(primaveraDbSettings);

Exporting Project Data in Primavera Formats

Aspose.Tasks supports exporting project data using the SaveFileFormat enumerator, with options for XML, XER, and MPX formats.

Exporting Project Data to Primavera XML Format

1Project project = new Project("New Project.mpp");
2project.Save("ExportProjectDataToXMLFormat_out.xml", SaveFileFormat.PrimaveraP6XML);

Exporting Project Data to Primavera XER Format

1Project project = new Project("New Project.mpp");
2project.Save("ExportProjectDataToXERFormat_out.mpp", SaveFileFormat.PrimaveraXER);

Exporting Project Data to Primavera MPX Format

1Project project = new Project("New Project.mpp");
2project.Save("ExportProjectDataToPrimaveraMPXFormat_out.xml", SaveFileFormat.MPX);

Primavera XML Save Options

If Primavera XML file doesn’t have any WBS inside (only Activities), Aspose.Tasks can’t read properly this type of file, because the API needs a root task to create a tree of tasks. In this case, the API creates a RootTask, even if it doesn’t exist in the file, to be able to read these particular files. If the user wants to save after reading, It’ll be saving with created RootTask, which did not exist before reading. This option helps to decide how to save into the file with created RootTask or not. By default it is set to true.

1Project project = new Project("project.xml");
2
3// Specify xml save options
4PrimaveraXmlSaveOptions options = new PrimaveraXmlSaveOptions();
5options.SaveRootTask = false;
6project.Save("UsingPrimaveraXMLSaveOptions_out.xml", options);

By using Aspose.Tasks for .NET, you can:

This makes Aspose.Tasks an essential tool for organizations that need seamless interoperability between Microsoft Project and Primavera environments, ensuring smooth data exchange and minimizing manual work.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.