zoukankan      html  css  js  c++  java
  • asp.net将word转成HTML

     // 在此处放置用户代码以初始化页面
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            Type wordType = word.GetType();
            Microsoft.Office.Interop.Word.Documents docs = word.Documents; 
            // 打开文件
            Type docsType = docs.GetType();
            object fileName = "c:\\test\\a.docx";
            Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open",
                System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { fileName, true, true });
    
            // 转换格式,另存为
            Type docType = doc.GetType();
            object saveFileName = "c:\\test\\test.html";
            ///其它格式:
            ///wdFormatHTML
            ///wdFormatDocument
            ///wdFormatDOSText
            ///wdFormatDOSTextLineBreaks
            ///wdFormatEncodedText
            ///wdFormatRTF
            ///wdFormatTemplate
            ///wdFormatText
            ///wdFormatTextLineBreaks
            ///wdFormatUnicodeText
            docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
                null, doc, new object[] { saveFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });
    
            // 退出 Word
            wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,
                null, word, null);
  • 相关阅读:
    DAY9学习笔记
    DAY8课下作业
    DAY8学习笔记
    DAY7课下作业
    github clone 开源代码报Permission denied (publickey)
    grandle构建工程报:javax.net.ssl.SSLException
    centos安装redash
    centos安装nodejs
    CURL执行请求
    flume定制拦截器Interceptor
  • 原文地址:https://www.cnblogs.com/you000/p/2840073.html
Copyright © 2011-2022 走看看