We are evaluating the Aspose.Tasks, and I tried to use the API to do a simple prototyping to write the database fields’ values into MS Project 2010 format. However, I experienced the following issues:
1. When I tried to save as mpp format, the API throws the exception saying the mpp file does not exist. I can save as XML format but not mpp.
2. When I created several task with duration and percent complete for each task using Java API and save as XML. Then I tried to open the XML in Ms Project 2010. Ms project 2010 complains that the Project Start Date is invalid. After I specifically set its value, it complained that the completeWorkPercent is invalid. When I open the XML, realize that completeWorkPercent is set to -100.
Do you have a working example of adding tasks then open in Ms Project 2010 successfully?
Thanks!
Hi Ying,
Project prj = new Project(“D:/Aspose/Blank2013.mpp”);
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(2014, 7, 18, 8, 0, 0);
java.util.Date dt1 = cal.getTime();
prj.setStartDate(dt1);
Task tsk1 = prj.addTask(“Task1”);
cal.set(2014, 7, 18, 8, 0, 0);
dt1 = cal.getTime();
tsk1.setConstraintDate(dt1);
tsk1.setStart(dt1);
tsk1.setPercentComplete(50);
Task tsk2 = prj.addTask(“Task2”);
cal.set(2014, 7, 19, 8, 0, 0);
dt1 = cal.getTime();
tsk2.setConstraintType(ConstraintType.StartNoEarlierThan);
tsk2.setConstraintDate(dt1);
tsk2.setStart(dt1);
tsk2.setPercentComplete(70);
//Save the Project
prj.save(“D:/Aspose/Project2.xml”, SaveFileFormat.XML);
Thanks for your reply.
I have downloaded the trail license and use your code to try.
However, at this line,
Task tsk1 = prj.addTask(“Task1”);
I got an Java exception:
Task.Start is DateTime.MinValue 0
Does this file “D:/Aspose/Blank2013.mpp” need to be an existing file? If not, why do I get the error?
Thanks!
Hi Ying,
Hi,
Can you provide Syntax for saving to MPP without a template?
I am able to save as MPP with you sample code except that I use no MPP template. However, when I try to open the mpp with Ms Project 2010, I got the error (see attached image).
I have attached my source codes, which replicate most of your codes except for file location and license loading.
Thanks!
Ying
Hi Ying,
prj.save(
“C:/eclipse-archibus/workspaces/CoreDeveloper/AsposeTaskLibrayTests/appClientModule/Test.mpp”,
SaveFileFormat.XML);
Thanks for your reply. We are able to use a default template to save as mpp. Your document is somewhat misleading since it claims that user can create MPP from scratch.
A further question about maintaining MS Project template, in order to support all three versions of Ms Project 2007, 2010, and 2013, do I need to maintain three different templates, or I can use one version of it, if so, which version?
Hi Ying,