Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Contributor
2401 Points
531 Posts
Jul 08, 2011 12:49 PM|LINK
Dear All,
I am working on asp.net 3.5.
In my application, i am creating a word file using the below code.
object nullobj = System.Reflection.Missing.Value; object oMissing = System.Reflection.Missing.Value; object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ //Start Word and create a new document. Microsoft.Office.Interop.Word._Application oWord; Microsoft.Office.Interop.Word._Document oDoc; oWord = new Microsoft.Office.Interop.Word.Application(); oWord.Visible = true; oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); //Insert a paragraph at the beginning of the document. Microsoft.Office.Interop.Word.Paragraph oPara1; oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing); foreach (RepeaterItem ri in Repeater1.Items) { Label lbl = (Label)ri.FindControl("ltrlForm"); Literal ltr = (Literal)ri.FindControl("ltrlComment"); string tst = StripHtml(ltr.Text, false); string tst1 = Server.HtmlEncode(ltr.Text.ToString()); string newstr = ltr.Text.Replace("<BR>", "~"); string[] htmlstr = newstr.Split('~'); oPara1.Range.Text = lbl.Text; oPara1.Range.Font.Bold = 1; oPara1.Range.Font.Size = 14; oPara1.Range.Font.Name = "Cambria"; oPara1.Format.SpaceAfter = 6; //24 pt spacing after paragraph. oPara1.Range.InsertParagraphAfter(); Microsoft.Office.Interop.Word.Paragraph oPara2; object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; oPara2 = oDoc.Content.Paragraphs.Add(ref oRng); oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; oPara2.Range.Font.Name = "Verdana"; if (htmlstr.Length > 1) { for (int i = 0; i < htmlstr.Length; i++) { oPara2.Range.Text = StripHtml(htmlstr[i].ToString(), false); oPara2.Range.InsertParagraphAfter(); oPara2.Range.Font.Name = "Verdana"; oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; } } else { oPara2.Range.Text = tst.ToString(); oPara2.Range.InsertParagraphAfter(); oPara2.Range.Font.Name = "Verdana"; oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; } oPara2.Range.Font.Bold = 0; oPara2.Range.Font.Size = 10; oPara2.Format.SpaceAfter = 30; }
When I run the application from the VS, its working fine and word file is generating.
When I host the site in my Local IIS, its not working. I am getting error message.
Can anyone help me.
Thanks in advance.
prabinyovan
Contributor
2401 Points
531 Posts
Word File Creation Error
Jul 08, 2011 12:49 PM|LINK
Dear All,
I am working on asp.net 3.5.
In my application, i am creating a word file using the below code.
object nullobj = System.Reflection.Missing.Value; object oMissing = System.Reflection.Missing.Value; object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ //Start Word and create a new document. Microsoft.Office.Interop.Word._Application oWord; Microsoft.Office.Interop.Word._Document oDoc; oWord = new Microsoft.Office.Interop.Word.Application(); oWord.Visible = true; oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); //Insert a paragraph at the beginning of the document. Microsoft.Office.Interop.Word.Paragraph oPara1; oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing); foreach (RepeaterItem ri in Repeater1.Items) { Label lbl = (Label)ri.FindControl("ltrlForm"); Literal ltr = (Literal)ri.FindControl("ltrlComment"); string tst = StripHtml(ltr.Text, false); string tst1 = Server.HtmlEncode(ltr.Text.ToString()); string newstr = ltr.Text.Replace("<BR>", "~"); string[] htmlstr = newstr.Split('~'); oPara1.Range.Text = lbl.Text; oPara1.Range.Font.Bold = 1; oPara1.Range.Font.Size = 14; oPara1.Range.Font.Name = "Cambria"; oPara1.Format.SpaceAfter = 6; //24 pt spacing after paragraph. oPara1.Range.InsertParagraphAfter(); Microsoft.Office.Interop.Word.Paragraph oPara2; object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; oPara2 = oDoc.Content.Paragraphs.Add(ref oRng); oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; oPara2.Range.Font.Name = "Verdana"; if (htmlstr.Length > 1) { for (int i = 0; i < htmlstr.Length; i++) { oPara2.Range.Text = StripHtml(htmlstr[i].ToString(), false); oPara2.Range.InsertParagraphAfter(); oPara2.Range.Font.Name = "Verdana"; oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; } } else { oPara2.Range.Text = tst.ToString(); oPara2.Range.InsertParagraphAfter(); oPara2.Range.Font.Name = "Verdana"; oPara2.Range.Font.Size = 10; oPara2.Range.Font.Bold = 0; } oPara2.Range.Font.Bold = 0; oPara2.Range.Font.Size = 10; oPara2.Format.SpaceAfter = 30; }When I run the application from the VS, its working fine and word file is generating.
When I host the site in my Local IIS, its not working. I am getting error message.
The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
Can anyone help me.
Thanks in advance.
Nothing is really over,until the moment u stop trying for it....