mirror of
https://gitee.com/dotnetchina/MiniExcel.git
synced 2024-12-04 21:07:34 +08:00
32 lines
968 B
C#
32 lines
968 B
C#
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");
|
|
}
|
|
}
|