public void Export() { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=Summary.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; using (StringWriter sw = new StringWriter()) { HtmlTextWriter hw = new HtmlTextWriter(sw); //To Export all pages GVExport.AllowPaging = false; // this.BindGrid(); GVExport.HeaderRow.BackColor = Color.White; foreach (TableCell cell in GVExport.HeaderRow.Cells) { cell.BackColor = GVExport.HeaderStyle.BackColor; } foreach (GridViewRow row in GVExport.Rows) { row.BackColor = Color.White; foreach (TableCell cell in row.Cells) { if (row.RowIndex % 2 == 0) { cell.BackColor = GVExport.AlternatingRowStyle.BackColor; } else { cell.BackColor = GVExport.RowStyle.BackColor; } } } GVExport.RenderControl(hw); //style to format numbers to string // string style = @"<style> .textmode { } </style>"; // Response.Write(); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)