自 2003 版以来,我一直在为 MS-Project XML 文件导入而苦苦挣扎。
现在我必须处理 MSP 2013 问题(为什么是 Microsoft?为什么它如此不可预测?)
在我看来,需要一些基本信息才能正确导入所需的值。
这是我所做的:
task.setEstimated(false); //to get rid of the percentage in the duration value
task.setPercentageComplete(50d); //50% for example
task.setPercentageWorkComplete(50d);
task.setPhysicalPercentComplete(50d);
task.setStart(<start date>);
task.setFinish(<finish date>);
task.setActualStart(<actual start date>);
task.setActualFinish(<actual finish date>); //only necessary if the task is 100%
task.setDuration(Duration.getInstance(4d, TimeUnit.DAYS)); //4d for example
task.setActualDuration(Duration.getInstance(2d, TimeUnit.DAYS));
double remainingDuration = task.getDuration().getDuration() - task.getActualDuration().getDuration();
task.setRemainingDuration(Duration.getInstance(remainingDuration, task.getDuration().getUnits()));
//if your task has resources assigned, you should set the work values
//suppose you have 2 resources assigned with 3 units each
double work = task.getDuration().getDuration() * 6;
task.setWork(Duration.getInstance(work, task.getDuration().getUnits()));
task.setRegularWork(work);
double actualWork = work * task.getPercentageComplete() / 100d;
task.setActualWork(Duration.getInstance(actualWork, task.getWork().getUnits()));
double remaining = task.getWork().getDuration() - task.getActualWork().getDuration();
task.setRemainingWork(Duration.getInstance(remaining, task.getWork().getUnits()));
好吧,我相信这就足够了。