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