Free Support Forum -

How i can add new columns and hide others columns?


I’m working with ASPOSE Task and i need to create/add new columns and also i want to hide/delete specific columns like resources because in my case i never add any resourcer to the project.

Some one can give me an example of this?


An example is like this:

I create a custom header named “Test 01/03/2013”. How i can create this with ASPOSE Tasks???



Thanks for writing to Aspose.Tasks support team.

Adding new columns is supported by Aspose.Tasks using ExtendedAttribute class. It allows you to add extended attributes to tasks, resources and assignments. Following is the sample code which adds extended attribute “Description” to all the tasks in an existing project.

Dim lic As License = New Aspose.Tasks.License()

Dim prj As Project
Dim reader As ProjectReader
Dim writer As ProjectWriter
Dim ead As ExtendedAttributeDefinition
Dim ea As ExtendedAttribute

'read project data from xml
reader = New ProjectReader()
prj = reader.Read(“project2.mpp”)

add extended attribute definition
ead = New ExtendedAttributeDefinition()
ead.FieldName = “Text1”
ead.Alias = “Description”
ead.FieldId = CType(ExtendedAttributeTask.Text1, Integer).ToString
prj.ExtendedAttributes = New ArrayList()

For Each task As Task In prj.RootTask.Children
task.ExtendedAttribute = New ArrayList()
ea = New ExtendedAttribute()
ea.FieldId = ead.FieldId
ea.Value = String.Format(“Description of ‘{0}’.”, task.Name)
prj.Save(“project_res.mpp”, Aspose.Tasks.Saving.SaveFileFormat.MPP)
This new column can be seen in MS Project by selecting it from “Add New Column” in Gantt Chart view.

Regarding hiding the columns, MS Project provides facility to hide individual column. This view can be saved in MPP however this view is not saved in XML.

We are afraid to inform that Aspose.Tasks does not provide any facility to control the view in a project. However you can achieve this feature by using some template MPP project file. This template MPP file can be saved with desired view like hiding the “Resource Names” column. You may use this template MPP file with Aspose.Tasks to add tasks etc. and then saving file as MPP. This resultant MPP file will have the same view as set in template project file.

Aspose.Tasks provide control over columns while rendering the Gantt Chart view as image. You may have a look at the article “Display Multiple Columns in Rendered Gantt Chart Image” to get detail of this feature.

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

Perfect… i test that code, but in C#, and works as you said.

Ok… if i create a template MPP file hiding many columns and add custom columns, how i can read this custom columns and add data for this columns in each task?


I create the template test MPP file (with out custom fields) and i read it without problem. After of this i add some tasks and i wanted save in the same format, in this case MPP, but the code throw me the following error:

"The operation is not allowed in evaluation mode"

This is my code:

ProjectWriter prjWriter = new ProjectWriter();
System.IO.Stream st = new System.IO.MemoryStream();
prjWriter.Write(prj, st, TasksDataFormat.MPP);

st.Seek(0, SeekOrigin.Begin); //In this line the error is shown
StreamReader sr = new StreamReader(st);

In this case, i need the stream because after i upload it to external server with this paremeter. The code works well when i used to save the project in XML.

There is a way to test in evaluation mode if works the MPP saving???


Following is the sample code which can be used to access the extended attribute "Description" from the above example, update the extended attribute for each task and then save back on the disc.

Please give it a try and let us know your feedback.

static void UpdateExtendedAttribute()


//create a project reader instance

ProjectReader rdr = new ProjectReader();

//call read method of project reader object to get project object

Project project = rdr.Read(@"Tasks_448660\project_res.mpp");

foreach (Task tsk in project.RootTask.Children)


FilterByAlias filter = new FilterByAlias("Description");

ExtendedAttribute attr = ArrayUtils.Find(tsk.ExtendedAttribute, filter) as ExtendedAttribute;

attr.Value = "New Value for " + tsk.Name;


//Recalculate the Project now






private class FilterByAlias : ICondition


private string alias;

public FilterByAlias(string alias)


this.alias = alias.ToUpper(CultureInfo.InvariantCulture).Trim();


public bool Check(object el)


ExtendedAttribute attr = el as ExtendedAttribute;

if (attr == null || attr.AttributeDefinition == null ||attr.AttributeDefinition.Alias == null)

return false;

return (attr.AttributeDefinition.Alias.ToUpper(CultureInfo.InvariantCulture).Trim() == alias);



In order to avoid the evaluation error, you can get a 30 day Temporary License by visiting this link. Please apply for a temporary license and let us know if we can be of any additional help to you.

Works very well the code to read the custom headers. About the license, i got one and my code works now… thanks.