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
AMOL
NA
17
14k
Save the contents of gridview to the excel file?
Sep 5 2012 7:09 AM
I want to save the contents of gridview to the excel file and i am using the following code to done this. It works fine but the excel file it make is of the 0 KB size. please help me to resolve this issue. Thanks in advance...
having the following code with me but it sttil irritate me...
please suggest me other method.....
private void ExportToExcel()
{
HtmlForm form = new HtmlForm();
string attachment = "attachment; filename=AssignedDoctors.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
// put your grid view in here
form.Controls.Add(GridView1);
this.Controls.Add(form);
form.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
}
Reply
Answers (
4
)
how to create dynamic theme in asp.net mvc3
best tutorial site for asp.net,sql for beginners.