小弟我在将Datalist的表格数据导出到EXCEL时,出现了字体乱码的问题.奇怪的是,相同的代码对有的DATALIST可以正常导出,有的就不可以(表头好象超过一行就不能正常导出)不知道是什么原因
代码如下:
private void ConvertToExcel_Click(object sender, System.EventArgs e)
{
Response.Clear(); 
Response.Buffer= true; 
Response.Charset="GB2312";    
Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls"); 
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 
this.EnableViewState = false;    
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); 
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.DL_Sign.RenderControl(oHtmlTextWriter); 
//this.myDG.RenderControl(oHtmlTextWriter); 
Response.Write(oStringWriter.ToString());
Response.End();
}