日期:2014-05-18 浏览次数:20780 次
OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Ofd_BOM.FileName + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"); olecon.Open(); OleDbDataAdapter oledbda = new OleDbDataAdapter("Select * from [Sheet1$]", olecon); DataSet myds = new DataSet(); oledbda.Fill(myds); txt_coding.Text = myds.Tables[0].Rows[0][3].ToString(); //获取物料编码 txt_coding.Enabled = false; txt_describe.Text = myds.Tables[0].Rows[0][5].ToString();//获取物料描述(型号) txt_describe.Enabled = false; txt_order.Text = myds.Tables[0].Rows[2][1].ToString();//获取订单号 txt_order.Enabled = false;
------解决方案--------------------
检索指定单元格的方法
http://dotnet.aspx.cc/file/Update-Excel-Cell-With-ADO.NET.aspx
String sql = "Select * FROM [Sheet1$B11:B11]";