Click here to Skip to main content
14,642,663 members
Articles » Platforms, Frameworks & Libraries » .NET Framework » General
Posted 18 Mar 2014

Tagged as


5 bookmarked

A Generic Library For Accessing And Creating Microsoft Project Plan File

Rate this:
4.86 (3 votes)
Please Sign up or sign in to vote.
4.86 (3 votes)
18 Mar 2014CPOL
Generic Library for Accessing and Creating Microsoft Project Plan File


In a project, if you need to extract data from Excel, you have a lot of options irrespective of technology. But if you have a requirement to retrieve data from a MPP (Microsoft Project Plan) file, you have a limited number of options.

Firstly, you can use MPXJ (Microsoft Project Exchange) open source Library to retrieve data from MPP file. But the problem is that it is coded in Java and the .NET version just embeds a virtual Java processor and then calls the Java-native version. It involves performance overhead.

Secondly, you can use Interop library provided in .NET Using this library, you can access an MPP file but is very complex and is low-level. Programming directly against Interop has been an issue with developers.

We came up with a generalized library keeping in mind the structure and fields of a MPP file. It provides you a direct mapping with inbuilt fields of a MPP file in an exact manner. For example, tasks in a project may have subtasks, but when you directly read it using Interop, even subtasks will be considered as separate tasks. Then the essence of a MPP file gets lost and rather it looks like an Excel file.

Image 1

Fig 1.0 Structure of MILE

We have kept intact the extensibility of Interop library and allowed the user to access and create a MPP file in a generalized manner keeping the essence of a project file intact.

Image 2

Fig 1.1 Class Specifications


  • Disconnected architecture
  • LINQ extensibility
  • Generate MPP file in a generalized manner
  • Accessing data from project file in its essence
  • Refinement- Child tasks
  • Secure for web application


Microsoft Project should be installed on your machine.

In order to use this library, you can use the following steps:

  1. Add reference of the provided DLL
  2. Import Abhi.MILE
  3. Create a List object of type MppTask and a reference variable of type MPPProject:
    // Creating a List variable of type MppTask
    List<MppTask> lsMppTasks;
    // Creating a reference variable of type MPPProject
    MPPProject project;
  4. Declare a string variable ‘path’ to store the location of MPP file and store the path in it
    // Creating a string variable to store the path of Mpp file
    String path;
    path="Your path here"; 
  5. After storing the path, just instantiate an object of MPPProject class as per the class definition:
    // Creating an object of  type MPPProject
    project = new MPPProject(path);
  6. Retrieve all tasks present in the mpp file through the object created in the last step. Invoke GetAllTasks method and store all tasks present in a list variable created in Step 3:
    // Invoking GetAllTasks() Method to retrieve all tasks present in MPP file
    lsMppTasks = project.GetAllTasks();
  7. Now you have a project object that contains all Tasks, subtasks and resources present in the Mpp file. With the help of List variable, we can access subtasks and all other fields or properties of a particular task as shown below:
    // Retrieving Name of first task    
    // Retrieving the name of First child of first task
    FirstChildOfFirstTask.text= lsMpptasks[0].ChildTasks[0].Name;
    // Retrieving the start date of First child of first task
    ChildTaskStartDate.Text = lsMpptasks [0].ChildTasks[0].StartDate.ToString();
    // Retrieving the name of second child of first task
    SecondChildOfFirstTask.Text = lsMpptasks [0].ChildTasks[1].Name;

    Now the lsMppTask object can be used to access entire information present in MPP file with the help of methods as shown in the Class specification. In this way, library can be used for accessing all information present in a MPP file.

  8. Similarly, we can create a MPP File by creating List of MppTasks and pass them into CreateMppFile method of MppProject class.
    // Creating a List variable of type MppTask to store task information
        List<MppTask> lsMppTasks;
    //Creating a MppTask object and initializing some properties
        MppTask task1=new MppTask();
    //Creating another MppTask object and initializing some properties
        MppTask task2=new MppTask();
    //Adding both Mpptask objects to List object
    /*Invoking CreateMppFile Method of project class to create a Mpp file with all 
    information present in List object */
        project .CreateMppFile(lsMppTasks,"D:/My_MppFile.mpp");

For all remaining properties and methods, kindly refer to the class specification given above.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Abhishek Kumar Goswami
Software Developer
India India
I like to code and I really enjoy to share my knowledge with all, Its my passion.

Comments and Discussions

SuggestionThere is no option to create new mpp file with customized mpp file name Pin
Member 1453290716-Jul-19 21:08
MemberMember 1453290716-Jul-19 21:08 
Questioncan you give me a kit of this .dll? Pin
Member 1362469714-Jun-18 3:45
MemberMember 1362469714-Jun-18 3:45 
QuestionLibrary set up Pin
Rita Griebenow14-May-18 22:01
MemberRita Griebenow14-May-18 22:01 
QuestionUnable to proceed Pin
kakkkosa17-Jul-16 18:01
Memberkakkkosa17-Jul-16 18:01 
AnswerRe: Unable to proceed Pin
Abhishek Kumar Goswami17-Jul-16 21:44
professionalAbhishek Kumar Goswami17-Jul-16 21:44 

Could you tell me which .net version are you using?
Abhishek Goswami

QuestionMissing Reference Pin
ariyasaap15-May-14 9:52
Memberariyasaap15-May-14 9:52 
QuestionDll Pin
drnaik18-Mar-14 11:07
Memberdrnaik18-Mar-14 11:07 
AnswerRe: Dll Pin
Abhishek Kumar Goswami18-Mar-14 21:20
professionalAbhishek Kumar Goswami18-Mar-14 21:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.