Vous êtes sur la page 1sur 7

Step-by-step process to read & extract Microsoft Project Files

PreparedBy: Veeraraghavan P
PreparedDate: 19/03/2009
Index

1. Objective
2. MPXJ
2.1 Introduction
2.2 Features
2.3 Getting started
2.3.1 Download
2.3.2 Extract
2.3.3 Required JAR Files
3. Sample Code
4. Sample Input
5. Sample Output
Read & Extract Microsoft Project Files

1. Objective

To design a document using which, anyone can able to design a class in order to read and
extract the microsoft project files (.mpp).

2. MPXJ

2.1 Introduction:

To read and extract the contents in the microsoft project file we are going to use MPXJ library.
This library provides a set of facilities to allow project information to be manipulated in Java.

2.2 Features:

1. MPXJ supports five file formats, Microsoft Project (MPP, MPT), Microsoft Project
Exchange (MPX), Microsoft Project Data Interchange (MSPDI), Microsoft Project Database (MPD),
and Planner (XML).
2. MPXJ is purely written and maintained in Java.
3. MPXJ supports read only access to MPP files produced by Microsoft Project 98, Microsoft
Project 2000, Microsoft Project 2002, Microsoft Project 2003, and Microsoft Project 2007.
4. MPP template files with the suffix MPT are also supported.
5. MPXJ allows MPX files to be created, read and written.
6. The MSPDI file format is Microsoft's XML file format for storing project data. Microsoft
Project 2002, Microsoft Project 2003 and Microsoft Project 2007 can read and write MSPDI files.
MPXJ allows MSPDI files to be created, read, and written.
7. The MPD file format is an Access database file format used to store one or more projects.
The database schema used in these databases is also close to that used by Microsoft Project Server.
MPXJ can read projects stored in an MPD file using a JDBC connection.
8. Planner is an Open Source project management too, which uses an XML file format to store
project data. MPXJ read and write the Planner file format.

2.3 Getting started with MPXJ:

The following steps has to be done in order to make ready the environment to read and extract
the microsoft project files.

2.3.1 Download

MPXJ library of version 3.0.0 can be download from the following link provided,
http://sourceforge.net/project/showfiles.php?group_id=70649
2.3.2 Extract

Extract the downloaded zip file (mpxj-3.0.0).

2.3.3 Required JAR Files

The following jar files have to be added to the class path of the project.
1. mpxj.jar
2. poi-3.2-FINAL-20081019.jar

Can get the mpxj.jar file from the extracted folder and poi-3.2-FINAL-20081019.jar file in the
lib folder inside the extracted folder.

3. Sample Code

package mpxj;

import net.sf.mpxj.MPXJException;
import net.sf.mpxj.ProjectFile;
import net.sf.mpxj.Resource;
import net.sf.mpxj.Task;
import net.sf.mpxj.mpp.MPPReader;
import net.sf.mpxj.reader.ProjectReader;

public class Main {

ProjectReader reader = new MPPReader();


ProjectFile project;

public void mppReader(){

System.out.println("before reading");
try {
project = reader.read("b4ubuild_sample_07.mpp");
} catch (MPXJException e) {
e.printStackTrace();
}
System.out.println("after reading");

for (Resource resource : project.getAllResources()) {


System.out.println("Resource: " + resource.getName() + " (Unique ID=" +
resource.getUniqueID() + ")");
}
for (Task task : project.getAllTasks())
{
System.out.println("Task: " + task.getName() + " ID=" + task.getID() + " Unique ID=" +
task.getUniqueID());
}
}

public static void main(String[] args) {


Main fileReader = new Main();
fileReader.mppReader();
}
}
4. Sample Input
5. Sample Output

Vous aimerez peut-être aussi