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>");
                        }
                       
                    }
                }
  • 相关阅读:
    shell中对于命令的搜寻顺序
    在shell中运行以不同方式运行脚本
    shell中的type命令
    shell中的数组
    shell中的循环语句
    shell中的case表达式
    双方括号
    34. Win7_x64安装oracle11g出现DIM-00019
    33. 完全卸载oracle11g步骤
    32. 安装oracle11g时,先决条件一直失败的解决方法
  • 原文地址:https://www.cnblogs.com/ringwang/p/1471585.html
Copyright © 2011-2022 走看看