protected void btnExportToExcel_Click(object sender, EventArgs e) { try { Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "EmployeeAttendance.xls")); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gvDisplayRecords.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } catch (Exception ex) { lblEmpAttError.Text = "" + ex.Message; } }
Response.Write(sw.ToString());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)