Microsoft Project MPP File Update

With Aspose.Tasks for C++ it is possible to update Microsoft Project 2010 MPP files in addition to XML. You can save the updated data to an existing or a new file.

Updating Microsoft Project 2010 MPP Files

The following examples show how to add a new task to an existing Microsoft Project 2010 file and save it back to the same file. The code goes through the following steps:

  1. Create an instance of the project reader.
  2. Read the file.
  3. Create a task.
  4. Add the task to the project.
  5. Re-calculate.
  6. Save.

The code example given below demonstrates how to update the MPP file.

Code Samples

 1// The path to the documents directory.
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3        
 4// Read an existing project
 5System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"MPPFileUpdate.mpp");
 6        
 7// Create a new task
 8System::SharedPtr<Task> task = project->get_RootTask()->get_Children()->Add(u"Task1");
 9        
10task->Set(Tsk::Start(), System::DateTime(2012, 8, 1));
11task->Set(Tsk::Finish(), System::DateTime(2012, 8, 5));
12        
13// Save the project as MPP project file
14project->Save(dataDir + u"AfterLinking_out.Mpp", Aspose::Tasks::Saving::SaveFileFormat::MPP);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.