Вернуться .файл XLSX в Excel с веб-API
<pre> Error CS1503 Argument 1: cannot convert from 'System.Collections.Generic.List<WebApi2.Controllers.Record>' to 'System.IO.Stream'
Что я уже пробовал:
[HttpGet] [Route("ExcelDownload")] public HttpResponseMessage ExcelDownload() { var reportStream = RecordInfo(); var result = Request.CreateResponse(HttpStatusCode.OK); result.Content = new StreamContent(reportStream); // Getting error here result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "Report.xlsx" }; return result; } public List<Record> RecordInfo() { List<Record> recordobj = new List<Record>(); recordobj.Add(new Record { FName = "Smith", LName = "Singh", Address = "Knpur" }); recordobj.Add(new Record { FName = "John", LName = "Kumar", Address = "Lucknow" }); recordobj.Add(new Record { FName = "Vikram", LName = "Kapoor", Address = "Delhi" }); recordobj.Add(new Record { FName = "Tanya", LName = "Shrma", Address = "Banaras" }); recordobj.Add(new Record { FName = "Malini", LName = "Ahuja", Address = "Gujrat" }); recordobj.Add(new Record { FName = "Varun", LName = "Katiyar", Address = "Rajasthan" }); recordobj.Add(new Record { FName = "Arun ", LName = "Singh", Address = "Jaipur" }); recordobj.Add(new Record { FName = "Ram", LName = "Kapoor", Address = "Panjab" }); recordobj.Add(new Record { FName = "Vishakha", LName = "Singh", Address = "Banglor" }); recordobj.Add(new Record { FName = "Tarun", LName = "Singh", Address = "Kannauj" }); recordobj.Add(new Record { FName = "Mayank", LName = "Dubey", Address = "Farrukhabad" }); return recordobj; }