C#导出txt文件
//导成txt
Response.Clear();
Response.Buffer = false;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(fileName) + ".txt");
Response.ContentType = "text/plain";
this.EnableViewState = false;
Response.Write(sb.ToString());
Response.End();
//导成excel
Response.Clear();
Response.Buffer = false;
Response.Charset = "GB2312";
//Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=aa.txt");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Response.ContentType = "application/ms-excel";
Response.ContentType = "text/plain";
this.EnableViewState = false;
// System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
//System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
//this.GridView1.RenderControl(oHtmlTextWriter);
Response.Write("sdfasdfasdfasdfasdfasdfasdfasdfadf");
Response.End();
Response.Clear();
Response.Buffer = false;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(fileName) + ".txt");
Response.ContentType = "text/plain";
this.EnableViewState = false;
Response.Write(sb.ToString());
Response.End();
//导成excel
Response.Clear();
Response.Buffer = false;
Response.Charset = "GB2312";
//Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=aa.txt");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Response.ContentType = "application/ms-excel";
Response.ContentType = "text/plain";
this.EnableViewState = false;
// System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
//System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
//this.GridView1.RenderControl(oHtmlTextWriter);
Response.Write("sdfasdfasdfasdfasdfasdfasdfasdfadf");
Response.End();
lei1217