Hi,
I am able to use the project.Save to get a default set of columns exported to excel. I would like to get all the columns like (successors, Baseline Start, baseline Finish) exported to Excel. Is there a different way I should implement? Could I have a sample of this implementation to export all the fields? Is there a way to export all the fields available in the mpp into excel?
@abhargava ,
if you are saving to Xlsx format, you can use XlsxOptions and customize its View property.
You can take all fields from project.DefaultView (default view in MPP file, which is shown when MPP file is opened using MS Project) and add a coresponding column to XlsxOptions.View.Columns collection using the following code:
string folder = "c:\\test\\";
Project project = new Project(folder + "input.mpp");
XlsxOptions options = new XlsxOptions();
var view = project.DefaultView;
if (view.Table == null)
{
return;
}
if (view.Table.TableType != ItemType.TaskItem)
{
return;
}
List<ViewColumn> columns = new List<ViewColumn>();
foreach (var t in view.Table.TableFields)
{
var columnTitle = FieldHelper.GetDefaultFieldTitle(t.Field);
columns.Add(new GanttChartColumn(columnTitle, t.Width * 5, t.Field));
}
options.View = new ProjectView(columns);
string fileName = folder + string.Format("output_{0}_{1}.xlsx", view.Name.Replace("&", ""), view.Uid);
project.Save(fileName, options);
Can you clarify what does “all the fields” mean? All fields supported by MS Project ?
For example, for task entity count of fields is over 850.