public void ProcessRequest(HttpContext context) { var dt = DBServer.GetDataTable("select * from table"); var ms = GetExcel.DataTableToExcelXlsx(dt, "Sheet1"); ms.WriteTo(context.Response.OutputStream); context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; context.Response.AddHeader("Content-Disposition", "attachment;filename=EasyEditCmsGridData.xlsx"); context.Response.StatusCode = 200; context.Response.End(); }