Hi guys, what is the recommended way to export a list to excel or csv?
I currently am developing a web app using Angular 2 and ASP.NET Core and I am generating a list in my back end that I send as JSON to the client side. Since the list is already generated I would just like the file to be downloaded for the user. In the past I would used OpenXML or some library but I do not believe those libraries exist to me in ASP.NET Core.
Here is a simplified idea of what I am doing I would just like to return that list to the user in the form of a CSV or Excel file.
[HttpGet] [Route("/api/preview/{item}")] public IActionResult Preview(string item) { if (item!= null) { var preview = _context.dbPreview.FromSql("Exec sampleStoredProcedure {0}, 1", item).ToList(); return Ok(preview); } }
Thanks