Dim tbl As DataTable
Dim da As New OleDb.OleDbDataAdapter
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fname As String = "C:\1.xls"
Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fName & ";Extended Properties=""Excel 8.0;HDR=NO;IMEX=1""")
cn.Open()
da.SelectCommand = New OleDb.OleDbCommand("Select [F1] from [Лист3$]", cn)
tbl = New DataTable
da.Fill(tbl)
'DataGridView1.DataSource = tbl
ListBox1.DisplayMember = "F1"
ListBox1.DataSource = tbl
End Sub |