Get all fields and values for a task

Hello,


I need to know how to read all tasks field names and column values.
Something like what another user requested in this post
Retrieve Project Task data and their field names including custom fields
but also including the column values for each field.
Using Task.Get(Tsk.Name) for each TSK class field requires that I specify the property key.
However that’s not convenient in cycles and it will require a heavy reflection to avoid
hardcoding of data.
I’ve checked the documentation but I was unable to find a GET method for all columns.

regards
Lyubo


Hi Lyubo,


Thank you for writing to Aspose support team.

I am afraid to share that no such option is available and you have to do some manual mapping for extracting values of available fields in the default view table. Please feel free to write us back if you have any other query in this regard.

hi Kashif,


I’m trying something else - to export the whole PPT project into Excel and then read from there all columns.
However I came into another issue - the resource names column is not exported.
Is that a bug?

regards
Lyubo

Hi Lyubo,


You may please use following sample code to retrieve the resource names and share the feedback.


Project proj = new Project(“Sample.mpp”);
ChildTasksCollector collector = new ChildTasksCollector(); // Create a ChildTasksCollector instance
TaskUtils.Apply(proj.RootTask, collector, 1); // Collect all the tasks from RootTask using TaskUtils
foreach (Task tsk in collector.Tasks)
{
//Read resource name
foreach(ResourceAssignment ass in tsk.Assignments)
{
Console.WriteLine("Resource Name = " + ass.Get(Asn.Resource).Get(Rsc.Name));
}
}

hi Kashif,


I know that way and it works, I was saying that the export to XLS is not exporting the resource names.
So even if I use that approach I have to take care manually of other columns…

Hi Lyubo,


We have tested the issue with the attached project file by converting it to Excel and the resources are included in the output file. Please try this at your end and let us know your feedback.

Sample Code:

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

project.Save(“OpenXML.xlsx”, SaveFileFormat.XLSX);

hi Kashif,


I’ve tried that, but it’s not working the way it should.
I’m attaching my MPP used for the test.
Please try it.

regards
Lyubo

Hi Lyubo,


Thank you for sharing the sample MPP file.

We were able to reproduce this problem at our end where the output XLSX file is not able to populate the project data. We have logged it as TASKSNET-1622 in our issue tracking system for further consideration by our Product team and will update you here once there is some information available in this regard.

@lyubobg,

We have just released Aspose.Tasks for .NET 17.7 version where this issue has been fixed. Please download this latest version for testing at your end and let us know if we can be of any additional help to you.