officefileapi-devexpress-dot-spreadsheet-dot-worksheet-dot-search-x28-system-dot-string-x29.md
Performs a search in the worksheet using the default parameters.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
IEnumerable<Cell> Search(
string text
)
Function Search(
text As String
) As IEnumerable(Of Cell)
| Name | Type | Description |
|---|---|---|
| text | String |
A String representing the search text.
|
| Type | Description |
|---|---|
| IEnumerable<Cell> |
An object implementing the IEnumerable interface which is the collection of cells that match the search term.
|
Use the Search method to perform a search in the current worksheet with the default parameters listed in the table below.
| Option | Default Value |
|---|---|
| Look In | Values and Formulas |
| Search Direction | By Rows |
| Match Case | False |
| Match Entire Cell Contents | False |
To perform a search in the specific cell range or the entire document, use the CellRange.Search or IWorkbook.Search method. Use the CellRange.Value property to replace values in cells that match the search term.
For more information about the search functionality in the SpreadsheetControl, refer to the Find and Replace article.
The example below demonstrates how to perform a search in the active worksheet and highlight all matching cells.
workbook.LoadDocument("Documents\ExpenseReport.xlsx")
workbook.Calculate()
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Find and highlight cells containing the word "holiday".
Dim searchResult As IEnumerable(Of Cell) = worksheet.Search("holiday")
For Each cell As Cell In searchResult
cell.Fill.BackgroundColor = Color.LightGreen
Next cell
workbook.LoadDocument("Documents\\ExpenseReport.xlsx");
workbook.Calculate();
Worksheet worksheet = workbook.Worksheets[0];
// Find and highlight cells containing the word "holiday".
IEnumerable<Cell> searchResult = worksheet.Search("holiday");
foreach (Cell cell in searchResult)
cell.Fill.BackgroundColor = Color.LightGreen;
The following code snippets (auto-collected from DevExpress Examples) contain references to the Search(String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
// Find and highlight cells containing the word "holiday".
IEnumerable<Cell> searchResult = worksheet.Search("holiday");
foreach (Cell cell in searchResult)
// Find and highlight cells containing the word "holiday".
IEnumerable<Cell> searchResult = worksheet.Search("holiday");
foreach (Cell cell in searchResult)
// Find and highlight cells that contain the word "holiday".
IEnumerable<Cell> searchResult = worksheet.Search("holiday");
foreach (Cell cell in searchResult)
' Find and highlight cells containing the word "holiday".
Dim searchResult As IEnumerable(Of Cell) = worksheet.Search("holiday")
For Each cell As Cell In searchResult
' Find and highlight cells containing the word "holiday".
Dim searchResult As IEnumerable(Of Cell) = worksheet.Search("holiday")
For Each cell As Cell In searchResult
' Find and highlight cells that contain the word "holiday".
Dim searchResult As IEnumerable(Of Cell) = worksheet.Search("holiday")
For Each cell As Cell In searchResult
See Also