Response.Clear();
Response.Buffer=true;
Response.ContentType="application/vnd.ms-excel";
Response.Charset="";
this.EnableViewState=false;
Response.Buffer=true;
Response.ContentType="application/vnd.ms-excel";
Response.Charset="";
this.EnableViewState=false;
stringwriter sw=new stringwriter();
HtmlTextWriter htw=new HtmlTextWriter(sw);
YoueDataGrid.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
本文介绍了一种使用ASP.NET将数据网格导出为Excel文件的方法。通过设置HTTP响应头并利用HTMLTextWriter来渲染数据网格,可以有效地生成Excel文件,实现数据导出的功能。
1万+

被折叠的 条评论
为什么被折叠?



