[MPXJ Series] Writing MS Project File using MPXJ

In the first part, we shall explore what are the different ways of writing a MS Project file using MPXJ.

Pre-requisite

The article assumes that you have downloaded MPXJ release and related dependencies. If not here are the links for download

 

Now let’s get back to the original intent of reading MPP files

Lets see the simplest form of reading an MPP file

ProjectWriterUtility.getProjectWriter(fileName), provides an appropriate Reader class, based on the version of MS Project file. This is the simplest way to create a writer for an Project file. ProjectFile is the class that contains details about the Schedule, we can iterate and extract information from it. We shall discuss the details on ProjectFile in subsequent posts. ProjectWriterUtility class checks for the file extension and returns an appropriate writer.

Alternative ways

  • For writing MPX file, you can use net.sf.mpxj.mpx.MPXWriter
  • For writing XML Project file, use net.sf.mpxj.mspdi. MSPDIWriter

5 thoughts on “[MPXJ Series] Writing MS Project File using MPXJ

  1. Ashish, have You tried to instanciate a Resource class?. It seems that the constructor is package private, I don’t understand the reason of this. How it’s supose that You asign a resource to a task if you can’t instanciate a resource?. Is this a bug or I’m doing something bad?.
    Regards.

  2. Ok……never mind. This is it. You can create the class Resource by calling to the addResource() method of the ProjectFile class which returns a Resource instance, then set his parameters and give his UID to the setResourceUniqueID() method of the ResourceAssignment class. By the way the this last class cannot be intanciated either (with new ()), but like the first one you can call to newResourceAssignment() in the ProjectFile class which returns a instance of ResourceAssignment.
    Sorry for not realize that before, I’ve a plane learning curve.
    Regards.

  3. Ok……never mind. This is it. You can create the class Resource by calling to the addResource() method of the ProjectFile class which returns a Resource instance, then set his parameters and give his UID to the setResourceUniqueID() method of the ResourceAssignment class. By the way the this last class cannot be intanciated either (with new ()), but like the first one you can call to newResourceAssignment() in the ProjectFile class which returns a instance of ResourceAssignment.
    Sorry for not realize that before, I’ve a plane learning curve… 😛
    Regards.

  4. Actually there is a sample called MpxjCreate.java in the source directory of the package and there it shows the code for generating the resources and assignment. I didn’t see it before :P….
    Regards.

Leave a Reply to vaibhav Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.