Membaca File Excel menggunakan VB.NET dan OLEDB

File excel dapat dibaca dengan menggunakan VB.NET dan OLEDB. Kodenya sebagai berikut:

Dim connection OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=x.xls;Extended Properties=""Excel 8.0;HDR=NO;IMEX=1;""")
connection.Open()
query = "SELECT * FROM [Sheet1$] "
Dim command As OleDbCommand = New OleDbCommand(query, connection)
Dim dr As OleDbDataReader = command.ExecuteReader()
If dr.HasRows Then
    While dr.Read
        Dim x As String = dr.GetValue(0)
        Dim y As String = dr.GetValue(1)
    End While
End If



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s