Solved

Export ASPX Web page to MS Word

Posted on 2007-04-08
1
1,792 Views
Last Modified: 2012-06-21
I have an .NET 2.0 aspx web page that contains a combination of HTML Table with Lables and Literals embedded throughout the tables and I also have one GridView object on the page.   I want to know how to export that entire page to an MS-WORD document.

I have the page display in the Web form with a link button that says "Export to Word",  when they click on that link they are redirected to Web page formatted for the print output, which is basically the same page without the banners, menus, etc.

On the page I have the following fuction to export to Word.  I was try to use the same method I did for export a GridView object on a page to excel, which is a slightly different need that i have here.  Instead if rendering out just one control, I want to render the entire page.

Here is a snippit of code I am try to work with..which doesn't work....

-------------- Start Code Sample ---------------------------------------
        protected void ExportReport()
        {
            Response.Clear();

            Response.AddHeader("content-disposition", "attachment; filename=FastAirReport.doc");

            this.EnableViewState = false;
            Response.Charset = String.Empty;

            Response.ContentType = "application/vnd.ms-word";
            //Response.ContentType = "application/vnd.xls";

            System.IO.StringWriter stringWrite = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

            //GridView1.RenderControl(htmlWrite);
            form1.RenderControl(htmlWrite);
         
           
           

            Response.Write(stringWrite.ToString());

            Response.End();


        }
        public override void VerifyRenderingInServerForm(Control form1)
        {

            // Confirms that an HtmlForm control is rendered for the
            //specified ASP.NET server control at run time.

        }

---------------------- End Code Sample ---------------------------------------------

Any help would be appreciated.

Thanks
0
Comment
Question by:jholmes724
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
sandip132 earned 125 total points
ID: 18874150
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c#, datatable, aspx 4 50
What are MicroServices? 4 67
Difference between Leaflet and MapBox? 5 45
Manage big list of parameter list 8 21
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question