导出DataList到excel中的方法[转]

我的代码如下,但是只能做到导出,不能在Excel中显示对应的颜色。  
   
  Response.Clear();    
  Response.BufferOutput=true;    
  Response.Charset="GB2312";          
  Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls");    
  Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");  
  Response.ContentType   =   "application/ms-excel";    
  DataList1.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.DataList1.RenderControl(oHtmlTextWriter);    
  Response.Write(oStringWriter.ToString());  
  Response.End();  
   
  哪位大大指点一下?
问题点数:100、回复次数:6
原文地址:https://www.cnblogs.com/jacktu/p/412649.html