How to Extract Microsoft Project File Metadata using C++

In this topic, we will explore how to extract Microsoft Project file metadata using C++. You will observe how to access the MPP file and its metadata information in C++ using simple API calls with no dependence on MS Project.

Steps to Extract Microsoft Project File Metadata using C++

  1. Install Aspose.Tasks for C++ from NuGet package Manager Tool
  2. Add reference to Aspose::Tasks namespace
  3. Instantiate Project class instance to load the MPP file to extract metadata information
  4. Extract metadata information for different properties using Prj class static methods

You can extract MPP file metadata in C++ by using simple API calls in few lines code. You just need to access the MPP file and iterate through desired metadata properties exposed by Prj class in C++.

Code to Extract Microsoft Project File Metadata using C++

#pragma once
#include <Project.h>
#include <Task.h>
#include<License/License.h>
#include<Saving/Html/HtmlSaveOptions.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 ExtractMetaInformation()
{
// Setting the license extracting metadata from MPP Project file
SharedPtr<License> AsposeTasksLicense = System::MakeObject<License>();
AsposeTasksLicense->SetLicense(u"licFile");
// Source MPP file path and name
System::String SourceFile = u"SourceMicrosoftProjectFile.mpp";
// Load the MPP file to extract meta information
SharedPtr<Project> MSProjectFile = MakeObject<Project>(SourceFile);
// Access and sae different meta information properties inside project file
System::String ProjectAuthor = MSProjectFile->Get(Prj::Author());
System::String ProjectCategory = MSProjectFile->Get(Prj::Category());
System::String ProjectCompany = MSProjectFile->Get(Prj::Company());
System::String ProjectComments = MSProjectFile->Get(Prj::Comments());
// Show the meta-data information extracted from the Microsoft Project file
System::Console::Write(u"Author:{0}, Catgory:{1}, Company:{2}, Comments:{3}",
ProjectAuthor, ProjectCategory, ProjectCompany, ProjectComments);
}

Earlier, we learnt how to extract Microsoft Project file metadata in C#. However, in this topic we have implemented Microsoft Project metadata extractor in C++.

 English