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

Free Support Forum - aspose.com

Aspose Tasks Add New Table Field


I’m using the following code to add a new table field to an existing table in a MPP file.

Aspose.Tasks.License license = new Aspose.Tasks.License();


Project project = new Project(“Project1.mpp”);// Create a new project task

Task task = project.RootTask.Children.Add(“New Activity”);

// Add custom text attribute to created task.

ExtendedAttribute attr = new ExtendedAttribute();

attr.FieldId = ((int)ExtendedAttributeTask.Text1).ToString();

attr.Value = “Activity attribute”;


// Customize table by adding text attribute field

TableField attrField = new TableField();

attrField.Field = Field.TaskText1;

attrField.Width = 20;

attrField.Title = “Custom attribute”;

attrField.AlignTitle = StringAlignment.Center;

attrField.AlignData = StringAlignment.Center;

Aspose.Tasks.Table table = project.Tables.ToList()[0];

table.TableFields.Insert(3, attrField);

project.Save(“Project1.mpp”, SaveFileFormat.MPP);

After execution is complete, the new field is not visible in the MPP file. Can anyone point me in the right direction?

I’ve downloaded a trial version of 9.2.1 of which I have a temporary license for evaluation. I’m using VS 2010 and MS Project 2010.

Thanks, Calvin

Hi Calvin,

Thank you for contacting Aspose Support team.

We were able to reproduce the issue at our end using the latest version of the API and have logged it as TASKS-34464 in our issue tracking system. Our Product team will look into it and we’ll update you here as soon as there is some information available about the status of this issue.

Hi Calvin,

We have further investigated this issue and found that view data is not written to MPP by default. In this case, the Table data relates to the project view data and if you wan to save it, please use the MPPSaveOptions class. Adding the following code should solve the problem.

Sample Code:

MPPSaveOptions mppSaveOptions = new MPPSaveOptions();
mppSaveOptions.WriteViewData = true;
project.Save(path + “Project1.mpp”, mppSaveOptions);

Thanks for quick response. The code provided resolved my issue.

Regards, Calvin

Hi Calvin,

You are welcome and please feel free to contact us for any further query related to the API.