using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using System.IO; using MiniExcelLibs; public class Startup { public void ConfigureServices(IServiceCollection services) => services.AddMvc(); public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute()); } } public class HomeController : Controller { public IActionResult Index() { var values = new[] { new { Column1 = "MiniExcel", Column2 = 1 }, new { Column1 = "Github", Column2 = 2} }; var stream = new MemoryStream(); stream.SaveAs(values); return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "demo.xlsx"); } }