gavriel ankri

gavriel ankri

  • NA
  • 39
  • 47.6k

Generating Ms Word document in ASP.NET and C#

Mar 3 2012 11:07 AM
Hello.
I am using this code to save asp.net page as an MS Word doc file. 

    protected void GenerateMsWordDoc(object sender, EventArgs e)
    {
        string strBody = "<html>" +
            "<body>" +
                "<table width=\"100%\" style=\"background-color:#cfcfcf; font-family: Arial, Helvetica, sans-serif\"><tr><td>????</td><td>2nd cell body data</td></tr></table>" +
                txtName.Text + "</b></div>" +
                "Ms Word document generated successfully." +
            "</body>" +
            "</html>";
        string fileName = "MsWordSample.doc";

        Response.ContentType = "application/msword";
        Response.Charset = "Windows-1255";
        Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName);
        Response.Write(strBody);
}

    }


I have 2 questions:
1.  If I write a text in hebrew, I cant see it correctly in the doc file. what should I do ?
2. How can I add image to the doc file ?

thank you !


Answers (1)