Help - Create a new List with some elements from another List

  • Thread starter Thread starter mamabrowsss
  • Start date Start date
M

mamabrowsss

Guest
I'm having trouble figuring out how to take certain elements from one List and creating a new List. This new List will be exported to Excel. The export works fine, but I'm currently exporting a list (schedulesToExport) that has more info than I need. What I need to do is create a list with only some elements from schedulesToExport (fields I need to pull from schedulesToExport are Date, User, Client and Product). If anyone can show me how to accomplish this it would be a great help and I would really really appreciate it.. Thank you :)

private void ExportNewScheduleReport(List<DirectTocDto> schedulesToExport)
{
//Create new list to export here

try
{
Cursor savePointer = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
var exporter = new ExcelListExporter();
exporter.ExportListToExcel(
sheetName: "Added Schedule Headers",
listToExport: schedulesToExport, //change the list to export to new abbreviated list
freezePaneSheetNumber: 1);

Cursor.Current = savePointer;
}
catch (Exception ex)
{
MessageDialogs.ErrorDialog(MessageBoxText.ExportError);
}
}
}

Continue reading...
 
Back
Top