System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
GridView gv = new GridView();
gv.EnableViewState = false;
gv.DataSource = tbl;
gv.DataBind();
gv.RenderControl(hw);
string style = @"<style type=""text/css"">td{mso-number-format:'\@';}</style>";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+DateTime.Now.ToFileTime()+".xls");
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel";
Response.Output.Write(style);
Response.Write(tw.ToString());
Response.Flush();
Response.End();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
GridView gv = new GridView();
gv.EnableViewState = false;
gv.DataSource = tbl;
gv.DataBind();
gv.RenderControl(hw);
string style = @"<style type=""text/css"">td{mso-number-format:'\@';}</style>";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+DateTime.Now.ToFileTime()+".xls");
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel";
Response.Output.Write(style);
Response.Write(tw.ToString());
Response.Flush();
Response.End();