if (openFileDialog1.ShowDialog() == DialogResult.OK) { String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source="+openFileDialog1.FileName+";"+ "Extended Properties='Excel 8.0;HDR=Yes;IMEX=2'"; //实例化一个Oledbconnection类(实现了IDisposable,要using) using (OleDbConnection ole_conn = new OleDbConnection(sConnectionString)) { ole_conn.Open(); using (OleDbCommand ole_cmd = ole_conn.CreateCommand()) { //类似SQL的查询语句这个[Sheet1$对应Excel文件中的一个工作表] ole_cmd.CommandText = "select * from [Sheet1$]"; OleDbDataAdapter adapter = new OleDbDataAdapter(ole_cmd); DataSet ds = new DataSet(); adapter.Fill(ds, "Sheet1"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MessageBox.Show(ds.Tables[0].Rows[i]["商家名称"].ToString()); } } } } //csharp/6136