1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mycon As System.Data.OleDb.OleDbConnection
Dim Dst As System.Data.DataSet
Dim mycomd As System.Data.OleDb.OleDbDataAdapter
Dim selectedFile As String = String.Empty
' Pour afficher l'OpenFileDialog
OpenFileDialog1.ShowDialog()
' Pour insérer l'emplacement du fichier choisi dans le TextBox
selectedFile = OpenFileDialog1.FileName
Dim conString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & selectedFile & ";Extended Properties=""Excel 12.0 Xml;HDR=Yes"""
mycon = New System.Data.OleDb.OleDbConnection(conString)
mycomd = New System.Data.OleDb.OleDbDataAdapter("select * from [Feuil1$]", mycon)
mycomd.TableMappings.Add("Table", "TestTabe")
Dst = New System.Data.DataSet
mycomd.Fill(Dst)
End Sub |
Partager