平台  ASP.NET

this.Response.Clear();
this.Response.Charset = "GB2312";
this.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
this.Response.AddHeader("Content-Disposition",String.Format("attachment; filename=file-{0}.csv",DateTime.Now.ToShortDateString()));
this.Response.ContentType = "application/vnd.ms-excel";
string[] columns = { "序号", "姓名", "手机号码", "电子邮箱", "省份", "城市", "地区" };
const string csv = "1,2,3";
var builder = new StringBuilder();

builder.AppendLine(String.Join(",",columns));
builder.AppendLine(csv);

this.Response.Write(builder);
this.Response.End();

 

相关文章: