易截截图软件、单文件、免安装、纯绿色、仅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#+ASP.NET】ASP.NET跨页面传值技巧总结(转)

★1.  使用QueryString变量
   QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。下面是一个例子:
a.aspx的C#代码
private void B ......

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#学习及与delphi的比较(一)

刚开始很不习惯c#的风格,哎,先入为主啊,delphi习惯了,{}代替begin/end太扎眼。
属性方法的宣告和代码在一起,没有像delphi分interface/implementation,感觉太乱,都不知道一个class到底有几个方法。
每个属性和方法前面都要单独写private/protected/public,老天,c#是delphi之父设计的揶,怎么不学delphi写一个就行 ......

c# txt文本转xml文本

       现在很多软件都是以xml文件作为数据源,而很多数据工具如pb等却只能另存为txt、excel等格式,为此需要一工具能将txt文本转换成xml文件。google了一下,没找到合适的,冲动之下用C#写了一个txt文本转xml格式文本的小程序,代码如下。
       新建一个w ......

C#一次连接数据库执行多条sql语句(三种方法)

第一种方法:
            string str="server=.;uid=sa;pwd=111111;database=text_db";//连接字符串
            SqlConnection SCON = null;//连接对象
       &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号