I have list of objects that i want to export to excel:
//My export to excel function:
public static void ExportToExcel(string[,] data, string excelFilePath = null)
{
// .....
}
My list contains many columns so i would like to select specific columns and add them into 2d array, also add the header on the top
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public Address Adress { get; set; }
public Evaluation Evaluation { get; set; }
// ... many more
}
List:
> IEnumerable<Student> students
Fields to be selected:
- Id
- Name
- Address.Zipcode
I can perform this with for loop however i'm interested in linq, also i would like to hear your advice about performance since the list has + 200k records
Edit Sample
Columns => ID Name Zipcode
Rows => values
ID Name Zip
1 Mike 1101
2 Jan 2250
3 Peter 4456