C#中word文档转html
2024-09-05 08:53:37
var path = Request.Url.Host + ":" + Request.Url.Port + list[i].AnnexPath;
//html保存路径
string savePath = Server.MapPath("~/Uploads/RemoteDatum/");
if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
//将word转成html
if (!System.IO.File.Exists(savePath + list[i].AnnexId + ".html"))
{
Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
Type wordType = word.GetType();
Documents docs = word.Documents;
Type docsType = docs.GetType();
Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { (object)path, true, true });
Type docType = doc.GetType();
string strSaveFileName = savePath + list[i].AnnexId + ".html";
object saveFileName = (object)strSaveFileName;
docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML });
docType.InvokeMember("Close", System.Reflection.BindingFlags.InvokeMethod, null, doc, null);
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);
}
var htmlPath = "/Uploads/RemoteDatum/" + list[i].AnnexId + ".html";
最新文章
- [Exchange]使用EWS托管API2.0同步邮箱
- iOS--获取输入字符的第一个字母(汉字则获取拼音的第一个字母)
- 一个在 Java VM 上使用可观测的序列来组成异步的、基于事件的程序的库 RxJava,相当好
- k近邻法的C++实现:kd树
- struts2框架开发的第一个应用
- 关于XMLEncoder和XMLDecoder
- 关于5303狄惟佳同学的myod程序设计的补充实现
- 算法题丨Next Permutation
- ANN实现
- win10下使用wget
- Oracle内置函数SQLCODE和SQLERRM的使用
- webpack2.0学习
- 程序员必须知道的HTML常用代码有哪些?
- jquery的extend函数
- js中forEach,for in,for of的区别
- uboot 下更改NAND的分区 fdisk
- 20155303 2016-2017-2 《Java程序设计》第八周学习总结
- Tomcat与Gzip与缓存
- 怎么上传自己的代码/项目到自己的github仓库上
- Centos上Apache重启,mysql重启,nginx重启方法
热门文章
- redis的主从复制原理
- 20175227张雪莹 2018-2019-2 《Java程序设计》第十周学习总结
- httpClinent工具类
- 服务器开启FTP功能
- leetcode 日常清单
- html提交表单,php在后台获取表单内容的方法_例1
- Elasticsearch安装配置问题
- Oracle 本地创建多个实例并创建多个监听(只能在服务端弄,不可在客户端)
- 数组中存放model去重
- document.documentElement.clientHeight 和 document.body.clientHeight