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
BiztalkerPosted Jun 9, 2009, 8:39 AM
SathishPosted Feb 4, 2009, 5:23 AM
Hi
I have tried the code...but no difference...
There error while opening the exported document is
missing file:Temporary internet files\Content.IE5\...\Stylesheet.css.
So can say any way to apply the stylesheet while exporting.
Thanks in advance.
SathishPosted Feb 4, 2009, 1:33 AM
And also tell What does that url meant in the code?
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);Thanks in advance
SathishPosted Feb 4, 2009, 1:28 AM
HttpWebRequest
HttpWebResponse
Jan MontanoPosted Feb 3, 2009, 9:04 PM
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
Stream stream = webResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(stream, Encoding.UTF8))
StringBuilder stringBuilder = new StringBuilder(streamReader.ReadToEnd().Trim());
streamReader.Close();
webResponse.Close();
webRequest.Abort();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=test.doc");
Response.ContentType = "application/vnd.ms-word";
Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
Response.Write(sb.ToString());
//Response.End();
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();