I'm using blazor and .net 5. I'm trying to do an excel export using ClosedXML. Here is the simple method I wrote:
public IActionResult CreateExcelSheet()
{
using (var wbook = new XLWorkbook())
{
var ws = wbook.Worksheets.Add("Sheet1");
ws.Cell("A1").Value = "1";
using (var stream = new MemoryStream())
{
wbook.SaveAs(stream);
var content = stream.ToArray();
return File(content, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Opportunities.xlsx");
}
}
}
The return file has a red underline saying Non-invocable member 'File' cannot be used like a method. I'm not really sure how to correct this... I'm also not sure if I'm doing this right with blazor and .net 5. Any help is greatly appreciated!