Mastering MS Project Save Options for Aspose.Tasks

Introduction

Aspose.Tasks for .NET offers powerful features for manipulating Microsoft Project files programmatically. In this tutorial, we’ll delve into the intricacies of saving MS Project files using various options provided by Aspose.Tasks. Specifically, we’ll focus on the general save options available for Aspose.Tasks, allowing you to tailor the output to your specific requirements.

Prerequisites

Before we begin, ensure you have the following prerequisites:

  1. Installation of Aspose.Tasks for .NET: Download and install Aspose.Tasks for .NET from the download link.
  2. Basic Understanding of .NET Framework: Familiarity with .NET programming concepts is beneficial.

Importing Namespaces

Before diving into the code, make sure to import the necessary namespaces:

    using Aspose.Tasks;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;
    using System.Drawing;
    using System.Linq;
    
    using Aspose.Tasks.Saving;
    using Aspose.Tasks.Util;
    using Aspose.Tasks.Visualization;

Step 1: Load the Project File

Firstly, you need to load the MS Project file using Aspose.Tasks:

var project = new Project("Your Document Directory/CreateProject2.mpp");

Step 2: Define Save Options

Define the save options according to your requirements. In this example, we’re using Spreadsheet2003SaveOptions:

var options = new Spreadsheet2003SaveOptions();

Step 3: Customize View Columns

You can customize view columns such as Gantt chart, resource view, and assignment view. Here’s how to add columns to each:

var ganttChartColumn = new GanttChartColumn("WBS", 100, delegate(Task task) { return task.Get(Tsk.WBS); });
options.View.Columns.Add(ganttChartColumn);
var resourceViewColumn = new ResourceViewColumn("Cost center", 100, delegate(Resource resource) { return resource.Get(Rsc.CostCenter); });
options.ResourceView.Columns.Add(resourceViewColumn);
var assignmentViewColumn = new AssignmentViewColumn("Notes", 200, delegate(ResourceAssignment assignment) { return assignment.Get(Asn.NotesText); });
options.AssignmentView.Columns.Add(assignmentViewColumn);

Step 4: Save the Project with Options

Finally, save the project with the specified options:

project.Save("Your Document Directory/UsingSpreadsheet2003SaveOptions_out.xml", options);

Conclusion

Mastering general MS Project save options with Aspose.Tasks for .NET empowers you to efficiently customize the output format according to your project’s needs.

FAQ’s

Q: Is Aspose.Tasks compatible with different versions of MS Project files?

A: Yes, Aspose.Tasks supports various versions of MS Project files, ensuring compatibility across different environments.

Q: Can I try Aspose.Tasks before purchasing?

A: Yes, you can explore Aspose.Tasks with a free trial available here.

Q: Where can I find documentation for Aspose.Tasks?

A: Detailed documentation can be found here, providing comprehensive guidance on using Aspose.Tasks features.

Q: How can I obtain temporary licenses for Aspose.Tasks?

A: Temporary licenses are available for evaluation purposes here.

A: You can join the Aspose.Tasks community forum here to get assistance from experts and fellow developers.