1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Private Sub BImpExcel_Click(sender As Object, e As EventArgs) Handles BImpExcel.Click
Label1.Show()
ListeAgent.Show()
Label2.Show()
Label4.Show()
DateFinPicker.Show()
DateDebutPicker.Show()
BDonnées.Show()
BActualiser.Show()
DataGAct.Rows.Clear()
Dim excel As String = ""
Dim OpenFileDialog As New OpenFileDialog
dat = New DataSet
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "All Files (*.*)|*.*|Excel files (*.xlsx)|*.xlsx|CSV Files (*.csv)|*.csv|XLS Files (*.xls)|*xls"
If OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
Dim fi As New FileInfo(OpenFileDialog.FileName)
Dim FileName As String = OpenFileDialog.FileName
excel = fi.FullName
Using Conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & excel & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""")
Using Adap As OleDbDataAdapter = New OleDbDataAdapter("select * from [Datasource Feuille$]", Conn)
Adap.Fill(dat)
End Using
End Using
Else
MsgBox(" Opération annuler" & Chr(10) & "Le programme va se fermer", vbExclamation, "Annulatoin")
Close()
End If
indice = 0
chaine = ""
While indice < dat.Tables(0).Rows.Count
If chaine = dat.Tables(0).Rows(indice).Item("RessourceAffectee").ToString Then
indice += 1
Else
chaine = dat.Tables(0).Rows(indice).Item("RessourceAffectee").ToString
ListeAgent.Items.Add(chaine)
indice += 1
End If
End While
End Sub |
Partager