标签:datagridview style class blog code ext
if (openFileDialog1.ShowDialog() == DialogResult.OK) { Filename = openFileDialog1.FileName; string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Filename + ";Extended Properties=‘Excel 8.0;IMEX=1‘"; System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(strCon); string strCom = "SELECT * FROM [Sheet1$]"; Conn.Open(); System.Data.OleDb.OleDbDataAdapter myCommand = new System.Data.OleDb.OleDbDataAdapter(strCom, Conn); DataSet ds = new DataSet(); myCommand.Fill(ds, "[Sheet1$]"); temp.DataSource = ds.Tables[0]; Conn.Close(); }
C#【数据库】 Excel打开到DataGridView,布布扣,bubuko.com
标签:datagridview style class blog code ext
原文地址:http://www.cnblogs.com/flay/p/3785616.html