Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
string fileName = Server.UrlEncode(nameTxt.Value);
if(fileName == "")
fileName = "file";
Response.AppendHeader("Content-Disposition","attachment;filename=" + fileName + ".xls");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("zh-CHS",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.RenderControl(oHtmlTextWriter);
Response.Write("<meta http-equiv=Content-Type content=text/html;charset=gb2312>");
Response.Write(oStringWriter.ToString());
Response.End();