Solved

Export ASPX Web page to MS Word

Posted on 2007-04-08
1
1,783 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
1 Comment
 
LVL 12

Accepted Solution

by:
sandip132 earned 125 total points
Comment Utility
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now