Cách trích xuất siêu dữ liệu tệp dự án Microsoft bằng C ++

Trong chủ đề này, chúng ta sẽ khám phá cách trích xuất siêu dữ liệu Microsoft Project file bằng C++. Bạn sẽ quan sát cách truy cập tệp MPP và thông tin siêu dữ liệu của nó trong C++ bằng cách sử dụng lệnh gọi API đơn giản mà không phụ thuộc vào MS Project.

Các bước để trích xuất siêu dữ liệu tệp dự án Microsoft bằng C ++

  1. Cài đặt Aspose.Tasks for C++ từ Công cụ quản lý gói NuGet
  2. Thêm tham chiếu vào không gian tên Aspose::Tasks
  3. Khởi tạo thể hiện của lớp Dự án để tải tệp MPP nhằm trích xuất thông tin siêu dữ liệu
  4. Trích xuất thông tin siêu dữ liệu cho các thuộc tính khác nhau bằng các phương thức tĩnh của lớp Prj

Bạn có thể trích xuất siêu dữ liệu tệp MPP trong C++ bằng cách sử dụng lệnh gọi API đơn giản trong mã vài dòng. Bạn chỉ cần truy cập tệp MPP và lặp qua các thuộc tính siêu dữ liệu mong muốn được hiển thị bởi Prj class trong C++.

Mã để trích xuất siêu dữ liệu tệp dự án Microsoft bằng 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);
}

Trước đó, chúng ta đã học cách trích xuất siêu dữ liệu tệp Microsoft Project trong C#. Tuy nhiên, trong chủ đề này, chúng tôi đã triển khai trình trích xuất siêu dữ liệu Microsoft Project trong C++.

 Tiếng Việt