The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

Worksheet.Search(String, SearchOptions) Method

Performs a search in the worksheet using specified options.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

IEnumerable<Cell> Search(
    string text,
    SearchOptions options
)
Function Search(
    text As String,
    options As SearchOptions
) As IEnumerable(Of Cell)
IEnumerable<Cell> Search(
    string text,
    SearchOptions options
)
Function Search(
    text As String,
    options As SearchOptions
) As IEnumerable(Of Cell)
IEnumerable<Cell> Search(
    string text,
    SearchOptions options
)
Function Search(
    text As String,
    options As SearchOptions
) As IEnumerable(Of Cell)

Parameters

Name Type Description
text String

A String representing the search text.

options SearchOptions

A SearchOptions instance containing required search options.

Parameters

Name Type Description
text String

A String representing the search text.

options SearchOptions

A SearchOptions instance containing required search options.

Parameters

Name Type Description
text String

A String representing the search text.

options SearchOptions

A SearchOptions instance containing required search options.

Returns

Type Description
IEnumerable<Cell>

An object implementing the IEnumerable interface which is the collection of cells that match the search term.

Returns

Type Description
IEnumerable<Cell>

An object implementing the IEnumerable interface which is the collection of cells that match the search term.

Returns

Type Description
IEnumerable<Cell>

An object implementing the IEnumerable interface which is the collection of cells that match the search term.

Remarks

To perform a search in the specific cell range or the entire document, use the CellRange.Search or IWorkbook.Search method. For more information about the search functionality in the SpreadsheetControl, refer to the Find and Replace article.

Examples

The example below demonstrates how to perform a search with the specified options in the active worksheet and highlight all matching cells.

workbook.LoadDocument("Documents\ExpenseReport.xlsx")
workbook.Calculate()
Dim worksheet As Worksheet = workbook.Worksheets(0)

' Specify the search term.
Dim searchString As String = Date.Today.ToString("d")

' Specify search options.
Dim options As New SearchOptions()
options.SearchBy = SearchBy.Columns
options.SearchIn = SearchIn.Values
options.MatchEntireCellContents = True

' Find all cells containing today's date and paint them light-green.
Dim searchResult As IEnumerable(Of Cell) = worksheet.Search(searchString, options)
For Each cell As Cell In searchResult
    cell.Fill.BackgroundColor = Color.LightGreen
Next cell
See Also