zoukankan      html  css  js  c++  java
  • C#中word文档转html

                            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";
  • 相关阅读:
    cocos2dx的发展的例子2048(加入动画版)
    Hibernate操作Clob数据类型
    json级联城市
    Ubuntu Linux 永山(mount)分
    C++出现计算机术语5
    Cocos2d-x 3.0 红孩儿私人义务教育
    大页(huge pages) 三大系列 ---计算大页配置参数
    EJB_消息驱动发展bean
    HDU5086Revenge of Segment Tree(数论)
    第五章_JSTL
  • 原文地址:https://www.cnblogs.com/llljpf/p/7541645.html
Copyright © 2011-2022 走看看