I've used the example here to sort it:
I've updated my controller to use an anonymous type like so:
[HttpGet("/export/expense-records-paid/excel")]
public async Task<IActionResult> ExportPaidExpenseRecordsToExcel()
{
var claimsPrincipal = User;
var companyId = claimsPrincipal.FindFirst(c => c.Type == "companyId");
if (companyId != null)
{
var data = context.expense_records.Where(x => x.DeleteDate == null && x.UserMarkedPaidDate == null
&& x.Expense!.Status == Status.AwaitingReimbursement.ToString() && x.Expense!.CompanyId == int.Parse(companyId.Value))
.Select(x => new { FullName = x.Expense.User.FirstName + " " + x.Expense.User.LastName });
var result = await ToExcel(ApplyQuery(data, Request.Query));
return Ok(result);
}
return NoContent();
}
and then I've updated my call to the export service accordingly:
public async Task ExportExpenseRecords(string type)
{
await _exportService.Export("expense-records-paid", type, new Query()
{
OrderBy = expenseRecordGrid.Query.OrderBy,
Filter = expenseRecordGrid.Query.Filter,
Select = "FullName"
});
}
Just need to go through and add back in the missing fields now.