首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

用IE打开excel或doc文件出现乱码,该怎么解决

2012-01-15 
用IE打开excel或doc文件出现乱码用IE打开excel或doc文件出现乱码代码如下,请请教~stringTmpPathServer.Ma

用IE打开excel或doc文件出现乱码
用IE打开excel或doc文件出现乱码
代码如下,请请教~


                        string   TmpPath   =   Server.MapPath( "../upFile/PartLists/200701040115034.xls ");
                        FileStream   fs   =   new   FileStream(TmpPath,   FileMode.Open);
                        BinaryReader   bw;
                        byte[]   outbyte   =   new   byte[fs.Length];
                        fs.Read(outbyte,   0,   int.Parse(fs.Length.ToString()));
                        long   FileLength   =   fs.Length;
                        Response.Clear();
                        Response.ContentType   =   "application/ms-excel ";
                        Response.AddHeader( "Content-Disposition ",   "incline;   filename= "   +   HttpUtility.UrlEncode(Path.GetFileName(TmpPath),   System.Text.Encoding.UTF8));
                        Response.AddHeader( "Content-Length ",   FileLength.ToString());
                        Response.BinaryWrite(outbyte);
                        Response.End();



[解决办法]
Response.ContentEncoding = System.Text.Encoding.GetEncoding( "GB2312 ");
[解决办法]
HttpUtility.UrlEncode(Path.GetFileName(TmpPath), System.Text.Encoding.UTF8));
改一下这行的编码,或者其他地方有编码的,都改一下 用 GB2312

热点排行