导出到Word文档在C#

导出到Word文档在C#

本文介绍了导出到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>

这篇关于导出到Word文档在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 07:06