2

I've created an app based on MpxjCreate sample from MPXJ library distribution. I create several task, some of them with child tasks, & use Task.setStart() / Task.setFinish() for setting task start/finish dates. After I write resulting file using MSPDIWriter, following tags can be seen in resulting xml file inside <Task> tag:

<Start>2013-01-01T00:00:00</Start>
<Finish>2016-12-31T00:00:00</Finish>

But when I open file using MS Project 2007, it seems to ignore given values & uses <StartDate> value from <Project> tag, which results in series of tasks with 1 day duration.

Please tell, what should be done to use <Task>-><Start>/<Finish> tag values for MS Project task start/end date without any "intellectual" calculation?

Raptor
  • 53,206
  • 45
  • 230
  • 366
32kda
  • 63
  • 6

2 Answers2

1

Since the 2003 version, I have always struggled with MS-Project XML files import.

Now I have to deal with MSP 2013 issues (Why Microsoft? Why is it so unpredictable?)

It seems to me that some basic information is needed in order to get the desired values correctly imported.

Here is what I do:

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()));

Well, I believe this is enough.

0

I had a similar problem, which was solved by adding duration with setManualDuration(...).

Apparently it is not enough to specify start and finish, you also need duration.

I'm not sure if it is necessary, but I also specify setTaskMode(TaskMode.MANUALLY_SCHEDULED)

Peer Sommerlund
  • 502
  • 6
  • 14