TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Karthik K
1.3k
479
50k
Getting Exception when excel export More than 5 Lakhs Record ?
Aug 19 2020 2:43 AM
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 :
//Create a dummy GridView
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++)
{
//Apply text style to each Row
GridView1.Rows[i].Attributes.Add(
"class"
,
"textmode"
);
}
GridView1.RenderControl(hw);
//style to format numbers to string
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
Reply
Answers (
2
)
Multiple Excel Files on button Click
Get Record From three table in linq