public ActionResult EmployeeAllowanceFullExportExcel(string filterString, int pageIndex, int pageSize, int Type) { DataTable dt = new DataTable("Grid"); dt.Columns.AddRange(new DataColumn[7] { new DataColumn(AppRes.FullName), new DataColumn("Loại phụ cấp"), new DataColumn(AppRes.Amount), new DataColumn(AppRes.Note), new DataColumn(AppRes.StartDate), new DataColumn(AppRes.EndDate), new DataColumn(AppRes.Company) }); dt.Columns[2].DataType = typeof(double); var db = new ImportExcelDal(); int?total = 0; int staffID = 0; var baseListParam = new BaseListParam() { FilterField = filterString, OrderByField = "", PageIndex = pageIndex, PageSize = int.MaxValue, UserType = Global.CurrentUser.RoleId, UserId = Global.CurrentUser.LoginUserId, DeptId = Global.CurrentUser.OrganizationUnitID, LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString() }; var lstData = db.GetEmployeeAllowance(baseListParam, out total); foreach (var item in lstData) { dt.Rows.Add( item.FullName, item.AllowanceName, item.Amount, item.Note, String.Format("{0:dd/MM/yyyy}", item.StartDate), String.Format("{0:dd/MM/yyyy}", item.EndDate), item.CompanyName ); } var wb = new XLWorkbook(); wb.Worksheets.Add(dt); byte[] data = null; using (var stream = new MemoryStream()) { wb.SaveAs(stream); data = stream.ToArray(); } return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "EmployeeAllowanceFull.xlsx")); }
public ActionResult TableServerSideGetData4(int pageIndex, int pageSize, string filter = "") { var db = new ImportExcelDal(); int?total = 0; var baseListParam = new BaseListParam() { FilterField = filter, OrderByField = "", UserType = Global.CurrentUser.RoleId, UserId = Global.CurrentUser.LoginUserId, DeptId = Global.CurrentUser.OrganizationUnitID, PageIndex = pageIndex, PageSize = pageSize, LanguageCode = Global.CurrentUser.CurrentLanguageID.ToString() }; var result = db.GetEmployeeAllowance(baseListParam, out total); return(Content(JsonConvert.SerializeObject(new { employees = result, totalCount = total }))); }