.NET读取Project 2007 MPP项目文件

Project文件读取:

方法1:Microsoft.Project.OLEDB.11.0

string strConn = "Provider=Microsoft.Project.OLEDB.11.0;Project Name=" + fileName;
DataSet ds = new DataSet();
using (OleDbConnection conn = new OleDbConnection(strConn))
{
conn.Open();
string[] tablesName = new string[] { "Assignments", "Tasks", "Resource" };
for (int k = 0; k < tablesName.Length; k++)
{
string strTableName = tablesName[k];
string str = "select * from " + strTableName;
OleDbDataAdapter da = new OleDbDataAdapter(str, conn);
da.Fill(ds, strTableName.ToLower());
da.Dispose();
}
conn.Close();
conn.Dispose();
}
return ds;

方法2:Microsoft.Office.Interop.MSProject

Object missing = Type.Missing;
ApplicationClass prj = new ApplicationClass();
//打开mpp文件
prj.FileOpen(fileName, true, missing, missing, missing, missing, missing, missing, missing,
missing, missing, PjPoolOpen.pjPoolReadOnly, missing, missing, missing, missing);
return prj.Projects;
以上两个方法都需要安装Microsoft.Project

方法3:mpxj

ProjectReader reader = ProjectReaderUtility.getProjectReader(fileName);
ProjectFile projectFile = reader.read(fileName);
List tasks = projectFile.getAllTasks();
for (int i = 0; i < tasks.size(); i++)
{
Task task = tasks.get(i) as Task;
}

.NET读取Project 2007 MPP项目文件,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。