Result: B2 is the active match and D7 is also highlighted; values are unchanged. The static controls show the equivalent Ctrl+F view after entering “error”; calling grid.search alone does not open the widget.
Usage example (requires an initialized grid)
This API excerpt needs an initialized grid. Populate its first seven rows with the log cells above, using plain "error" in B2 and D7. The final call clears the search highlights, not the values.
If cells B2 and D7 contain "error", the log shows 2 match(es). result.matches is [B2, D7] as zero-based addresses, and result.active is 0.
findNext() and findPrev() move the active match. clearSearch() clears the highlights. The built-in Ctrl+F find widget, gated by config.find (on by default), drives this same API.
Replace literal text/number matches through undoable transactions.
Edge cases and limits
An active search picks up matches that a value edit adds or removes, without scrolling.
On sheets with formulas or references, an active search rescans after each edit, including edits to off-screen inputs or other sheets. This keeps matches whose computed text changes.
highlightCells(ranges, color?) highlights arbitrary ranges independently of search. Pass null to clear; color overrides the theme highlight color. See Temporary highlights.
Set config.find: false to turn off the Ctrl+F widget. The methods still work.
const result: SearchResultconstresult:SearchResultconstresult:SearchResultSearch state after the replacement (matches re-scanned against the new data).API reference →const grid: Gridconstgrid:Gridconstgrid:GridThe imperative core grid this controller owns.API reference →Grid.search(query: string, opts?: SearchOptions): SearchResultGrid.search(query: string, opts?: SearchOptions): SearchResultGrid.search(query: string, opts?: SearchOptions): SearchResultFind cells matching query; highlights matches, emits search, returns the result.API reference →var console: Consolevar console:Consolevar console:ConsoleConsole.log(...data: any[]): void (+1 overload)Console.log(...data: any[]): void (+1 overload)Console.log(...data: any[]): void (+1 overload)The console.log() static method outputs a message to the console. MDN ReferenceSearchResult.matches: CellAddress[]interfaceSearchResult {matches:CellAddress[];}interfaceSearchResult {matches:CellAddress[];}Matching cells in row-major order.API reference →Array<CellAddress>.length: numberinterfaceArray<CellAddress> {length:number;}interfaceArray<CellAddress> {length:number;}Gets or sets the length of the array. This is a number one higher than the highest index in the array.API reference →Grid.findNext(): SearchResultGrid.findNext(): SearchResultGrid.findNext(): SearchResultMove the active match to the next match and scroll it into view.API reference →Grid.clearSearch(): voidGrid.clearSearch(): voidGrid.clearSearch(): voidClear the current search and its highlights.API reference →interface SearchOptions
interface SearchOptionsinterfaceSearchOptionsinterfaceSearchOptionsinterfaceSearchOptionsinterfaceSearchOptionsCase, whole-cell, sheet, and column constraints for grid search.API reference →SearchOptions.matchCase?: boolean | undefinedinterfaceSearchOptions {matchCase?:boolean|undefined;}interfaceSearchOptions {matchCase?:boolean|undefined;}Case-sensitive match (default false).API reference →SearchOptions.wholeCell?: boolean | undefinedinterfaceSearchOptions {wholeCell?:boolean|undefined;}interfaceSearchOptions {wholeCell?:boolean|undefined;}Match only when the whole cell text equals the query (default false: substring).API reference →SearchOptions.sheet?: string | undefinedinterfaceSearchOptions {sheet?:string|undefined;}interfaceSearchOptions {sheet?:string|undefined;}Sheet identity used by the simple data-first adapter. Defaults to sheet1.API reference →type SheetId = stringtypeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →SearchOptions.columns?: number[] | undefinedinterfaceSearchOptions {columns?:number[] |undefined;}interfaceSearchOptions {columns?:number[] |undefined;}Exact column runs represented by every returned row.API reference →interface SearchResult
interface SearchResultinterfaceSearchResultinterfaceSearchResultinterfaceSearchResultinterfaceSearchResultOrdered matches and active index produced by a grid search.API reference →SearchResult.query: stringinterfaceSearchResult {query:string;}interfaceSearchResult {query:string;}Query string retained for navigation and subsequent replacement.API reference →interface CellAddressinterfaceCellAddressinterfaceCellAddressZero-based address of one cell on a stable sheet ID.API reference →SearchResult.active: numberinterfaceSearchResult {active:number;}interfaceSearchResult {active:number;}Index of the active match within matches, or -1 when there are none.API reference →