Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export to Word Document in C#

Tags:

c#

export

ms-word

I'm looking for a .NET library that will allow creation of a Word document. I need to export HTML based content to a Word doc (97-2003 format, not docx).

I know that there are the Microsoft Office Automation libraries and Office interop, but as far as I can tell, they require that you have office actually installed and they do the conversion by opening word itself. But I don't want to have the requirement of having office installed for the conversion to work.

Edit: Converting to RTF may even work, if possible.

like image 692
Adam Haile Avatar asked Dec 18 '22 10:12

Adam Haile


1 Answers

Would it work if I somehow converted the CSS to be embedded in the HTML??

Yes. I use an internal style sheet, as I mentioned.

Document Example:

<html>
<head>
<STYLE type="text/css">
    h1 {text-align:center; font-size:12.0pt; font-family:Arial; font-weight:bold;}

    p {margin:0in; margin-bottom:0pt; font-size: 10.0pt;font-family: Arial;}
    p.Address {text-align:center;font-family:Times; margin-bottom: 10px;}
</style></head>
<body>
<p class="Address">The Street</p>
<h1>Head</h1>
like image 75
Fionnuala Avatar answered Dec 24 '22 00:12

Fionnuala