首先利用 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. bzoj 1119 [POI2009]SLO && bzoj 1697 [Usaco2007 Feb]Cow Sorting牛排序——思路(置换)

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1119 https://www.lydsy.com/JudgeOnline/problem.p ...

  2. NOIp2018 D2T3 defense——树上倍增

    题目:https://www.luogu.org/problemnew/show/P5024 考场上只会写n,m<=2000的暴力,还想了想A1和A2的情况,不过好像只得了A1的分.然后仔细一看 ...

  3. flyplane

    看到别人的一个简单制作打飞机的demo,先保存下来有空可以研究一下: <!DOCTYPE html> <html lang="en"> <head&g ...

  4. datasnap 上传/下载大文件(本Demo以图传片文件为例)

    好久没写技术文了 datasnap传大流. 完整代码,同时感谢叶兄传流的指点,(只公开十天) 附:下面代码,转载请注明出处 ::code 服务端: function TServerMethods1.D ...

  5. ALUA and SRM

    A couple important (ALUA and SRM) notes There’s some internal dialog today on our “VMware Champions” ...

  6. Java-Maven-Runoob:Maven 自动化部署

    ylbtech-Java-Maven-Runoob:Maven 自动化部署 1.返回顶部 1. Maven 自动化部署 项目开发过程中,部署的过程包含需如下步骤: 将所的项目代码提交到 SVN 或者代 ...

  7. PHP base64多图片上传

    // 多图片上传,base64 public function upload_multi() { $pic = $_POST['pic']; if (!$pic) { $this->json-& ...

  8. Linux的启动级别

    一.启动级别 1.查看linux 系统默认启动级别cat /etc/inittab id:3:initdefault: ##可以看出默认为三 2.查看某一服务在各个启动级别上是否启动[root@loc ...

  9. andriod/ios webview与js交互 html_demo

    <html> <head> <title>测试</title> </head> <body> <h3>Android ...

  10. AJAX如何获取从前台传递过来的数据然后在通过servle传递给后台

    1 用 request.getParameter接收值 <% String id1=request.getParameter("id"); out.print(id1); % ...