这篇文章主要介绍“如何解决asp.net导出Excel显示中文乱码的问题”,在日常操作中,相信很多人在如何解决asp.net导出Excel显示中文乱码的问题问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何解决asp.net导出Excel显示中文乱码的问题”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
创新互联建站主要从事成都做网站、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务依兰,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108复制代码 代码如下:
protected void btnExcel_Click(object sender, EventArgs e)
{
List
string filename = "3g流量网龄升级计划用户表";
string name1 = filename;
string bname = Common.MyRequest.GetBrowserName().ToLower();
if (bname.Contains("firefox"))
{
}
else if (bname.Contains("ie"))
{
filename = HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8);
}
else
{
filename = HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8);
}
HttpResponse resp = System.Web.HttpContext.Current.Response;
resp.Charset = "utf-8";
resp.Clear();
resp.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
resp.ContentEncoding = System.Text.Encoding.UTF8;
resp.ContentType = "application/ms-excel";
string style =""+ "";
resp.Write(style);
//resp.Write(ExportTable(list));
resp.Write("
" +"手机"+ " | " + "渠道" + " | " +"时间" + " |
---|---|---|
" + model.phone + " | ");" + model.qudao + " | ");" + model.tm + " | ");