HTML output to winword RRS feed

  • Question

  • I am looking for a suitable solution for the following scenario.

    I have an input which is HTML data (ex. <b>this is a test</b><i>help</i>). I need to add this data to a cell in a table via word automation. Is there a way I can get only the rendered HTML of the above data and add it to the document ?


    Monday, July 11, 2011 3:14 AM


  • Hi Rupesh

    In order for HTML to appear "with formatting" in Word a conversion must take place.

    Either you have to program the conversion (you could, for example, create an XSLT (transform) for HTML to WordProcssingML or WordOpenXML; I believe there are also third-party tools you can license).

    Or you have to let Word's converter do the job. Word's converter only kicks in when you: 1) open a file, 2) insert a file or 3) paste HTML from the Clipboard. Your program could, for example, "stream" the html to a file then use the InsertFile method to put it into the target Range.

    Cindy Meister, VSTO/Word MVP
    Monday, July 11, 2011 10:20 AM
  • Hi Rupesh,


    Thanks for your post.


    It seems that you want to export ASP.NET page to Word. Are you trying to do the processing in server-side?

    If so, have a look at this sample code:

    Export ASP.NET page to Word, Excel or PDF


    And these two examples about generating Word document in server-side via Open XML


    I hope this helps.

    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 12, 2011 6:24 AM

All replies