20

What are my options for programmatically accessing a Microsoft Project file? What are the pros and cons of each approach?

I will basically need to import all data from the file into another data structure. Using the Office Interop assembies is low on the preference scale.

BIBD
  • 15,107
  • 25
  • 85
  • 137
Bob
  • 97,670
  • 29
  • 122
  • 130

5 Answers5

14

The MPXJ (mpxj.sf.net) library comes in both Java and .Net flavours and will allow you to read and write multiple Microsoft Project file formats using a single consistent API. I am aware of commercial products which use both the Java and the .Net versions of MPXJ without any issues.

Disclaimer: I'm the maintainer of MPXJ.

Jon Iles
  • 2,519
  • 1
  • 20
  • 30
  • Hello Jon, Thanks for your response. Just wondering if we can schedule tasks start/finish dates using MPXJ. like suppose i have added 3 tasks. task 1, task 2. task 3 and task 2 has dependency of finish to start and task 3 has dependency of finish to finish... how would their start/finish dates would be recalculated on the basis of dependencies i added? – Muhammad Adnan Jul 09 '10 at 11:34
  • Just check out MPXJ - this is *awesome*!! Thanks Jon, this is a really great and useful contribution. Saved not just my day but years of user data. – Roland Bouman May 27 '11 at 11:48
  • It's working in console application but it's not able to work in event receiver when i am trying to read file from SharePoint document library. – Akshay Aug 29 '18 at 04:48
  • @Akshay open an issue at https://github.com/joniles/mpxj, it would be useful to figure out why. – Jon Iles Aug 30 '18 at 06:30
  • @JonIles in your answer you mention that you can write to multiple Microsoft Project file formats, but can you please confirm you can not write to .mpp file format by MPXJ which is the standard format when you save a Ms Project file. When I do `ProjectWriter writer = ProjectWriterUtility.getProjectWriter(FileName);` I get an error and http://www.mpxj.org/faq/ mentions that you can't write to MPP files. – Chris Harper Aug 20 '21 at 15:07
  • 1
    @ChrisHarper that's correct. MPXJ does not write MPP files. I believe Aspose Tasks offers some support for writing MPP files. – Jon Iles Aug 21 '21 at 16:21
7

You may use Aspose.Tasks for .NET. This component allows you to work with Microsoft Project files. It doesn't require MS Office to be installed on the server, unlike Office Interop. The API is very simple and easy to use. And it provides a rich set of features to read, edit, write, and convert MPP files.

This component is a normal .NET assembly which can be used with your .NET applications. It works on any Windows OS and in 32/64-bit environments as well.

Disclosure: I work as developer evangelist at Aspose.

Shahzad Latif
  • 1,408
  • 12
  • 29
5

Here are the options:

  1. Interop (messy and horribly slow for large projects)
  2. Save project in XML and work with it (messy)
  3. Save project in the database (that's not publishing and it is available for project 2003 only - see ODBC option while saving). I've seen it being used a lot in the integration scenarios
  4. Projette (commercial, $10 per license)
  5. ILog Project Viewer (also commercial)
Rinat Abdullin
  • 23,036
  • 8
  • 57
  • 80
4

The Microsoft Office API provides programmatic access to MS Project. I have only used it for Word and Excel so I don't know how rich the interface is - you will have to do some digging around on MSDN to find out what you can and can't do.

One of the Java projects at my company uses a commerical product by Aspose which allows applications to manipulate Office documents including Project. It works well for their purposes, but again, they have only used it for Word and Excel so can't offer much advice on Project.

EDIT (2019): I can confirm that it is a very capable product.

Rikalous
  • 4,514
  • 1
  • 40
  • 52
1

Sourcefourge.net offers a component in Java which can be integrated with .net applications to read MPP files upto MPP 2007 the link is http://mpxj.sourceforge.net/getting-started.html

Rajesh
  • 11
  • 1