We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Save as mpp?

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,


Thank you for contacting Aspose support team.

Aspose.Tasks features can be tested using free dll available on the downloads page however there are few restrictions. One of them is that we can save projects to XML only in case we don’t have license. In order to save the project to MPP file, a valid license is must required. If you want to test all the features of Aspose.Tasks without license limitations, please avail the temporary 30 days license as described here.

Following is a sample code which can be used to write data to XML file which can be opened in Microsoft Project 2010. Could you please give it a try and let us know your feedback?


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.setConstraintType(ConstraintType.StartNoEarlierThan);
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,


Thank you for providing feedback.

The Blank2013.mpp file is an existing project file which is used as template to initialize the project instance. You may use some existing MPP/XML project file as it initializes most of the properties required by Project object. However it is not always necessary to use a template file and an empty constructor can also be used to instantiate the project class object.

I am afraid that I could not observe any issue at the line mentioned by you. I have tested it with and without the template file. Could you please elaborate if you have used some template file or not. If you have used any template file please send it to us along with the code used for this testing. I will analyze it here to re-produce the error and provide assistance as soon as possible.

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,


Thank you for contacting us again.

MPP files cannot be created without the template file however the XML files are allowed. Hence you may please use a template MPP file if you want to save the project as MPP file however for XML output, you don’t need any template file.

Regarding the exception when output file is opened in Microsoft Project (MSP), I have observed a little issue in your sample code as given below:

// Save the Project
prj.save(
“C:/eclipse-archibus/workspaces/CoreDeveloper/AsposeTaskLibrayTests/appClientModule/Test.mpp”,
SaveFileFormat.XML);

Here the file extension is given as MPP where as SaveFileFormat.XML is used. It causes the creation of a XML file which is saved as MPP. When this file is opened in MSP, it tries to read as MPP due to its extension which causes this exception.

Could you please use template, MPP file extension and SaveFileFormat.MPP or create an XML file without a template?

Please feel free to write us back if you have any other query in this regard.

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,


Could you please provide the link for the document that is misleading in this case? We’ll look into it as soon as possible and rectify it.

At present, one template document can not be saved to another version of Ms Project. You need to maintain individual templates in this case. We suggest you to use MS Project 2010 template in your applications as it is the more stable relative to the latest version of MS Project.