I am trying to create an excel file from datagrid in my asp.net page using the below code.I am able to create the excel file.But the created excel file does not has the cell borders.Without the cell borders,it looks like a word document.
My code is
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 help