您的位置:首页 > 编程语言 > C#

c# winform 中导入Excel 的问题 !

2014-08-11 10:16 543 查看
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" EXCEL的本地路径 ";Extended Properties=Excel 8.0;");
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
strExcel = string.Format("select '号码' from [这里填你的EXCEL左下角的工作表名$]");
myCommand = new OleDbDataAdapter(strExcel,conn);
DataTable dt=new DataTable();
myCommand .Fill(dt);//把所有结果填充到dt里面
string rusult="":
for(int i=0;i<dt.Row.count;i++)
{
rusult+=dt.Rows[i][0].ToString()+";";//遍历所有号码相加
}
textbox1.Text=rusult;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# winform