Hi All,
I am facing issue when I try to export more than 5 Lakh Records in Asp.Net Excel Export. I am getting
Exception of type 'System.OutOfMemoryException' was thrown.
The above exception. If anyone knows for the solution, Suggest me with Sample Code.
Code which i used :
-
- GridView GridView1 = new GridView();
- GridView1.ShowFooter = true;
- GridView1.AllowPaging = false;
- GridView1.DataSource = Dt2;
- GridView1.DataBind();
- Response.Clear();
- Response.Buffer = true;
- Response.AddHeader("content-disposition",
- "attachment;filename=MemberHistory.xls");
- Response.Charset = "";
- Response.ContentType = "application/vnd.ms-excel";
- StringWriter sw = new StringWriter();
- HtmlTextWriter hw = new HtmlTextWriter(sw);
- for (int i = 0; i < GridView1.Rows.Count; i++)
- {
-
- GridView1.Rows[i].Attributes.Add("class", "textmode");
- }
- GridView1.RenderControl(hw);
-
- string style = @"<style> TD { mso-number-format:\@; } </style>";
- Response.Write(style);
- Response.Output.Write(sw.ToString());
- Response.Flush();
- Response.End();
Thanks in advance
Karthik K