Find and Seach using Aspose.Excel


#1

Hi,

Please find the following code in VB.NET using MS Excel and suggest me an equalant Aspose.excel code for search?

Private Sub DemoFind()
Dim currentFind As Excel.Range

’ Keep track of the first range you find.
Dim firstFind As Excel.Range = Nothing

’ You should specify all these parameters
’ every time you call this method, since they
’ can be overridden in the user interface.
currentFind = Me.Fruits.Find(“apples”, , _
Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, _
Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, _
False)
While Not currentFind Is Nothing
If firstFind Is Nothing Then
firstFind = currentFind
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 =Me.Fruits.FindNext(currentFind)
End While
End Sub


#2

Please try the following sample code with the attached fix.

’ Search string in range from B2 to F11

Dim cells as Cells = ExcelObj.Worksheets(0).Cells

Dim area as CellArea
area.StartRow = 1
area.EndRow = 10
area.StartColumn = 1
area.EndColumn = 5

Dim previousCell as Cell = null
Dim currentCell as Cell = cells.FindString(“apples”, previousCell, area)

While Not currentCell Is Nothing
previousCell = currentCell
With currentCell.Style.Font
.Color = Color.Red
.IsBold = True
End With
currentCell = cells.FindString(“apples”, previousCell, area)
End While


#3

Hi,

Thanks for that…But in search i am really looking for a format to search inside a loop and validate for it.

For Ex, i am looking for cell values with “-” inside. (HEP-001,GEIO-98).
In Excel they have (-) for that.Here how can i search that?

-Balaji RJ