public IActionResult ExportExcel(string keyword = "") { DataAccess.TASM_MACHINEManager manager = new DataAccess.TASM_MACHINEManager(); List <MachineModel> list = new List <MachineModel>(); manager.ListByWhere(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("订单时间"); row1.CreateCell(6).SetCellValue("送货时间"); row1.CreateCell(7).SetCellValue("送货单号"); row1.CreateCell(8).SetCellValue("验收时间"); row1.CreateCell(9).SetCellValue("创建时间"); for (int i = 0; i < list.Count(); i++) { NPOI.SS.UserModel.IRow rowTemp = sheet1.CreateRow(i + 1); rowTemp.CreateCell(0).SetCellValue(list[i].NAME); rowTemp.CreateCell(1).SetCellValue(list[i].TYPESNAME); rowTemp.CreateCell(2).SetCellValue(list[i].SERIAL); rowTemp.CreateCell(3).SetCellValue(list[i].CUSTOMER); rowTemp.CreateCell(4).SetCellValue(list[i].CONTRACT); rowTemp.CreateCell(5).SetCellValue(list[i].ORDERTIME.Value.ToString("yyyy-MM-dd")); rowTemp.CreateCell(6).SetCellValue(list[i].DELIVERYTIME.Value); rowTemp.CreateCell(7).SetCellValue(list[i].DELIVERYNUMBER); rowTemp.CreateCell(8).SetCellValue(list[i].CHECKTIME.Value); rowTemp.CreateCell(9).SetCellValue(list[i].CREATETIME.Value); } 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(ListMachineInputModel model) { DataAccess.TASM_MACHINEManager manager = new DataAccess.TASM_MACHINEManager(); SqlSugar.PageModel p = new SqlSugar.PageModel() { PageIndex = model.pageindex, PageSize = model.pagesize }; List <MachineModel> list = new List <MachineModel>(); manager.ListByWhere(model.keywords, ref p, ref list); return(SuccessResultList(list, p)); }
public IActionResult List(string keywords, int pageIndex, int pageSize) { DataAccess.TASM_MACHINEManager manager = new DataAccess.TASM_MACHINEManager(); SqlSugar.PageModel p = new SqlSugar.PageModel() { PageIndex = pageIndex, PageSize = pageSize }; List <MachineModel> list = new List <MachineModel>(); manager.ListByWhere(keywords, ref p, ref list); return(SuccessResultList(list, p)); }