js 编码: encodeURIComponent(row.FILEPATH);
C#后台解码:
strSub = context.Server.UrlDecode(strSub);
生成Excel中文乱码:
string tempFilename = filepathArr[filepathArr.Length - 1];//文件名称
System.IO.FileInfo file = new System.IO.FileInfo(strSub);//创建一个文件对象
if (file.Exists)
{
response.Clear();
response.ContentEncoding = System.Text.Encoding.UTF8;
response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", HttpUtility.UrlEncode(tempFilename)));
response.AddHeader("Content-Length", file.Length.ToString());
//添加头文件,指定文件的大小,让浏览器显示文件下载的速度
response.WriteFile(file.FullName);// 把文件流发送到客户端
response.End();
}