TX Sheet Control

Search.ReplaceAsync Method

Method
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Api.dll from the private NuGet feed or the supplied NuGet folder
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll

Replaces matching cells in one transaction; protection and validation are still enforced.

Syntax

public Task<int> ReplaceAsync(SearchOptions options, string replacement, CancellationToken cancellationToken = default)

Parameters

ParameterTypeOptionalDescription
optionsSearchOptionsNoSupported settings for this operation; omitted settings retain documented defaults.
replacementstringNoValue matching replacement's declared type and the owning object's validation rules.
cancellationTokenCancellationTokenYesCancels waiting or execution as supported by this operation.

Return Value

Task<int>.

Examples

Create the sample document data first, then use Search.ReplaceAsync. The returned value can be used by the calling report or application.

using TXTextControl.TXSheetControl.Server;

async Task<int> UseSearchReplaceAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Cell("A1").SetTextAsync("Consulting");

    var search = book.Search;

    var result = await search.ReplaceAsync(new SearchOptions(), "Consulting services");
    return result;
}

Remarks

Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.

See Also