如何使用 C++ 将 MPP 转换为 XPS

在本主题中,我们将探讨如何使用 C++** 将 MPP 转换为 XPS。 XPS 是一种广泛使用的文件格式,您可以使用少量 API 调用轻松地将 MPP 文件导出到 C++ 中的 XPS,而无需依赖 MS Project。

使用 C++ 将 MPP 转换为 XPS 的步骤

  1. 使用 NuGet 包管理器工具安装 Aspose.Tasks for C++
  2. 包括对 Aspose::Tasks 命名空间的引用
  3. 实例化 Project 类实例以加载 MPP 文件以保存为 XPS
  4. 使用 Save 方法将 MPP 文件保存到 C++ 中的 XPS

您可以在几个 API 调用中将 MPP 文件导出到 C++ 中的 XPS。您只需访问 MPP 文件,然后在使用 C++ 进行的后续 API 调用中将其保存为 XPS。

使用 C++ 将 MPP 转换为 XPS 的代码

#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);
}

之前,我们学习了 如何在 C++ 中提取 Microsoft Project 文件元数据。但是,在本主题中,我们重点关注 C++* 中 *MPP 到 XPS 的转换。

 简体中文