Dim strCon As String = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =C:/Documents and Settings/user/桌面/2006.xls;Extended Properties=Excel 8.0"
Dim myConn As New OleDbConnection(strCon)
Dim strCom As String = " SELECT * FROM [办公室1$] "
Try
myConn.Open() '打开数据链接,得到一个数据集
Dim objDA As OleDbDataAdapter = New OleDbDataAdapter(strCom, myConn)
Dim objDS As New DataSet
objDA.Fill(objDS)
DataGrid1.DataSource = objDS.Tables(0).DefaultView
'DataGrid1()
Catch a As Exception
MessageBox.Show(a.Message)
End Try
vb.net 连接excel
最新推荐文章于 2023-02-16 11:19:12 发布