Sathish

Sathish

  • NA
  • 7
  • 0

Erro in Export c#.net page to Document

Feb 3 2009 5:22 AM

HiI am using the following code in C#.net to export a page of contents to MS-Word document.

The file is exported well. But the tables and cell alignments are not coming in an aligned manner.

And also while opening the saved MSWord file it is producing an error that it is missing the stylesheet.css (it is the css file which I am using and is located in my Bin folder only).

So can I have any solution for both the queries?

string attachment = "attachment; filename="MyFile.doc";

Response.ClearContent();

Response.AddHeader("content-disposition", attachment);

Response.ContentType = "application/msword";

StringWriter sw = new StringWriter();

HtmlTextWriter htw = new HtmlTextWriter(sw);

this.RenderControl(htw);

Response.Write(sw.ToString());

Response.End();

 

Thanks in Advance

 


Answers (5)