怎么解决这个乱码?
我写了一个导出,导出的名字是中文字,如果写个英文字就不是乱码,代码如下:
public void Bind()
{
string sql = "select * from userInfo";
DataTable dt = SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
StringWriter sw = new StringWriter();
sw.WriteLine("编号\t姓名\t年龄");
foreach(DataRow dr in dt.Rows)
{
sw.WriteLine(dr["id"] + "\t" + dr["name"] + "\t" + dr["age"]);
}
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment; filename=报表.xls");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.Write(sw);
Response.End();
}
请问各位前辈要怎么解决呀!