首先利用 Nuget 获取 Aspose.Words.dll

public ActionResult AsposeWordsDemo()
{
string srcFileName = Server.MapPath("~/Data/a.doc");
Document doc = new Document(srcFileName); string basicDirVirtualPath = "/UploadFiles/"; string tempDir = Server.MapPath(basicDirVirtualPath); HtmlSaveOptions saveOptions = new HtmlSaveOptions();
// Specify folder where images will be saved.
saveOptions.ImagesFolder = tempDir;
// We want the images in the HTML to be referenced in the e-mail as attachments so add the cid prefix to the image file name.
// This replaces what would be the path to the image with the "cid" prefix.
saveOptions.ImagesFolderAlias = basicDirVirtualPath;
// Header footers don't normally export well in HTML format so remove them.
saveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.None; // saveOptions.ExportHeadersFooters = false; // 老版本用这个 // Save the document to stream in HTML format.
MemoryStream htmlStream = new MemoryStream();
doc.Save(htmlStream, saveOptions); // Read the HTML from the stream as plain text.
string htmlText = Encoding.UTF8.GetString(htmlStream.ToArray());
htmlStream.Close(); // Save the HTML into the temporary folder. string htmlFileNameWithoutPath = "Message.html"; Stream htmlFile = new FileStream(Path.Combine(tempDir, htmlFileNameWithoutPath), FileMode.Create);
StreamWriter htmlWriter = new StreamWriter(htmlFile);
htmlWriter.Write(htmlText);
htmlWriter.Close();
htmlFile.Close(); return Redirect(basicDirVirtualPath + htmlFileNameWithoutPath);
}

利用 Aspose.Words 组件,在不依赖与 Office 组件的情况下把 Word 文件转换成 HTML 代码。的更多相关文章

  1. java调用com组件将office文件转换成pdf

    在非常多企业级应用中都涉及到将office图片转换成pdf进行保存或者公布的场景,由于pdf格式的文档方便进行加密和权限控制(类似于百度文库).总结起来眼下将office文件转换 成pdf的方法主要有 ...

  2. 微信小程序中利用时间选择器和js无计算实现定时器(将字符串或秒数转换成倒计时)

    转载注明出处 改成了一个单独的js文件,并修改代码增加了通用性,点击这里查看 今天写小程序,有一个需求就是用户选择时间,然后我这边就要开始倒计时. 因为小程序的限制,所以直接选用时间选择器作为选择定时 ...

  3. win2008在组件服务中未找到office组件服务

    在win2003系统,cmd中输入 dcomcnfg ,组件服务里面找到office的组件服务,但win2008 R2 64位操作系统需要输入comexp.msc -32 tks:http://www ...

  4. nodejs将PDF文件转换成txt文本,并利用python处理转换后的文本文件

    目前公司Web服务端的开发是用Nodejs,所以开发功能的话首先使用Nodejs,这也是为什么不直接用python转换的原因. 由于node对文本的处理(提取所需信息)的能力不强,类似于npm上的包: ...

  5. 解决本地调用office组件成功,但是发布到IIS中出现的错误(检索COM类工厂中CLSID为{00024500-0000-0000-C000-000000000046}的组件时失败)

    在C#操作word或者Excel,我们可能会用到微软内置的COM组件,会出现很多问题. 如:在本地调试导出Excel没有问题,发布到IIS就有问题了,检测到的异常: 我们会发现在iis上运行的程序,没 ...

  6. 【转】 (C#)利用Aspose.Cells组件导入导出excel文件

    Aspose.Cells组件可以不依赖excel来导入导出excel文件: 导入: public static System.Data.DataTable ReadExcel(String strFi ...

  7. (C#)利用Aspose.Cells组件导入导出excel文件

    Aspose.Cells组件可以不依赖excel来导入导出excel文件: 导入: public static System.Data.DataTable ReadExcel(String strFi ...

  8. 3: 组件间的依赖管理 Managing Dependencies Between Components Using the Prism Library 5.0 for WPF(英汉对照版)

    Applications based on the Prism Library are composite applications that potentially consist of many ...

  9. Prism 文档 第三章 管理组件之间的依赖关系

                                                                          第3章:管理组件之间的依赖关系 基于Prism库的复合应用程 ...

随机推荐

  1. sublime text3 中设置默认浏览器,并且设置快捷键

    1.打开packageControl   对应快捷键  command + shift + p 2.输入install package 3.安装插件 SideBarEnhancements 4.安装了 ...

  2. FastAdmin 一键 CRUD 生成时方法不存在的问题分析

    FastAdmin 一键 CRUD 生成时方法不存在的问题分析 有群友反馈 使用 一键 CRUD 生成时不成功. 我试了以下命令 php think crud -t test -u 1 是成功的. 再 ...

  3. 软件开发中IT用语-日文和英文对照版

    開発工程 † 要件定義…Requirement Definition (Analyze) 外部設計…External Design 内部設計…Internal Design 開発…Coding テスト ...

  4. php跨域问题

    http://www.cnblogs.com/xiezn/p/5651093.html

  5. 【原创】官方文档-hive 启动命令

    [一起学Hive]之十六-Hive的WEB页面接口-HWI Apache Hive 管网 hive metrics hive常用命令整理 Hive学习之HiveServer2服务端配置与启动 启动hi ...

  6. linux 根据进程名查看其占用的端口

    linux 根据进程名查看其占用的端口 pasting $ netstat -nap | grep pid    //查看进程ID 所占的端口 netstat -lnp 查看端口所在的进程 will ...

  7. Java调用Groovy

    记录一下 http://docs.groovy-lang.org/latest/html/documentation/guide-integrating.html

  8. 腾讯云搭建php环境

    1.安装搭建论坛必要的软件 apache  php  mysql CentOS系统我们可以直接使用 yum install 的方式进行软件安装,腾讯云有提供软件安装源,是同步CentOS官方的安装源, ...

  9. 记一次oralce 11g r2 rac安装问题

    环境:虚拟机[root@rac1 ~]# lsb_release -aLSB Version:        :base-4.0-amd64:base-4.0-noarch:core-4.0-amd6 ...

  10. 为什么要初始化css样式

    因为浏览器的兼容问题,不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面显示差异. 初始化CSS样式主要是提高编码质量,如果不初始化整个页面做完很糟糕,重复的CSS样 ...