public IActionResult Post(StudentRegisterRequest request) { List <StudentSearchResponse> list = StudentService.GetListBykeyWord(""); string[] header = new string[] { "ID", "学生姓名", "年龄", "性别ID", "性别", "出生年月", "手机号", "校区名称" }; NPOIExcelExport excelExport = new NPOIExcelExport(); excelExport.Add <StudentSearchResponse>(list, header); return(excelExport.DownloadToFile(this, "学生资料")); }
public FileResult GetStudentLessonsExport([FromQuery] LifeClassLessonStudentSearchRequest request) { LifeClassService service = new LifeClassService(base.SchoolId); List <LifeClassLessonStudentExportResponse> list = service.GetStudentLessonsExport(request); string[] header = new string[] { "学生姓名", "性别", "出生日期", "证件类型", "证件号码", "班级代码" }; NPOIExcelExport excelExport = new NPOIExcelExport(); excelExport.Add(list, header); return(excelExport.DownloadToFile(this, "写生排课")); }
/// <summary> /// 查询导出 /// </summary> /// <param name="search"></param> /// <returns></returns> public HttpResponseMessage Get([FromUri] TestSearch search, bool isExport) { var dataList = dal.GetListByCondition(search); MemoryStream ms = new NPOIExcelExport().DataToExcel <TBLTEST>(dataList, search.ExportTitles.Split(',').ToList(), search.ExportColumns.Split(',').ToList(), search.ExportTimeZone); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StreamContent(ms); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = Guid.NewGuid() + ".xlsx" }; return(response); }