HI,
I am creating an ms-word document from server side using a template. Here i add the reference
Microsoft word 11.0 object library.
Here i use a template where i set some bookmarks. Now i need to populate those bookmarks.
Everything goes fine but i am stuck in one place where i need to write html text except
normal text.
My code sample is as follows:
object TemplatefileName = Server.MapPath("Template") + "\\High.doc";
object novalue = System.Reflection.Missing.Value;
Word.Table oTable;
objWordDoc.Bookmarks.get_Item(ref prj_name).Range.Text = dProject.Rows[0]["txtProject"].ToString();
Here its a complex report. Now in a bookmark i need to write html code which comes from FCKEditor.
Please guide me how i can insert the html formatted text into my word document.
THANKS IN ADVANCE.
Word COM Interop Office .NETweb 2.0MS WordWord document printingasp.net export to wordSmart Quotes Word HTML Conversion
Did anyone get this to work? Can you export HTML to an existing word document?
I have an aspx page that has a grdiview and a plain HTML table with data. I'm trying to export either/or to an existing word document at a certain bookmark. The exporting works, but my word document shows the actual HTML tags, not the table that I want.
If anyone knows how to do this, a code sample would really be appreciated. Thanks.
I want to genarate word document programatically in C#.I need to get the data from database which i entered using rich text editor,When i am inserting data into word file.The html format does not suported.Please help me any one.
You may try our .Net component for directly converting HTML to Word (RTF, Doc, Text). It names HTML-to-RTF Pro DLL .Net, completely written in C# and absolutely standalone.
This .Net assembly doesn't require Microsoft Office or Internet Explorer. We don't use any third-party software.
If anyone will have questions how to deploy it in ASP.Net or other, please let me know.
Best wishes,
Max [;)]
asp.net 2.0htmlASP.net 1.1Word COM Interop Office .NETHTMlLHTML to PDF ConverterXML control in ASP.NETWord document printingrtf to pdf converterxhtmlwordhtml wysiwygrich texthtml parse code tag style table cellHTML Decode
This is how you make a word document from an aspx page.
Add this Sub to your code behind page. I didn't create this code, but I can't remember where I got it from. I did tweak it a little bit though. This also gives you a header and a footer, but one thing to note. The header and Footer will appear twice
in your word document. There is no way to get around it that I know of and I searched for a solution for weeks. The way I get around this issue is that I ask my users to print from a macro that I created which removes the duplicate header and footer.
ONce you add this code to your code behind page, make sure you add 15 labels to your aspx page. Name them Label1 through Label15. When you go to view your page, a download prompt comes up asking if you would like to download the word document. The way
I display tables is through LINQ. I create an html table though link and I display it in a label. When the label gets downloaded as a word document, it comes out as a regular table.
Dim GetCodes = From codes In db.View_Infos Where codes.Number = ShowID _
Select New With {codes.DCode, codes.Name}
Dim x As Integer = 0
For Each code In GetCodes
x = x + 1
lblShowCode.Text += "<tr><td>" & x & ") " & "</td><td>" & code.DCode & "</td>" & "<td>" & code.Name & "</td></tr>"
Next
lblShowCode.Text = "<table border=""1"" frame=""box"" cellpadding=""5"" cellspacing=""0"">" & "<tr><td>" & "" & "</td><td><b>" & "Code" & "</td><td></b><b>" & "Problems" & "</td></tr></b>" & lblShowCode.Text & "</table>"
shawpnendu
Contributor
4275 Points
749 Posts
Insert html formatted text into word document asp.net(C#)
Feb 24, 2008 08:17 AM|LINK
HI,
I am creating an ms-word document from server side using a template. Here i add the reference
Microsoft word 11.0 object library.
Here i use a template where i set some bookmarks. Now i need to populate those bookmarks.
Everything goes fine but i am stuck in one place where i need to write html text except
normal text.
My code sample is as follows:
object TemplatefileName = Server.MapPath("Template") + "\\High.doc";
object novalue = System.Reflection.Missing.Value;
Word.Table oTable;
Word.ApplicationClass objWord = new Word.ApplicationClass();
Word.Document objWordDoc = objWord.Documents.Add(ref TemplatefileName, ref novalue, ref novalue, ref novalue);
objWordDoc.Activate();
objWordDoc.Application.Visible = true;
objWordDoc.Bookmarks.get_Item(ref prj_name).Range.Text = dProject.Rows[0]["txtProject"].ToString();
Here its a complex report. Now in a bookmark i need to write html code which comes from FCKEditor.
Please guide me how i can insert the html formatted text into my word document.
THANKS IN ADVANCE.
Word COM Interop Office .NET web 2.0 MS Word Word document printing asp.net export to word Smart Quotes Word HTML Conversion
MCTS
http://shawpnendu.blogspot.com
munishwalia
Member
12 Points
61 Posts
Re: Insert html formatted text into word document asp.net(C#)
Apr 25, 2008 10:42 AM|LINK
Hi,
Try this :-
string Content = Word.Content.Text;
Content = Content.Replace("\r\a","<br/>");
Its just to give you an idea.
Good Luck!
MikeB55
Member
58 Points
78 Posts
Re: Insert html formatted text into word document asp.net(C#)
Jun 25, 2008 01:55 PM|LINK
Did anyone get this to work? Can you export HTML to an existing word document?
I have an aspx page that has a grdiview and a plain HTML table with data. I'm trying to export either/or to an existing word document at a certain bookmark. The exporting works, but my word document shows the actual HTML tags, not the table that I want. If anyone knows how to do this, a code sample would really be appreciated. Thanks.
<div>
<table cellspacing="0" rules="all" border="1" id="ctl00_ContentPlaceHolder1_GridView1" style="border-collapse:collapse;">
<tr>
<th scope="col">Code</th><th scope="col">Name</th>
</tr><tr>
<td>1 </td><td>Book1</td>
</tr><tr>
<td>2 </td><td>Book2</td>
</tr><tr>
<td>3</td><td>Book3</td>
</tr>
</table>
</div>
shiva994u
Member
8 Points
36 Posts
Re: Insert html formatted text into word document asp.net(C#)
Aug 07, 2008 02:23 PM|LINK
I want to genarate word document programatically in C#.I need to get the data from database which i entered using rich text editor,When i am inserting data into word file.The html format does not suported.Please help me any one.
Thanks in advance,
Shiva reddy.P
SautinSoft
Member
194 Points
103 Posts
Re: Insert html formatted text into word document asp.net(C#)
Jan 21, 2009 02:53 PM|LINK
Hi Shiva994u,
You may try our .Net component for directly converting HTML to Word (RTF, Doc, Text). It names HTML-to-RTF Pro DLL .Net, completely written in C# and absolutely standalone.
This .Net assembly doesn't require Microsoft Office or Internet Explorer. We don't use any third-party software.
This is a page of component:
http://www.sautinsoft.com/products/html-to-rtf/index.php
Download link:
http://www.sautinsoft.com/components/htmltortf_pro_net.zip
If anyone will have questions how to deploy it in ASP.Net or other, please let me know.
Best wishes,
Max [;)]
asp.net 2.0 html ASP.net 1.1 Word COM Interop Office .NET HTMlL HTML to PDF Converter XML control in ASP.NET Word document printing rtf to pdf converter xhtml word html wysiwyg rich text html parse code tag style table cell HTML Decode
nnarvekar
Member
2 Points
1 Post
Re: Insert html formatted text into word document asp.net(C#)
Feb 07, 2009 01:15 PM|LINK
Did anyone find an answer to this one? I am creating the word document through code and need to insert some rich text into the document.
Appreciate any help, thanks
adamcasey
Member
11 Points
30 Posts
Re: Insert html formatted text into word document asp.net(C#)
May 15, 2009 11:25 AM|LINK
Anyone got solution to this? I'm trying to insert a table into a word document, however <table> tags appear...
MikeB55
Member
58 Points
78 Posts
Re: Insert html formatted text into word document asp.net(C#)
May 15, 2009 12:18 PM|LINK
This is how you make a word document from an aspx page.
Add this Sub to your code behind page. I didn't create this code, but I can't remember where I got it from. I did tweak it a little bit though. This also gives you a header and a footer, but one thing to note. The header and Footer will appear twice in your word document. There is no way to get around it that I know of and I searched for a solution for weeks. The way I get around this issue is that I ask my users to print from a macro that I created which removes the duplicate header and footer.
ONce you add this code to your code behind page, make sure you add 15 labels to your aspx page. Name them Label1 through Label15. When you go to view your page, a download prompt comes up asking if you would like to download the word document. The way I display tables is through LINQ. I create an html table though link and I display it in a label. When the label gets downloaded as a word document, it comes out as a regular table.
LINQ that shows how to make an HTML table.
----------------------------------------------------------------------------------------------------------------
Dim GetCodes = From codes In db.View_Infos Where codes.Number = ShowID _ Select New With {codes.DCode, codes.Name} Dim x As Integer = 0 For Each code In GetCodes x = x + 1 lblShowCode.Text += "<tr><td>" & x & ") " & "</td><td>" & code.DCode & "</td>" & "<td>" & code.Name & "</td></tr>" Next lblShowCode.Text = "<table border=""1"" frame=""box"" cellpadding=""5"" cellspacing=""0"">" & "<tr><td>" & "" & "</td><td><b>" & "Code" & "</td><td></b><b>" & "Problems" & "</td></tr></b>" & lblShowCode.Text & "</table>"----------------------------------------------------------------------------------------------------------------
Add this to your code behind page:--------------------------------------------------------------------------------------------------------------------
Add this to your aspx page:
-----------------------------------------------------------------------------------------------------------------------------------
Hope this helps. Let me know if you have any questions.
kiran_tsp
Member
18 Points
8 Posts
Re: Insert html formatted text into word document asp.net(C#)
Jun 22, 2009 12:04 PM|LINK
Hi,
You could store the html text in a "temporary" .html file say "temp.html" and then do the following..
Bookmark.InsertFile("temp.html");
After insertion, delete the temp file, if required. Hope this helps..
~kiran
jahedur
Member
3 Points
8 Posts
Re: Insert html formatted text into word document asp.net(C#)
Sep 30, 2009 10:07 AM|LINK
Thanks a lot...
I have got it working...
I just had to do a little code to wrap the text to make it HTML formatted text.