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文件的下载
 
相关文档:
本文来自CSDN博客:http://blog.csdn.net/jinjazz/archive/2008/07/14/2650506.aspx
将oledb读取的excel数据快速插入的sqlserver中,很多人通过循环来拼接sql,这样做不但容易出错而且效率低下,最好的办法是使用bcp,也就是System.Data.SqlClient.SqlBulkCopy 类来实现。不但速度快,而且代码简单,下面测试代码导入一个6 ......
★1. 使用QueryString变量
QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。下面是一个例子:
a.aspx的C#代码
private void B ......
代码如下:
<%@ Page Language="C#" Debug="true" %>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<Script Language="C#" runat="server">
int Record_Per_Page;//定义每页显示记录数
int nPageCount;//定义总页数
int nRecCount;//定义总 ......
第一种方法:
string str="server=.;uid=sa;pwd=111111;database=text_db";//连接字符串
SqlConnection SCON = null;//连接对象
&n ......