首先利用 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. CentOS虚拟机中安装VMWare Tools

    1.单击VMWare的[虚拟机]菜单,选择[安装VMWare Tools]命令 2.接着CentOS系统会自动挂载VMWare  Tools,并自动打开,如果没有打开可以自己去图形界面打开VMWare ...

  2. springboot 自定义属性

    前言 spring boot使用application.properties默认了很多配置.但需要自己添加一些配置的时候,我们如何添加呢 1.添加自定义属性 在src/main/resources/a ...

  3. Oracle Stream配置详细步骤

    1 引言 Oracle Stream功能是为提高数据库的高可用性而设计的,在Oracle 9i及之前的版本这个功能被称为Advance Replication.Oracle Stream利用高级队列技 ...

  4. (转)setTextColor()的参数设置方式

    setTextColor()的参数设置方式 分类: Android界面研究2011-12-09 23:27 11160人阅读 评论(2) 收藏 举报 查了下资料发现setTextColor()的参数应 ...

  5. 通过ssh连接git操作

    项目又一次从svn切换到git,而且要求使用安全协议ssh连接git.不管是个人还是组织,git上只负责导入公钥,而不会帮你生成.这里先说下怎么生成这个ssh的私钥和公钥. 首先你得找到有ssh命令的 ...

  6. leetcode 21.Merge Two Sorted Lists ,java

    题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splici ...

  7. plsql无法连接64位oracle数据库的解决方法

    今儿个重装了个系统,win8 64位.接着装了个64位的oracle11g,oracle11g下载页面:http://www.oracle.com/technetwork/database/enter ...

  8. composer 详解

    composer 详解 http://blog.csdn.net/panpan639944806/article/details/16808261 https://www.phpcomposer.co ...

  9. Erlang基础 -- 介绍 -- 历史及Erlang并发

    前言 最近在总结一些Erlang编程语言的基础知识,拟系统的介绍Erlang编程语言,从基础到进阶,然后再做Erlang编程语言有意思的库的分析. 其实,还是希望越来越多的人关注Erlang,使用Er ...

  10. 【转】wireshark抓包工具详细说明及操作使用

      wireshark是非常流行的网络封包分析软件,功能十分强大.可以截取各种网络封包,显示网络封包的详细信息.使用wireshark的人必须了解网络协议,否则就看不懂wireshark了. 为了安全 ...