Solved

Export ASPX Web page to MS Word

Posted on 2007-04-08
1
1,793 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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