I am trying to export the contents of an HTML page in Word.
My HTML display page:
- What is your favorite color?
NA
- A list of the top three schools?
one national two devs three ps
And a button for the click event. A button press event will open the word MS and paste the contents of the page into the word.
The text page contains the html design page table property. This only happens in Word 2003. But in 2007, the word document contains text with an out table attribute. How to remove table property in word 2003.
I can not add snapshots. I will also make it clear to you.
I am designing an aspx webpage. I export the contents of the web page using the following code.
protected void Button1_Click(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF7;
System.Text.StringBuilder SB = new System.Text.StringBuilder();
System.IO.StringWriter SW = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlTW = new System.Web.UI.HtmlTextWriter(SW);
tbl.RenderControl(htmlTW);
string strBody = "<html>" +
"<body>" + "<div><b>" + htmlTW.InnerWriter.ToString() + "</b></div>" +
"</body>" +
"</html>";
Response.AppendHeader("Content-Type", "application/msword");
Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName);
Response.ContentEncoding = System.Text.Encoding.UTF7;
string fileName1 = "C://Temp/Excel" + DateTime.Now.Millisecond.ToString();
BinaryWriter writer = new BinaryWriter(File.Open(fileName1, FileMode.Create));
writer.Write(strBody);
writer.Close();
FileStream fs = new FileStream(fileName1, FileMode.Open, FileAccess.Read);
byte[] renderedBytes;
renderedBytes = new byte[fs.Length];
fs.Read(renderedBytes, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
FileInfo TheFile = new FileInfo(fileName1);
if (TheFile.Exists)
{
File.Delete(fileName1);
}
Response.BinaryWrite(renderedBytes);
Response.Flush();
Response.End();
}
saran