public ActionResult ExportExcel() { ExcelHelp excel = new ExcelHelp(); DataTable dt = new DataTable("Test"); dt.Columns.Add("姓名", typeof(string)); dt.Columns.Add("性别", typeof(string)); dt.Columns.Add("电话", typeof(string)); dt.Rows.Add("李磊", "男", "15898653259"); dt.Rows.Add("张执先", "男", "19158974563"); dt.Rows.Add("韩志成", "女", "16498653245"); var ms = excel.ExportDataTableToExcel(dt, "MyTest"); return(File(ms.ToArray(), "application/vnd.ms-excel", "导出.xlsx")); }