MPP column count & name related

Hi Team,


Is there a way to only read the columns present in the MPP file and add it in the list. (also need the column count of the column present in a sample MPP file.)

I want to use this to check the no. of columns present in the MPP with the columns prsent in the page to import to DB before calling the import method.



Regards
Abhishek

Hi Abhishek,


Thank you for contacting Aspose support team.

You may please use Table in the default gantt chart view to get the list and count of the columns present in the MPP. Please give a try to the following sample code and share the feedback.



Project proj = new Project(“project.mpp”);

GanttChartView defaultView = proj.DefaultView as GanttChartView;


foreach(TableField fld in defaultView.Table.TableFields)

Console.WriteLine(fld.Field);

Hi Team,


I am able to read the columns vbut it is giving the actual name and I want the alias name i.e the name which I have set to the MPP field.

Like instead of Flag1 I want Critical Path Indicator (the actual name).

Regards
Abhihsk

Hi Abhishek,


The Alias names are present in the project ExtendedAttributeDefinitionCollection. The ExtendedAttributeDefinition contains element type, field name and alias. Element type can be Task, Resource, Calendar or Assignment (in you case it is Task). Field Name is the name of column like Flag1 here and Alias is given name like “Critical Path Indicator”.

You have to retrieve the alias name from the project.ExtendedAttributeDefinitionCollection such that combining the ElementType and FieldName will match with TableField.Field value. Following code displays the alias names and field names present in the Project.



Project proj = new Project(path + “sample.mpp”);


Console.WriteLine(“EXTENDED ATTRIBUTES\n”);

foreach (ExtendedAttributeDefinition def in proj.ExtendedAttributes)

{

Console.WriteLine(def.ElementType + def.FieldName + “=” + def.Alias);

}


Console.WriteLine("\n\nTABLE FIELDS\n");

GanttChartView defaultView = proj.DefaultView as GanttChartView;


foreach (TableField fld in defaultView.Table.TableFields)

Console.WriteLine(fld.Field);