【问题标题】:How to update a perticular row in mpx file using MPXWriter in java如何在 java 中使用 MPX Writer 更新 mpx 文件中的特定行
【发布时间】:2014-02-18 02:31:23
【问题描述】:

我正在尝试使用 MPXWrite 更新 mpx 文件,

实际上,我将 mpp 文件转换为 mpx 文件,以便现在我能够读取所有任务和任务详细信息。但我想更新 mpx 文件中特定任务的 % Completion 我是如何做到的。

谁能提供代码。

在此先感谢..请帮我解决这个问题

//这样我在读mpx文件

 private static void readMPX(String inputFile){

   File f = new File(inputFile);
   MPXReader read1 = new MPXReader();
   ProjectFile pFile = null;

   try{
        pFile = read1.read(f);
       }catch(Exception e){
           e.printStackTrace();
       }
    List llist=pFile.getAllTasks();

   for(int i=1;i<10/*llist.size()*/;i++)
   {

   Task t=(Task)llist.get(i);
   System.out.println("------------------------------------");
   System.out.println("Task Details : "+i  +llist.get(i));
   System.out.println("WBS : "+t.getWBS());
   System.out.println("WBS Leve : "+t.getWBSLevel());
   System.out.println("Task name : "+t.getName());
   System.out.println("Duration : "+t.getDuration());
   //System.out.println("Task Unique ID : "+t.getUniqueID());
 //  System.out.println("Task Unique ID : "+t.getUniqueID());
   System.out.println("Base Line Start : "+t.getBaselineStart());
   System.out.println("Base Line Finish : "+t.getBaselineFinish());
   System.out.println("Actual Start Date : "+t.getActualStart());
 //  System.out.println("\tFinish Date : "+t.getFinish());
   System.out.println("Actual End Date : "+t.getActualFinish());
   System.out.println("% Complete : "+t.getPercentageComplete());
   //getSubTasks(t,t.getUniqueID());
   System.out.println("------------------------------------");
   }

  }

【问题讨论】:

    标签: java ms-project mpxj


    【解决方案1】:

    这里有一些示例代码:

    private static void readMPX(String inputFile, String outputFile)
    {
       File f = new File(inputFile);
       MPXReader read1 = new MPXReader();
       ProjectFile pFile = read1.read(f);
    
       // Select the task you want to update
       // Here we are just selecting the first task
       Task task = pFile.getTaskByID(1);
    
       // Let's set it to 60% complete
       task.setPercentageComplete(60);
    
       // Now we write the result to a new file
       new MPXWriter().write(pFile, outputFile);   
      }
    

    【讨论】:

      【解决方案2】:

      这是来自 Microsoft 的限制。我们无法回写到 mpp 文件。

      【讨论】:

        猜你喜欢
        • 2014-08-17
        • 2020-09-28
        • 1970-01-01
        • 2017-02-24
        • 2012-06-23
        • 2012-12-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多