Brug OleDbConnection med :
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<Full Path of Excel File>; Extended Properties="Excel 8.0; HDR=No; IMEX=1";
Public Function ImportAttendence(ByVal PrmPathExcelFile As String, ByVal DataGrid1 As DataGrid)
Dim MyConnection As System.Data.OleDb.OleDbConnection
Try
''''''' Fetch Data from Excel
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source='" & PrmPathExcelFile & " '; " & "Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$]", MyConnection)
MyCommand.TableMappings.Add("Table", "Attendence")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
DataGrid1.DataSource = DtSet.Tables(0)
MyConnection.Close()
Catch ex As Exception
MyConnection.Close()
End Try
End Function
Med venlig hilsen
/Jokke Jensen
www.jj-multimediedesign.dk