string strExcelName = this.txtExcelName.Text.Trim(); string strExcelDocName = this.txtExcelDocName.Text.Trim(); //读数据 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strPath+strExcelName + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); string strExcel = ""; OleDbDataAdapter myCommand = null; DataSet ds = null; strExcel = "select * from ["+strExcelDocName+"$]"; myCommand = new OleDbDataAdapter(strExcel, strConn); ds = new DataSet(); myCommand.Fill(ds, "table1"); |