public CPUserController(CPUserService userService, CPRoleService roleService) { _service = userService; _roleService = roleService; var data = _roleService.GetAll(); _listRoles = data?.ToList(); }
public void Export() { var data = _service.GetAll() .OrderByDescending(o => o.ID) .ToList(); DataTable dt = data.ToDataTable(); Response.Clear(); Response.Headers["content-disposition"] = "attachment;filename=Catalog.xls"; Response.ContentType = "application/excel"; string html = Query.ConvertDataTableToHTML(dt); HtmlString htmlTextWriter = new HtmlString(html); Response.WriteAsync(html); }