I am trying to create an excel file from a datagrid in my asp.net page using the code below. I can create an excel file. But the created excel file has no cell borders. Without cell borders, it looks like a document with text.

My code
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=asas.xls");
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(dgShipping);
dgShipping.AllowPaging = false;
DisplayRecords();
dgShipping.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
dgShipping.AllowPaging = true;
Any workarounds for this? thanks for the help
Shyju source
share