将 Word 文档文本转换为 HTML 的库 [英] Library to convert Word document text to HTML

查看:25
本文介绍了将 Word 文档文本转换为 HTML 的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有.Net 开源库将word 文档转换为HTML 以显示在网页内.

Is there a .Net open source library to convert the word dococument to HTML to display inside the webpage.

我知道几种将 word 文档转换为 html 文件的工具,但我的要求是在 ASP.Net 应用程序中将文档(从文件中或只是提取的文本)即时转换为 HTML.

I know several tools to convert word docs to html files, but my requirements is to convert the doc(either from the file or just extracted text) to HTML on the fly in the ASP.Net application.

我发现了 converting-a-word-document-into-usable-html-in-php PHP 库做同样的事情,.net 中有没有类似的工具?

I found the converting-a-word-document-into-usable-html-in-php PHP library do the same thing, is there any similar tool in .net?

推荐答案

您只想将 *.doc 文件转换为 HTML?将其另存为 HTML 文件是一种选择吗?

You just want to convert a *.doc file to HTML? Is saving it as a a HTML file an option?

有标准的 .SaveAs 方法,可以选择另存为 HTML:

There is the standard .SaveAs method which has the option to save as HTML:

wdFormatHTML 使用 HTML 标记保存所有文本和格式,以便可以在 Web 浏览器中查看生成的文档.

wdFormatHTML Saves all text and formatting with HTML tags so that the resulting document can be viewed in a Web browser.

来自:MSDN SaveAs 方法

有关如何使用该方法将 .doc 转换为不同格式的示例教程,您可以在此处找到:如何使用 C# 将 DOC 转换为其他格式.

An example tutorial on how to use the method to convert .doc to a different format you can find here: How to convert DOC into other formats using C#.

如果您有 *.docx 文件而不是 *.doc 文件,那就更容易了,因为您可以使用 OpenXML API,如 MSDN 上的说明:使用 Open XML 格式 API 操作 Word 2007 文件(第 1 部分,共 3 部分).如果您获得 Word 文件的 XML,您当然可以将其输出为您想要的任何格式 (HTML).

If you have *.docx files instead of *.doc files it is even easier because you get to use the OpenXML API like explained on MSDN here: Manipulating Word 2007 Files with the Open XML Format API (Part 1 of 3). And if you get the XML of the Word file you can of course output it to any format (HTML) you want.

这篇关于将 Word 文档文本转换为 HTML 的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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