troubleshooting Question

Transferring text from ASP.NET web form to a Word doc without HTML tags

Avatar of Vrik22
Vrik22 asked on
ASP.NETHTMLMicrosoft Word
1 Comment1 Solution84 ViewsLast Modified:
How to render only text into a word document using asp.net web forms ?

I am using the below code , but, it is rendering with <html> tags :

 
Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/vnd.word";
                Response.ContentEncoding = System.Text.Encoding.UTF7;
                Response.AddHeader("Content-Disposition", "attachment;filename=xyz.doc");
                Response.Charset = "";
                EnableViewState = false;
                System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
                oStringWriter.Write(txtDetails.Text);
                System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
                PanelControlId.RenderControl(oHtmlTextWriter);
                Response.Write(oStringWriter.ToString());
                HttpContext.Current.ApplicationInstance.CompleteRequest();

I want only text to be rendered in word and not with html tags. Please help .
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros