Import and Export Project Data to Primavera Format

Primavera Proprietary Exchange Format (XER), by Primavera Systems, Inc., is primarily associated with Primavera Project Management. Aspose.Tasks for C++ provides the capability to export Microsoft Project Data to Primavera XER as well as XML formats. This article demonstrates how to import or export to a variety of Primavera supported formats.

Importing Data from Primavera File

Aspose.Tasks for C++ facilitates to import project data from Primavera XML or MPX formats.

Importing Data from Primavera XML File Formats

Aspose.Tasks for C++ 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.

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project.xml");
2System::SharedPtr<ProjectFileInfo> info = Project::GetProjectFileInfo(dataDir + u"Project.xml");
3System::Console::WriteLine(System::ObjectExt::Box<FileFormat>(info->get_ProjectFileFormat()));

Importing Data from Primavera MPX File Formats

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Primavera1.mpx");
2System::SharedPtr<ProjectFileInfo> info = Project::GetProjectFileInfo(dataDir + u"primavera1.mpx");
3System::Console::WriteLine(System::ObjectExt::Box<FileFormat>(info->get_ProjectFileFormat()));

Reading Project UIDs from Primavera XML file

A Primavera XML file may contain multiple projects, each having its own UID. Aspose.Tasks for C++ 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.

1System::SharedPtr<PrimaveraXmlReader> reader = System::MakeObject<PrimaveraXmlReader>(dataDir + u"Project.xml");
2System::SharedPtr<System::Collections::Generic::List<int32_t>> listOpProjectUids = reader->GetProjectUids();

Reading Primavera XML file with Multiple Projects

1System::SharedPtr<PrimaveraXmlReadingOptions> options = System::MakeObject<PrimaveraXmlReadingOptions>();
2options->set_ProjectUid(4557);
3// Returns project with special Uid
4System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project.xml", options);

Exporting Project Data in Primavera Formats

The SaveFileFormat enumerator is used to specifying the project export type as Primavera XML or XER.

Exporting Project Data to Primavera XML Format

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project1.mpp");
2    
3// Save project in desired format
4project->Save(dataDir + u"ExportProjectDataToXMLFormat_out.xml", Aspose::Tasks::Saving::SaveFileFormat::PrimaveraP6XML);

Exporting Project Data to Primavera XER Format

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project1.mpp");
2    
3// Save project in desired format
4project->Save(dataDir + u"ExportProjectDataToXERFormat_out.mpp", Aspose::Tasks::Saving::SaveFileFormat::PrimaveraXER);

Exporting Project Data to Primavera MPX Format

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project1.mpp");
2    
3// Save project in desired format
4project->Save(dataDir + u"ExportProjectDataToPrimaveraMPXFormat_out.xml", Aspose::Tasks::Saving::SaveFileFormat::MPX);

Primavera XML Save Options

If Primavera XML file doesn’t have any WBS inside (only Activities), Aspose.Tasks for C++ 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.

1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"project.xml");
2    
3// Specify xml save options
4System::SharedPtr<PrimaveraXmlSaveOptions> options = System::MakeObject<PrimaveraXmlSaveOptions>();
5options->set_SaveRootTask(false);
6project->Save(u"UsingPrimaveraXMLSaveOptions_out.xml", options);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.