locked
Export html to word document. RRS feed

  • Question

  • User34108037 posted

    I am exporting the html content to word document. For this am using the following code to export the html content as word.

    Response.AppendHeader("Content-Type", "application/msword");
    Response.AppendHeader("Content-disposition", "attachment; filename=State details.doc");
    Response.Write(htmlcontent);

    While executing this, it will open the save as dialog box, while saving by default its saving as web page. Can we save it as a word document by default?

    Suresh.

    Wednesday, May 15, 2013 2:55 AM

Answers

  • User-1552614833 posted
    try this code...
    HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Charset = ""; 
    HttpContext.Current.Response.ContentType = "application/msword"; string strFileName = "DocumentName" + ".doc"; 
    HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName); 
    StringBuilder strHTMLContent = new StringBuilder(); strHTMLContent.Append(RadEditor1.Content); 
    HttpContext.Current.Response.Write(strHTMLContent); HttpContext.Current.Response.End(); 
    HttpContext.Current.Response.Flush();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 3, 2013 3:36 AM