Hello
I am using a code for download attached excel file.
After download this excel file Gridline of excel is automatically false.
Means Excel gridline not showing.
my code:-
Response.Clear();
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
Response.ContentType = "application/msexcel";
Response.AddHeader("Content-disposition", string.Format("attachment;filename=MyFiles.xls; Gridlines=true"));
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
Table table = new Table();
table.GridLines = gv.GridLines;
if (gv.HeaderRow != null)
{
table.Rows.Add(gv.HeaderRow);
}
foreach (GridViewRow row in gv.Rows)
{
table.Rows.Add(row);
}
table.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
please help