从XLS到DATAGRIW的最短代码 string source = "c://1.xls";//execel文件的完整路径 string sqlconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + source + ";Extended Properties=Excel 8.0"; string sql = "SELECT * FROM [Sheet1$]"; OleDbCommand oldcom = new OleDbCommand(sql, new OleDbConnection(sqlconn)); OleDbDataAdapter oleda = new OleDbDataAdapter(oldcom); DataSet ds = new DataSet(); oleda.Fill(ds, "[Sheet1$]"); this.GridView1.DataSource = ds.Tables[0];this.GridView1.DataBind();