// Response.ContentType = "application/x-rar-compressed";
Export("application/ms-excel", filename ); //注意文件一类型
filename//为路径
private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
// HtmlTextWriter hw = new HtmlTextWriter(tw);
// GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}