怎样将DataList导出到Excel中,并在Excel中保留DataList中的颜色属性
我的代码如下,但是只能做到导出,不能在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();
哪位大大指点一下?