Writing Updated Resource Data Back to MPP files

Aspose.Tasks for Java lets you update a Microsoft Project MPP file’s resource data and save it data back to the MPP file.

Writing Updated Resource Data back to the MPP file The code snippet in this article opens a source MPP file that has one resource. It then updates the data of the resource and adds several new resources. The steps involved in this activity are:

  1. Create an instance of the Project Reader.
  2. Read the source MPP file.
  3. Add resources to the project.
  4. Update existing resource data.
  5. Save the project using the Project Writer.

The following piece of code demonstrates this by an example. The first code snippet shows the process code and is followed by method definitions.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(WriteUpdatedResourceData.class);
 4
 5String file = dataDir + "SampleNewMPP.mpp"; // Test file with one rsc to
 6                                            // update
 7// File to write test project
 8String resultFile = dataDir + "OutputMPP.mpp";
 9
10Project project = new Project(file);
11Resource rsc = project.getResources().add("Rsc");
12rsc.set(Rsc.STANDARD_RATE, BigDecimal.valueOf(30));
13rsc.set(Rsc.OVERTIME_RATE, BigDecimal.valueOf(45));
14rsc.set(Rsc.GROUP, "Workgroup1");
15
16project.save(resultFile, SaveFileFormat.MPP);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.