简体   繁体   中英

Convert from aspx page content to MS Word Format

Response.ContentType = "application/word";
Response.AddHeader("content-disposition", "inline;filename=TestPage.doc");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());

Response.Write(sw);
Response.End();
Response.Flush();

I am trying to convert from aspx page to word format. When i launch the MS Word file generated it displays the dialog box Problems during load Missing file: c:\\Content\\Site.css

Looks like it is unable to load the css file. What is the solution. Please reply.

try adding the following headers:

Response.AddHeader("Content-Type: application/vnd.ms-word"); Response.AddHeader("Expires: 0");Response.AddHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM