public IActionResult OnPostDown()
{
DataTable table = new DataTable();
table.Columns.Add("部门", typeof(string));
table.Columns.Add("姓名", typeof(string));
table.Columns.Add("职务", typeof(string));
table.Columns.Add("评定等级", typeof(string));
table.Columns.Add("年份", typeof(string));
table.Columns.Add("次数", typeof(string));
table.Columns.Add("详细", typeof(string));
DataTable dt = _db.Ado.GetDataTable("select * from pub_member where bm<>'校领导' and groupid<>3 order by id asc");//bm asc,
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = table.NewRow();
dr[0] = dt.Rows[i]["bm"].ToString();
dr[1] = dt.Rows[i]["truename"].ToString();
dr[2] = dt.Rows[i]["zw"].ToString();
table.Rows.Add(dr);
}
}
// 创建内存流用于存储 Excel 数据
using var stream = new MemoryStream();
// 使用 MiniExcel 将数据写入到内存流
stream.SaveAs(table);
// 返回 Excel 文件作为文件下载响应
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "评定表_"+ tbl + ".xlsx");
}