In this topic, we will explore how to convert MPP to XPS using C++. XPS is a widely used file format and you can easily export MPP file to XPS in C++ using few API calls with no dependence on MS Project.
Steps to Convert MPP to XPS using C++
- Install Aspose.Tasks for C++ using NuGet package Manager tool
- Include reference to Aspose::Tasks namespace
- Instantiate Project class instance to load the MPP file to save as XPS
- Save the MPP file to XPS in C++ using Save method
You can export MPP file to XPS in C++ in few API calls. All you need is to access the MPP file and then save that as XPS in subsequent API call using C++.
Code to Convert MPP to XPS using C++
#pragma once | |
#include <Project.h> | |
#include <Task.h> | |
#include<License/License.h> | |
#include<Saving/Enums/SaveFileFormat.h> | |
#include<Prj.h> | |
#include <system/string.h> | |
#include <system/console.h> | |
#include <system/environment.h> | |
#include <system/shared_ptr.h> | |
#include <system/environment.h> | |
#include <system/object_ext.h> | |
#include <system/object.h> | |
#include <stdio.h> | |
using namespace Aspose::Tasks; | |
using namespace Aspose::Tasks::Saving; | |
using namespace System; | |
void MPPToXPS() | |
{ | |
// Set license to perform MPP to XPS conversion | |
SharedPtr<License> AsposeTasksLicense = System::MakeObject<License>(); | |
AsposeTasksLicense->SetLicense(u"licFile"); | |
// The path to sour MPP file and directory. | |
System::String SourceFile = u"SourceMPPFile.mpp"; | |
// Load the source MPP file to export to XPS | |
SharedPtr<Project> MppToXps = MakeObject<Project>(SourceFile); | |
// Save the MPP to XPS in C++ | |
MppToXps->Save(u"MPPSavedToXPS.xps", SaveFileFormat::XPS); | |
} |
Earlier, we learnt how to extract Microsoft Project file metadata in C++. However, in this topic we have focused on MPP to XPS conversion in C++.