Results 1 to 7 of 7

Thread: Read MS Project files from C#

  1. #1
    Join Date
    Jul 2010
    Posts
    1

    Read MS Project files from C#

    I have a requirement to read tasks from MS Project file using asp.net and save the tasks in SQL server database. I could do this uising OLEDB and in local machine where MS project is installed. But not able to deply this in the server, cause is MSP is not installed in the server... is it possible to add any DLLs any any other utilities. Please help.

  2. #2
    Join Date
    Dec 2007
    Posts
    1,736

    Re: Read MS Project files from C#

    Below is the method how I went about reading a Microsoft Project file in C#:

    using Microsoft.Office.Interop.MSProject;
    using System.Reflection;

    ApplicationClass projectApp = new ApplicationClass();

    // Open the file. There are a number of options in this constructor as you can see
    projectApp.FileOpen("C:\myfile.mpp", true, Missing.Value, Missing.Value, Missing.Value,
    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
    PjPoolOpen.pjDoNotOpenPool, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

    // Get the active project
    Project proj = projectApp.ActiveProject;

    // Enumerate the tasks
    foreach (Task task in proj.Tasks)
    {
    string name = task.Name;

    // Project stores the number of minutes in a workday, so 8 hours per workday * 60 = 480. 480 is a project "day"
    int duration_in_days = Int32.Parse(task.Duration.ToString()) / 480;

    DateTime start = DateTime.Parse(task.Start.ToString());
    DateTime finish = DateTime.Parse(task.Finish.ToString());
    double percent_complete = Double.Parse(task.PercentComplete.ToString());
    DateTime actual_finish = DateTime.Parse(task.ActualFinish.ToString());

    // Do something with each task here
    }

    // Make sure to clean up and close the file
    projectApp.FileCloseAll(PjSaveType.pjDoNotSave);

    A pretty simple example, but I could not find a single example of doing this online.

    Projectin' Tom Out.

  3. #3
    Join Date
    Jul 2011
    Posts
    3

    sad Re: Read MS Project files from C#

    Hi JAMES_911,

    Very useful your post.

    Please, one doubt... when I try to compile I receive this error message:
    "The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"

    Is it necessary install a DLL ?

    Thanks, best wishes.

    Daniel

  4. #4
    Join Date
    Jan 2006
    Posts
    605

    Re: Read MS Project files from C#

    Hi daniel.aquere,

    The error that you are getting is mainly due to PIA's (primary interop assemblies) not registered to the GAC for XP or any version of Windows. You just got to add the dlls in the following download or register the dlls through visual studio command prompts. The error is coming because you don't have the proper reference. In this case it very well could be due to differing versions.

  5. #5
    Join Date
    Jul 2011
    Posts
    3

    smile Re: Read MS Project files from C#

    Hi Janos,

    Thanks for response.

    Please, where I find the DLL mentioned to install?

    Best

    Daniel

  6. #6
    Join Date
    Jan 2006
    Posts
    605

    Re: Read MS Project files from C#

    Hi daniel.aquere,

    I think that you can use xp PIAs for 2000, check the below link for same:

    http://www.microsoft.com/downloads/d...displaylang=en

  7. #7
    Join Date
    Jul 2011
    Posts
    3

    smile Re: Read MS Project files from C#

    Hi Janos,

    Thank you very much.

    I´m using 2007 version, it´s working very fine.

    Best

    Daniel

Similar Threads

  1. Replies: 4
    Last Post: 26-03-2012, 06:42 PM
  2. Does Kindle DX read .doc files?
    By Ramirez in forum Portable Devices
    Replies: 6
    Last Post: 22-02-2011, 02:02 AM
  3. Replies: 3
    Last Post: 14-12-2010, 04:10 AM
  4. Unable to read avi files
    By Axton in forum Windows Software
    Replies: 3
    Last Post: 13-04-2009, 11:57 AM
  5. Read MAG files of images
    By Parker in forum Windows Software
    Replies: 3
    Last Post: 20-03-2009, 12:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,666,025.28182 seconds with 16 queries