在 C# 中导出到 Word 文档 [英] Export to Word Document in C#

查看:34
本文介绍了在 C# 中导出到 Word 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找允许创建 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 自动化库和 Office 互操作,但据我所知,它们要求您实际安装 office,并且它们通过打开 word 本身来进行转换.但是我不想有安装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>

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆