Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Read MS Project files from C#

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-07-2010
Member
 
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.

Reply With Quote
  #2  
Old 26-07-2010
Member
 
Join Date: Dec 2007
Posts: 1,721
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.
Reply With Quote
  #3  
Old 16-07-2011
Member
 
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
Reply With Quote
  #4  
Old 16-07-2011
Member
 
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.
Reply With Quote
  #5  
Old 16-07-2011
Member
 
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
Reply With Quote
  #6  
Old 16-07-2011
Member
 
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
Reply With Quote
  #7  
Old 16-07-2011
Member
 
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Read MS Project files from C#"
Thread Thread Starter Forum Replies Last Post
How to Migrate .mpp files from Project 2003 to Project 2010 Skylar Microsoft Project 4 26-03-2012 06:42 PM
Does Kindle DX read .doc files? Ramirez Portable Devices 6 22-02-2011 01:02 AM
Can copy and read the new files but cannot read or delete old contents in the hard drive GOOL Hardware Peripherals 3 14-12-2010 03:10 AM
Unable to read avi files Axton Windows Software 3 13-04-2009 11:57 AM
Read MAG files of images Parker Windows Software 3 20-03-2009 12:39 PM


All times are GMT +5.5. The time now is 01:03 AM.