This quick tutorial discusses how to create MPP file in C#. It includes the algorithm and a sample code illustrating how to create project in Microsoft Project using C#. Moreover, incorporating this feature into your projects does not require any additional software installation on your end.
Steps to Create MPP File in C#
- Configure the IDE by installing Aspose.Tasks to create Project files
- Initiate an object of the Project class
- Add a task and append a subtask to the created task
- Write the output MPP file by calling the Save method
These steps exhibit how to create project in MS Project using C#. They let you understand the program logic easily without getting into the basic details of the Project files. Initiate a project file and add relevant tasks or subtasks to it before exporting the output MPP file.
Code to Create MS Project in C#
// Create project | |
Aspose.Tasks.Project project = new Aspose.Tasks.Project(); | |
// Add task | |
Aspose.Tasks.Task task = project.RootTask.Children.Add("Summary1"); // Add sub task | |
Aspose.Tasks.Task subtask = task.Children.Add("Subtask1"); | |
// Save output project | |
project.Save("Project.mpp", Aspose.Tasks.Saving.SaveFileFormat.Mpp); |
This sample code is a bare minimum form to create subtask in MS Project in C#. At the same time, it can be modified to cater to complicated requirements that may involve several tasks, subtasks, resources, etc. Additionally, you can write the output Project file in XML, MPP, or other supported file formats.
In this basic guide, you have understood how to create MS Project in C#. Besides, if you want to export MPP to a TIFF image, then refer to the article on Convert MPP to TIFF in C#.