MiniExcel/tests/MiniExcel.Tests.AspNetMvc/Controllers/HomeController.cs

26 lines
591 B
C#
Raw Normal View History

2021-03-14 20:25:04 +08:00
using System;
using System.Web.Mvc;
using System.Collections.Generic;
using System.IO;
using MiniExcelLibs;
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index() => View();
public ActionResult Download()
{
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");
}
}