【发布时间】:2016-06-30 14:54:56
【问题描述】:
在我的 gridview 中,我有 30000 条记录,当我导出到 excel 时,它只导出了近 12000 条记录,下面我的代码导出到 excel。
GridView1.AllowPaging = false;
DataTable dt = (DataTable)Session["tabledata"];
GridView1.DataSource = dt;
GridView1.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
//Change the Header Row back to white color
GridView1.HeaderRow.Style.Add("background-color", "Red");
//Applying stlye to gridview header cells
for (int i = 0; i < GridView1.HeaderRow.Cells.Count; i++)
{
GridView1.HeaderRow.Cells[i].Style.Add("background-color", "Red");
}
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
我如何将所有(30k)gridview 记录导出到 excel?
【问题讨论】: