我现在开发的是一个B/S的结构,在画面上生成了一个Htmltable ,我现在想将结果输出到Excel中,我自己参照网上修改了一段代码,但是不能正常输出,请教大侠指点一下,谢谢!!
我的代码如下:
string filename="";
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
filename="Query.xls";
Response.AppendHeader("Content-Disposition","attachment;filename="+ filename +"");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-excel";
this.EnableViewState = true;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.Table1.RenderControl(oHtmlTextWriter);      
Response.Write(oHtmlTextWriter.ToString());
Response.End();请指教一下!!谢谢!