Wondering if anyone can assist. I have an .ashx file which creates an excel document which is populated with a C# DataGrid. This all works well the only problem is when I open the excel document the automatic gridlines are turned off. Is there a way to enable them?
Thanks in advance, Air
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = "";
response.ContentEncoding = System.Text.Encoding.Default;
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=\"dataImportTemplate.xls\"");
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
dg.DataSource = ds.Tables[0];
dg.ShowHeader = false;
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
}
}