# WorkbookSearch Class

> WorkbookSearch class in the Node.js TypeScript API: Sparse cross-sheet search and atomic replacement, independent of the selected worksheet and browser DOM.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > TypeScript API > Node.js Server > WorkbookSearch Class
- **757 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/llms-full.txt

---

Sparse cross-sheet search and atomic replacement, independent of the selected worksheet and browser DOM.

Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

Related workbook object-model type, returned through the server control. Obtain it from its owning workbook or collection; it is not a required browser-package import.

### Constructor

```typescript
new WorkbookSearch(workbook: Workbook): WorkbookSearch
```

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `workbook` | `Workbook` | No | Value matching workbook's declared type and the owning object's validation rules. |

Returns: `WorkbookSearch`.

### Members

#### Methods

| Method | Description |
|---|---|
| [find](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/find-method/llms-full.txt) | Finds cells in workbook order and then row-major order, returning at most maxResults (default 1,000). |
| [replace](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/replace-method/llms-full.txt) | Replaces all matches in one atomic workbook transaction; protection and validation remain enforced. |

### Examples

Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.

```typescript
import type { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';

function createWorkbookSearchReport(control: ServerSheetControl) {
    const book = control.workbook;
    const sheet = book.sheets.at(0);
    sheet.cell('A1').setText('October invoice');
    sheet
        .cell('A1')
        .format({
            fontFamily: 'Liberation Sans',
            fontSize: 16,
            bold: true,
            textColor: '#ffffff',
            fillColor: '#163b63',
        });

    sheet.columns.at(0).setWidth({ pixels: 240 });
    sheet.range('B8:B9').setValues([[120], [80]]);
    sheet.cell('B10').setFormula('=SUM(B8:B9)');
    sheet.range('B8:B10').format({ numberFormatCode: '#,##0.00', fontSize: 11 });
    sheet.cell('A7').setText('Consulting');
    book.search.replace({ query: 'Consulting' }, 'Consulting services');
    return sheet;
}
```

### See Also

- [TypeScript Node.js Server API](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/llms-full.txt)
- [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)

---

## In This Section

- [WorkbookSearch.find Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/find-method/llms-full.txt): WorkbookSearch.find method in the Node.js TypeScript API, with the parameter options, the return type SearchMatch[] and a TypeScript example.
- [WorkbookSearch.replace Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/replace-method/llms-full.txt): WorkbookSearch.replace method in the TX Sheet Control TypeScript API for Node.js: Replaces all matches in one atomic workbook transaction.

---

## Nearby

- **Previous:** [WorkbookPdfOptions.viewerPreferences Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookpdfoptions/viewerpreferences-property/llms-full.txt)
- **Next:** [WorkbookSearch.find Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbooksearch/find-method/llms-full.txt)
