Back to Devexpress

SearchOptions Class

officefileapi-devexpress-dot-spreadsheet-204a13a3.md

latest2.9 KB
Original Source

SearchOptions Class

Contains options affecting search in a document.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public class SearchOptions
vb
Public Class SearchOptions

Remarks

Use the IWorkbook.Search, Worksheet.Search or CellRange.Search method with a SearchOptions instance passed as a parameter to perform a search with the required settings.

The following code snippet searches for cells that contain today’s date. The matching cells are highlighted in green:

View Example

cs
using DevExpress.Spreadsheet;
// ...
            // Specify the search term.
            string searchString = DateTime.Today.ToString("d");

            // Specify search options.
            SearchOptions options = new SearchOptions();
            options.SearchBy = SearchBy.Columns;
            options.SearchIn = SearchIn.Values;
            options.MatchEntireCellContents = true;

            // Find and highlight all cells that contain today's date.
            IEnumerable<Cell> searchResult = worksheet.Search(searchString, options);
            foreach (Cell cell in searchResult)
                cell.Fill.BackgroundColor = Color.LightGreen;
vb
Imports DevExpress.Spreadsheet
' ...
            ' 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 and highlight all cells that contain today's date.
            Dim searchResult As IEnumerable(Of Cell) = worksheet.Search(searchString, options)
            For Each cell As Cell In searchResult
                cell.Fill.BackgroundColor = Color.LightGreen
            Next cell

Inheritance

Object SearchOptions

See Also

SearchOptions Members

Search

DevExpress.Spreadsheet Namespace