标签:post info serialize write sub data orm name app
//导入1111
public ActionResult lead(HttpPostedFileBase fname)
{
if (fname!=null)
{
Stream steam = fname.InputStream;
var table = ExcelHelper.ImportToDataTables(steam);
var json = JsonConvert.SerializeObject(table);
var list = JsonConvert.DeserializeObject<List<student>>(json);
return View("Index", list);
}
else
{
Response.Write("<script>alert(‘请选择文件‘);location.href=‘/Default/Index‘");
return View();
}
}
*****************
@using (Html.BeginForm("lead", "Default", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input id="File1" type="file" name="fname" />
<input id="Submit1" type="submit" value="导入" />
}
------------------------------------------------------------------------
//导出
public FileResult derive()
{
var table = bl.Show();
var fs = ExcelHelper.ExportToXlss(table);
return File(fs,"application/vnd.ms-excel","测试.xls");
}
*****************
<input id="Button1" type="button" value="导出" onclick="location.href=‘/Default/derive‘" />
------------------------------------------------------------------------
标签:post info serialize write sub data orm name app
原文地址:https://www.cnblogs.com/gaoyuhui/p/10957321.html