Hi, I am required to generate a Microsoft project file with some data MYSQL database. Since the application I am writing is a PHP application, is there a way to create a Microsoft project file like we do data export to excel file using some libraries. Any help would be highly appreciated.
A:
Yes, here's an example from MSDN that shows how to import from Excel.
Eric J.
2009-10-17 23:52:19
A:
I can tell you how to do it via C# and the Microsoft.Office.Interop.MSProject.dll.
Example code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.Office.Interop.MSProject;
using System.Data;
namespace ConsoleApplication2
{
public static class ProjectHelper
{
public static void CreateProject(string projectName, DataSet mySqlData)
{
ApplicationClass msProjectApp = new ApplicationClass();
msProjectApp.AppMaximize();
msProjectApp.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
Project project = msProjectApp.ActiveProject;
// Process the dataset and add tasks ... etc
// Assume you are reading from the dataset
Task task = project.Tasks.Add("test1", 1);
Task task2 = project.Tasks.Add("test2", 2);
task.Start = "22/10/2009";
task.Finish = "25/10/2009";
task.Text1 = "some test";
msProjectApp.GanttBarFormat(task.ID, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.MSProject.PjColor.pjGreen, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
task2.Start = "23/10/2009";
task2.Finish = "24/03/2009";
task2.Text1 = "some test 2";
task2.Predecessors = task.ID.ToString();
}
}
}
Vladimir Georgiev
2009-10-17 23:58:51