• 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>");
                        }
                       
                    }
                }
  • 相关阅读:
    json转成csv文件
    从输入url到页面展示到底发生了什么
    详解定时任务中的 cron 表达式
    创建型模式之简单工厂模式
    MySQL数据分组GROUP BY 和HAVING
    贪心算法
    JavaScript与DOM(下)
    JavaScript与DOM(上)
    Hibernate 的一级缓存和二级缓存总结
    JVM 发生OOM的四种情况
  • 原文地址:https://www.cnblogs.com/ringwang/p/1471585.html
Copyright © 2020-2023  润新知