易截截图软件、单文件、免安装、纯绿色、仅160KB

C# word转换成HTML

C# word转换成HTML
添加com引用Microsoft word 11.0 Object Library
添加using System.Threading;using System.IO;
       //实例化一个Word
        Microsoft.Office.Interop.Word.ApplicationClass appclass = new Microsoft.Office.Interop.Word.ApplicationClass();
       Type wordtype = appclass.GetType();
       
        Microsoft.Office.Interop.Word.Documents docs = appclass.Documents;//获取Document
        Type docstype = docs.GetType();
        object filename = @"E:\AA.doc";//Word文件的路径
        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 = @"E:\bb.html";//生成HTML的路径和名子
        doctype.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { savefilename, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });//另存为Html格式
       
wordtype.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, appclass, null);//退出
       
        Thread.Sleep(3000);//为了使退出完全,这里阻塞3秒
        StreamReader objreader = new StreamReader(savefilename.ToString(), System.Text.Encoding.GetEncoding("GB2312")); 
       //以下内容是为了在Html中加入对本身Word文件的下载      
  


相关文档:

Javascript函数中调用C#方法

一、后台(.cs文件)方法:
       public string GetString(string name)
        {
            return ("Hello " + name);
        }
&n ......

C#代码与javaScript函数的相互调用

C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中 ......

C#中用XmlDocument对象获取XML文件中的节点值

 xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
  <book>
    <title lang="eng">Harry Potter</title>
    <price>29.99</price>
  </book>
  <book>
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号