zoukankan      html  css  js  c++  java
  • asp.net读取/导入project(mpp)文件

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

    需要引入Microsoft.Office.Interop.MSProject组件

    引入方式见:http://blog.csdn.net/Flyear_cheng/archive/2008/09/07/2895865.aspx

    参考:http://blog.csdn.net/wenzhixing/archive/2008/09/11/2911461.aspx

    Microsoft.Office.Interop.MSProject.ApplicationClass prj = new ApplicationClass();

                
    string prjFileName = Server.MapPath("../upfile/计划.mpp");
                 
    //Response.Write(prjFileName);
                
    //if (new FileInfo(prjFileName).Exists)
                
    //    Response.Write("文件存在");
                
    //else
                
    //    Response.Write("文件不存在");

                prj.FileOpen(prjFileName, 
    true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.MSProject.PjPoolOpen.pjPoolReadOnly, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
             
                
    foreach (Microsoft.Office.Interop.MSProject.Project proj in prj.Projects)
                {
                    Response.Write(
    "<table border=1 width=100%>");
                    Response.Write(
    "<tr><td>任务编号</td><td>任务名</td><td>优先级</td><td>开始时间</td><td>结束时间</td><td>资源名</td><td>WBS号</td><td>完成百分比</td><td>是否完成</td><td>摘要</td><td>前置任务</td></tr>");
                    
    foreach (Microsoft.Office.Interop.MSProject.Task task in proj.Tasks)
                    {
                        
    if (task != null)
                        {
                            
    int iTaskLevel = task.OutlineLevel;
                            
    string str = string.Empty;
                            
    for (int j = 0; j < iTaskLevel; j++)
                            {
                                str 
    += "---";
                            }
                           

                            Response.Write(
    "<tr><td>"+task .ID+"</td><td>" + str + task.Name + "</td><td>"+task .Priority+"</td><td>" + task.Start + "</td><td>" + task.Finish + "</td><td>" + task.ResourceNames.ToString() + "</td><td>" + task.WBS + "</td><td>" + task.PercentComplete + "</td><td>" + task.ActualFinish + "</td><td>"+task.Notes +"</td><td>");
                            
    foreach (Task t in task.PredecessorTasks)
                                Response.Write(t.WBS
    +":"+t.Name);
                            Response.Write(
    "</td></tr>");
                        }
                       
                    }
                }
  • 相关阅读:
    Python 初学者必看:Python 异常处理集合
    解析分布式应用框架Ray架构源码
    混合编程:如何用python11调用C++
    AI开发效率低,你可以试试华为NAIE AutoML
    知道Python中的字符串是什么吗?
    Java 第十一届 蓝桥杯 省模拟赛 70044与113148的最大公约数
    MindSpore部署图像分割示例程序
    MindSpore模型推理
    MindSpore特性支持类
    MindSpore后端运行类
  • 原文地址:https://www.cnblogs.com/ringwang/p/1471585.html
Copyright © 2011-2022 走看看