易截截图软件、单文件、免安装、纯绿色、仅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文件的下载      
  


相关文档:

一个C# xml 序列化错误

一个C# xml 序列化错误
 
事发现场:
xml序列化的数据中存储的节点数据是
   <Module>536870912</Module>  (xml文件中)
对应的类属性是
    public short Module { get; set; }  (C#类中)
 
序列化的代码:
public static FMDSTimeSeriesDefinitio ......

Javascript函数中调用C#方法

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

C# xml解析

已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price& ......

c# txt文本转xml文本

       现在很多软件都是以xml文件作为数据源,而很多数据工具如pb等却只能另存为txt、excel等格式,为此需要一工具能将txt文本转换成xml文件。google了一下,没找到合适的,冲动之下用C#写了一个txt文本转xml格式文本的小程序,代码如下。
       新建一个w ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号