ASP.NET中的Excel下载问题

时间:2019-07-12 11:28:13

标签: asp.net excel

我正在从gridview导出大量数据到Excel(2万行)。我无法导出此大数据集-该代码仅导出2400行。

string attachment = "attachment;filename=Itemofservice.xls";

Response.Clear();
Response.AddHeader("content-disposition", attachment);
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
System.Web.UI.WebControls.GridView Dgr_Select1 = new System.Web.UI.WebControls.GridView();

Dgr_Select1.DataSource = Ds.Tables["Itemofservice"];
Dgr_Select1.DataBind();

Dgr_Select1.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());
Response.End();

0 个答案:

没有答案