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 序列化错误
事发现场:
xml序列化的数据中存储的节点数据是
<Module>536870912</Module> (xml文件中)
对应的类属性是
public short Module { get; set; } (C#类中)
序列化的代码:
public static FMDSTimeSeriesDefinitio ......
★1. 使用QueryString变量
QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。下面是一个例子:
a.aspx的C#代码
private void B ......
我们都知道java、c#、vb等语言都有sleep暂停的函数,而JavaScript脚本没有类似的功能。
下面就是我的实现的方法:
<mce:script type="text/javascript"><!--
function test()
{
var s="javascript--暂停函数";
setTimeout(
function(){
eval(sleep(test)); //执行return之后的代码,也就是&ldq ......
sd.xml文件:
<?xml version="1.0" encoding="gb2312"?>
<!--这是一个xml文件-->
<xml1>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1) ......
第一种方法:
string str="server=.;uid=sa;pwd=111111;database=text_db";//连接字符串
SqlConnection SCON = null;//连接对象
&n ......