Re: excel file read query
like im trying it this way but getting an error
Code:
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
If Not String.IsNullOrEmpty(txtFileName.Text) Then
Try
btnClose.Enabled = False
Dim OExcelHandler As New ExcelHandler()
Dim ds As DataSet = OExcelHandler.GetDataFromExcel(txtFileName.Text.Trim())
Dim currentFind As Excel.Range = Nothing
Dim firstFind As Excel.Range = Nothing
Dim Fruits As Excel.Range = Me.Application.Range("A1", "a500")
' You should specify all these parameters every time you call this method,
' since they can be overridden in the user interface.
currentFind = Fruits.Find("Cash at Bank", , _
Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, _
Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, False)
While Not currentFind Is Nothing
' Keep track of the first range you find.
If firstFind Is Nothing Then
firstFind = currentFind
' If you didn't move to a new range, you are done.
ElseIf currentFind.Address = firstFind.Address Then
Exit While
End If
With currentFind.Font
.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)
.Bold = True
End With
currentFind = Fruits.FindNext(currentFind)
End While
Catch ex As Exception
Finally
btnClose.Enabled = True
End Try
End If
End Sub
Re: excel file read query
You might explain things like;
What is "ExcelHandler", "GetDataFromExcel" etc. There are way to many unknowns in your code to provide suggestions. Lastly, when there is an error as you have mentioned it would be wise to indicate exactly what the errror message is.