I have the following function to download an excel file of results passed via LoadFromCollection()
. It works locally but once I deploy to my Dev server (Ubuntu) I get a 500 error.
await Task.Yield();
var stream = new MemoryStream();
using (var package = new ExcelPackage(stream))
{
var workSheet = package.Workbook.Worksheets.Add(excelName);
workSheet.Row(1).Height = 20;
workSheet.Row(1).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
workSheet.Row(1).Style.Font.Bold = true;
workSheet.Column(6).Style.Numberformat.Format = "yyyy-mm-dd hh:mm:ss";
workSheet.Column(12).Style.Numberformat.Format = "yyyy-mm-dd hh:mm:ss";
workSheet.Column(13).Style.Numberformat.Format = "yyyy-mm-dd hh:mm:ss";
workSheet.Cells.LoadFromCollection(model.Trips, true).AutoFitColumns();
package.Save();
}
stream.Position = 0;
return File(stream, "application/octet-stream", excelName);
I've tried a few approaches now from tutorials / stack overflow suggestions and I'm just not sure what the problem is anymore. I'm wondering if it's an issue with the operation system (Windows vs Linux) or the environment configuration?