您的位置:程序门 -> .net技术 -> c#



(100 分求)c# 把 excel 和 文本文档 中数据 导入到 datagridview 不是把 excel 或 文本文档作为数据源 而是把其中数据导入到 datagridvie


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


(100 分求)c# 把 excel 和 文本文档 中数据 导入到 datagridview 不是把 excel 或 文本文档作为数据源 而是把其中数据导入到 datagridvie[已结贴,结贴人:dzhpeng]
发表于:2007-01-08 15:15:20 楼主
比如   我   datagridview   中原来有   4   行纪录   现在我要把   文本文档   或   excel   中数据导入到4   行数据的后面   也就是给datagridview   添加几行   添加行的数据是   excel   或文本文档中的数据

希望大家帮忙给与回复
发表于:2007-01-08 16:44:331楼 得分:5
reading   and   writing   excel   using   oledb
http://www.codeproject.com/office/excel_using_oledb.asp
发表于:2007-01-08 17:11:292楼 得分:5
xmldocument   doc   =new   xmldocument();
doc.load( "your   path ");
xmlnode   s=doc.createelement();
 
..........
网上有资料,多搜索一下
发表于:2007-01-08 17:14:143楼 得分:40
system.data.oledb.oledbconnection   cn   =   new   system.data.oledb.oledbconnection();
cn.connectionstring   =   @ "provider=microsoft.jet.oledb.4.0;data   source=c:\book1.xls;extended   properties=excel   8.0; ";
cn.open();
string   sql   =   "select   *   from   [sheet1$a2:f10] ";
system.data.oledb.oledbcommand   cmd   =   new   system.data.oledb.oledbcommand(sql,   cn);
system.data.oledb.oledbdatareader   dr   =   cmd.EXECutereader();
while   (dr.read())
{
    messagebox.show(dr[0].tostring());
}

cn.close();

用上面的语句先连接再添加
发表于:2007-01-09 12:43:384楼 得分:0
我试一下   回来就结贴
发表于:2007-01-09 12:45:275楼 得分:0
感谢大家帮忙


快速检索

最新资讯
热门点击