Good day everyone ^_^.
In this post I'll show you how to reading excel file by VB.NET code. I have an example named karyawan.xlsx and I saved it on D:\karyawan.xlsx.
Here is what it looks like:
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Open("D:\karyawan.xlsx")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")
'display the cells value B2
MsgBox(xlWorkSheet.Cells(2, 2).value)
xlWorkBook.Close()
xlApp.Quit()
End Sub
End Class
Lets run!!!
0 Comments