Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Collapse]Spreadsheet
   [Expand]Product Information
    Product Structure
    Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Spreadsheet Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
    Data Grouping
   [Expand]Pivot Table Overview
   [Expand]Charting Overview
    Printing
    Events
   [Expand]Mail Merge Overview
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
   [Expand]Shortcuts
   [Expand]Examples
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Find and Replace

The SpreadsheetControl allows you to search for specific data in a document. You can perform a search using the SpreadsheetControl's user interface, or directly in code using the corresponding Search method overloads.

Expanded Search Using the Find and Replace Dialog

You can find data in the current worksheet using the Find and Replace feature of the SpreadsheetControl. To perform a search, on the Home tab, in the Editing group, click the Find & Select button. The button's drop-down menu will be displayed.

Next, do one of the following.

  • Click Find in the Find & Select drop-down menu (or press CTRL+F) to perform a search in the active worksheet. The Find and Replace dialog (with the Find tab activated) will be invoked.

    In the Find what field, enter the text or number you wish to find, and click the Find Next button to start the search. To define the direction of the search, in the Search field, select the By Rows or By Columns drop-down item. In the Look in field, select Values (to search cell values only) or Formulas (to search cell values and formula expressions, excluding the calculated results). To perform a case-sensitive search, select the Match Case check box. To restrict the search to the entire cell content, select the Match entire cell contents check box.

  • Click Replace in the Find & Select drop-down menu (or press CTRL+H) to search for a text string and optionally replace it with another value. The Find and Replace dialog (with the Replace tab activated) will be invoked.

    In the Find what field, enter the text or number you wish to find. In the Replace with field, enter the replacement text for your search term. Click the Replace button to replace only the value of the selected matching cell, or the Replace All button to replace all occurrences of the search term. Note that the Replace tab provides the same search options as the Find tab, with one exception: you can only select the Formulas drop-down item in the Look in box, so only the underlying formulas (not the calculated results) will be examined when searching for matches to your search term.

Expanded Search in Code

The SpreadsheetControl also allows you to find text in a range, worksheet or entire document programmatically using the Range.Search, Worksheet.Search or IWorkbook.Search methods, respectively. To set options affecting search in a document, create an instance of the SearchOptions class and pass it as a parameter to the Search method. As in the case of the user interface, you can set the following advanced options.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4832.

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

The image below shows the result of executing the code. Today's date is located in the expense report and highlighted in light-green.

How would you rate this topic?​​​​​​​