Author: mychucky | Posted on: 4/28/2010 1:19:12 PM | Views : 702

I'm trying to export my data to an Excel file. Here's my code behind:
protected void btnExcel_Click(object sender, ImageClickEventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); gdvClassNotes.AllowPaging = false; gdvClassNotes.DataBind(); //Change the Header Row back to white color gdvClassNotes.HeaderRow.Style.Add("background-color", "#FFFFFF"); //Apply style to Individual Cells #region Format table cells gdvClassNotes.HeaderRow.Cells[0].Style.Add("background-color", "#FFF ...

Go to the complete details ...