0

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

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

任何人都可以为此提供代码。

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

// 像这样我正在读取 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("------------------------------------");
   }

  }
4

2 回答 2

0

以下是一些示例代码:

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);   
  }
于 2014-06-27T14:21:07.423 回答
0

它是来自微软的限制。我们无法写回 mpp 文件。

于 2014-10-29T10:42:05.390 回答