导出excel的乱码问题,
用以下代码导出datagrid,有些文件正常,有些会是乱码,是啥问题??
所有的导出都是经过这个文件导出的.
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=export.xls");
HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/vnd.ms-excel";
/****image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword****/
myDataGrid.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
myDataGrid.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();