求助导出Excel
请大家帮忙:给一个 导出excel的例子。
Response.ClearContent();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName1.xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/excel";
oStringWriter = new ();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
table.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.Flush();
这一段是目前我用来将web服务器控件table导出到excel的代码,你可以参考下,网上讲这个的还是挺多的。
Response.End();