How to Extract MPP Metadata Using C#

In order to extract MPP metadata, we’ll use

Aspose.Tasks for .NET

API which is a feature-rich, powerful and easy to use document metadata API for C# platform. Open


package manager, search for Aspose.Tasks and install. You may also use the following command from the Package Manager Console.


PM> Install-Package Aspose.Tasks

Steps to Extract Metadata of MPP via C#

  • Load MPP using Project Class
  • Use respective Class objects like Task, ResourceAssignment
  • Set the relevant properties
  • Save the project

System Requirements

Aspose.Tasks for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with .NET Framework, Mono and COM Interop.
  • Development environment like Microsoft Visual Studio.
  • Aspose.Tasks for .NET referenced in your project.

Extract Metadata of MPP - C#

Project project = new Project("Project1.mpp");

// Add working times to project calendar
WorkingTime wt = new WorkingTime();
wt.FromTime = new DateTime(2010, 1, 1, 19, 0, 0);
wt.ToTime = new DateTime(2010, 1, 1, 20, 0, 0);
WeekDay day = project.Get(Prj.Calendar).WeekDays.ToList()[1];

// Change calendar name
project.Get(Prj.Calendar).Name = "CHANGED NAME!";

// Add tasks and set task meta data
Task task = project.RootTask.Children.Add("Task 1");
task.Set(Tsk.DurationFormat, TimeUnitType.Day);
task.Set(Tsk.Duration, project.GetDuration(3));
task.Set(Tsk.Contact, "Rsc 1");
task.Set(Tsk.IsMarked, true);
task.Set(Tsk.IgnoreWarnings, true);
Task task2 = project.RootTask.Children.Add("Task 2");
task2.Set(Tsk.DurationFormat, TimeUnitType.Day);
task2.Set(Tsk.Contact, "Rsc 2");

// Link tasks
project.TaskLinks.Add(task, task2, TaskLinkType.FinishToStart, project.GetDuration(-1, TimeUnitType.Day));

// Set project start date
project.Set(Prj.StartDate, new DateTime(2013, 8, 13, 9, 0, 0));

// Add resource and set resource meta data
Resource rsc1 = project.Resources.Add("Rsc 1");
rsc1.Set(Rsc.Type, ResourceType.Work);
rsc1.Set(Rsc.Initials, "WR");
rsc1.Set(Rsc.AccrueAt, CostAccrualType.Prorated);
rsc1.Set(Rsc.MaxUnits, 1);
rsc1.Set(Rsc.Code, "Code 1");
rsc1.Set(Rsc.Group, "Workers");
rsc1.Set(Rsc.EMailAddress, "This email address is being protected from spambots. You need JavaScript enabled to view it.");
rsc1.Set(Rsc.WindowsUserAccount, "user_acc1");
rsc1.Set(Rsc.IsGeneric, new NullableBool(true));
rsc1.Set(Rsc.AccrueAt, CostAccrualType.End);
rsc1.Set(Rsc.StandardRate, 10);
rsc1.Set(Rsc.StandardRateFormat, RateFormatType.Day);
rsc1.Set(Rsc.OvertimeRate, 15);
rsc1.Set(Rsc.OvertimeRateFormat, RateFormatType.Hour);

rsc1.Set(Rsc.IsTeamAssignmentPool, true);
rsc1.Set(Rsc.CostCenter, "Cost Center 1");

// Create resource assignment and set resource assignment meta data
ResourceAssignment assn = project.ResourceAssignments.Add(task, rsc1);
assn.Set(Asn.Uid, 1);
assn.Set(Asn.Work, task.Get(Tsk.Duration));
assn.Set(Asn.RemainingWork, assn.Get(Asn.Work));
assn.Set(Asn.RegularWork, assn.Get(Asn.Work));
task.Set(Tsk.Work, assn.Get(Asn.Work));

rsc1.Set(Rsc.Work, task.Get(Tsk.Work));
assn.Set(Asn.Start, task.Get(Tsk.Start));
assn.Set(Asn.Finish, task.Get(Tsk.Finish));

// Add extended attribute for project and task
ExtendedAttributeDefinition attr = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Flag, ExtendedAttributeTask.Flag1,  "My Flag Field");

ExtendedAttribute taskAttr = attr.CreateExtendedAttribute();
taskAttr.FlagValue = true;

// Save project as MPP
project.Save("WriteMetaData_out.mpp", SaveFileFormat.MPP);  
  • About Aspose.Tasks for .NET API

    Aspose.Tasks is a Microsoft Project API to view and convert project documents. One can load, create, modify and render Microsoft Project files to Primavera, Excel, PDF, HTML, images and XML formats. Aspose.Tasks is a standalone API and does not require Microsoft Project or any other software to be installed.

    Extract Metadata of MPP via Online App

    View & edit Metadata to MPP documents by using our Live Demos with following benefits.

      No need to download or setup anything
      No need to write any code
      Just upload your MPP file & edit document properties
      Instantly get the download link for the resultant file

    MPP Mi a MPP fájlformátum

    A file with MPP extension is Microsoft Project data file that stores information related to project management in an integrated manner. It is proprietary file format developed by Microsoft as file format for Microsoft Project (MSP) which is a project management application software. Besides MPP, MSP supports other file formats as well like project XML schema. Several APIs and applications provide the facility to convert MPP file format to others. Microsoft now has online Project Server where project management files can be uploaded for collaboration by multiple users.

    Other Supported Metadata Formats

    Using C#, One can also manipulate metadata of many other formats including.