public IActionResult ExportExcelUnion(string date, string keyword = "") { TASM_TRAVELManager manager = new TASM_TRAVELManager(); DateTime time = DateTime.Now; if (!string.IsNullOrEmpty(date)) { time = DateTime.Parse(date); } List <DirectionModel> list = new List <DirectionModel>(); manager.ListBaseUser(time, keyword, ref list); HSSFWorkbook excelBook = new HSSFWorkbook(); //创建工作簿Excel ISheet sheet1 = excelBook.CreateSheet("动向信息表"); IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("工号"); row1.CreateCell(1).SetCellValue("姓名"); row1.CreateCell(2).SetCellValue("部门"); row1.CreateCell(3).SetCellValue("职务"); row1.CreateCell(4).SetCellValue("电话"); row1.CreateCell(5).SetCellValue("当月出差天数"); for (int i = 0; i < list.Count(); i++) { NPOI.SS.UserModel.IRow rowTemp = sheet1.CreateRow(i + 1); rowTemp.CreateCell(0).SetCellValue(list[i].WORK_ID); rowTemp.CreateCell(1).SetCellValue(list[i].USER_NAME); rowTemp.CreateCell(2).SetCellValue(list[i].DEPARTMENT); rowTemp.CreateCell(3).SetCellValue(list[i].DTNAME); rowTemp.CreateCell(4).SetCellValue(list[i].MOBILE); rowTemp.CreateCell(5).SetCellValue(list[i].MOUNTHCOUNT); } var fileName = "动向信息" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + ".xls";//文件名 //将Excel表格转化为流,输出 MemoryStream bookStream = new MemoryStream(); excelBook.Write(bookStream); bookStream.Seek(0, SeekOrigin.Begin); return(File(bookStream, "application/vnd.ms-excel", fileName)); }
public IActionResult List(string date, string keyword, int pageIndex, int pageSize) { TASM_TRAVELManager manager = new TASM_TRAVELManager(); SqlSugar.PageModel p = new SqlSugar.PageModel(); p.PageIndex = pageIndex; p.PageSize = pageSize; DateTime time = DateTime.Now; if (!string.IsNullOrEmpty(date)) { time = DateTime.Parse(date); } List <DirectionModel> list = new List <DirectionModel>(); manager.ListBaseUser(time, keyword, ref p, ref list); return(SuccessResultList(list, p)); }