Dalam topik ini, kita akan mempelajari cara mengonversi MPP ke XPS menggunakan C++. XPS adalah format file yang banyak digunakan dan Anda dapat dengan mudah mengekspor file MPP ke XPS di C++ menggunakan beberapa panggilan API tanpa ketergantungan pada MS Project.
Langkah-langkah untuk Mengkonversi MPP ke XPS menggunakan C++
- Instal Aspose.Tasks for C++ menggunakan alat Pengelola paket NuGet
- Sertakan referensi ke Aspose::Tasks namespace
- Buat instance kelas Project untuk memuat file MPP untuk disimpan sebagai XPS
- Simpan file MPP ke XPS di C++ menggunakan metode Simpan
Anda dapat mengekspor file MPP ke XPS di C++ dalam beberapa panggilan API. Yang Anda butuhkan hanyalah mengakses file MPP dan kemudian menyimpannya sebagai XPS dalam panggilan API berikutnya menggunakan C++.
Kode untuk Mengonversi MPP ke XPS menggunakan 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); | |
} |
Sebelumnya, kita telah mempelajari cara mengekstrak metadata file Microsoft Project di C++. Namun, dalam topik ini kami berfokus pada MPP ke konversi XPS di C++.