导出到Word文档在C#

问题描述:

我正在寻找一个允许创建Word文档的.NET库。我需要将HTML内容导出到Word文档(97-2003格式,而不是docx)。

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).

我知道有Microsoft Office Automation库和Office互操作,但据我所知,他们要求您实际安装办公室,并通过打开单词进行转换。但是我不想要安装办公室以使转换工作的要求。

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.

编辑:如果可能,转换为RTF甚至可以工作。 >

Converting to RTF may even work, if possible.

如果我以某种方式将CSS转换成嵌入HTML?

是的。我使用内部样式表,如我所提到的。

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

文件示例:

<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>