16,718
社区成员
发帖
与我相关
我的任务
分享

Dim con As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=excel路径")
Try
con.Open()
Dim cmd As New OleDb.OleDbCommand("select * from [sheet1]", con)
Dim rs As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(cmd)
Dim DT As New DataTable
Try
rs.Fill(DT)
datagridview1.datasource=dt
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical)
connection.Close()
Exit Sub
End Try