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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Export Gridview to Word Format
Ashish Srivastava
May 11
2016
Code
743
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
protected
void
btnExportWord_Click(
object
sender, EventArgs e)
{
Response.Clear();
Response.Buffer =
true
;
Response.AddHeader(
"content-disposition"
,
"attachment;filename=GridViewExport.doc"
);
Response.Charset =
""
;
Response.ContentType =
"application/vnd.ms-word "
;
StringWriter sw=
new
StringWriter();
HtmlTextWriter hw =
new
HtmlTextWriter(sw);
GridView1.AllowPaging =
false
;
GridView1.DataBind();
GridView1.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
Export Gridview
Word Format