I want to read an excel file in VB.NET
. This excel file is always open and is constantly updated.
The code I have used is given below.
Dim objExcelApp As New Excel.Application
Dim objWorkBook As Excel.Workbook = objExcelApp.Workbooks.Open("c:\ReadExcel.xls")
Dim objWorkSheet As Excel.Worksheet = objWorkBook.Worksheets.Item(1)
Dim objRng As Excel.Range
Dim strCol, strCell As String
Dim maxCol, maxRow As Integer
Dim iRow, iCol As Integer
maxRow = 2
maxCol = 2
objWorkBook = objExcelApp.Workbooks.Open("c:\ReadExcel.xls")
objWorkSheet = objWorkBook.Worksheets(1)
objExcelApp.Visible = True
For iCol = 1 To maxCol
For iRow = 1 To maxRow
strCol = Chr(Asc(iRow) + 16)
strCell = strCol + iCol.ToString
objRng = objWorkSheet.Range(strCell)
I have a few issues with this code.
1. Since I want to read an already open excel sheet I don't want to open it again. Here the OPEN command opens another excel sheet which I don't want.
2. In this code the columns & rows are hard coded, but in my case the excel sheet can have any number of rows & columns.
I want to loop till the end of the file.
Can anybody Please help me on an urgent basis.
Thanks in advance