Home >> ASP.NET >> Export to Word from GridView in ASP.NET

Export to Word from GridView in ASP.NET

Hi,Today, I am going to continue our GridView tricks series ahead and posting a nice and useful feature. For all list of GridView articles we have written here, you can search for GridView in search box. As I have previously written about Exporting data to Excel from GridView, this is about exporting GridView to Microsoft Word which is another most used document format and needed in most cases.
Lets create a design as below.

I have just dragged and dropped a gridview control and used autoformat to make GridView look some better.

Now bind data to this gridview from backend.

Let’s view page in Browser. You must see data from your database. Mine query has resulted below data in grid.

Perfect, now its time to do the important stuff. Lets write code for Export Button. Double click in button to create a method and automatically bind event with control. Now write below code in backend.

Its time to check our code, Click on Export to Word button. I have attached snapshot of Firefox because it prompts user.

You can save file or just click on Open with your word processor software. I am using Microsoft Word here.

Did you read our previous Export to Excel tutorial? What are the similarities between exporting to Word and Excel?
I am leaving with a question, if you know, leave a reply below.
Thanks for reading . Do not forget to say thanks or plus1 or provide feedback.
+John Bhatt

About John Bhatt

Aka, Prithvi Raj Bhatt, A Proud Nepali, Blogger, Software Developer, ASP.NET, Web Designer & Developer, Faculty and a Troubleshooter blog @PRsBlog

Check Also


Searching GridView Data in ASP.NET

Hi, Today, when visiting a community website, I found below article left unpublished with some …

One comment

  1. Hello! I simply wish to give a huge thumbs
    up for the great info you will have right here on this post.
    I might be coming back to your weblog for more soon.

    Here is my web site … 網路設計

Leave a Reply

Your email address will not be published. Required fields are marked *