@univerjs/sheets-find-replace v0.5.4
Interface: IFTextFinder
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:23
Methods
ensureCompleteAsync()
ensureCompleteAsync(): Promise<Nullable<IFindComplete>>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:152
ensure the find operation is completed
Returns
Promise
<Nullable
<IFindComplete
>>
the find complete result
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const complete = await textFinder.ensureCompleteAsync();
console.log(complete);
findAll()
findAll(): FRange[]
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:37
get all the matched range in the univer
Returns
FRange
[]
all the matched range
Throws
if the find operation is not completed
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const ranges = textFinder.findAll();
ranges.forEach((range) => {
console.log(range.getA1Notation());
});
findNext()
findNext(): Nullable<FRange>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:52
find the next matched range in the univer
Returns
the next matched range
null if no more match
Throws
if the find operation is not completed
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const range = textFinder.findNext();
if (range) {
console.log(range.getA1Notation());
}
findPrevious()
findPrevious(): Nullable<FRange>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:67
find the previous matched range in the univer
Returns
the previous matched range
null if no more match
Throws
if the find operation is not completed
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const range = textFinder.findPrevious();
if (range) {
console.log(range.getA1Notation());
}
getCurrentMatch()
getCurrentMatch(): Nullable<FRange>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:81
get the current matched range in the univer
Returns
the current matched range
Throws
if the find operation is not completed
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const range = textFinder.getCurrentMatch();
if (range) {
console.log(range.getA1Notation());
}
matchCaseAsync()
matchCaseAsync(matchCase): Promise<IFTextFinder>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:93
set the match case option
Parameters
Parameter | Type | Description |
---|---|---|
matchCase | boolean | whether to match case |
Returns
Promise
<IFTextFinder
>
text-finder instance
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
await textFinder.matchCaseAsync(true);
matchEntireCellAsync()
matchEntireCellAsync(matchEntireCell): Promise<IFTextFinder>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:104
set the match entire cell option
Parameters
Parameter | Type | Description |
---|---|---|
matchEntireCell | boolean | whether to match entire cell |
Returns
Promise
<IFTextFinder
>
text-finder instance
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
await textFinder.matchEntireCellAsync(true);
matchFormulaTextAsync()
matchFormulaTextAsync(matchFormulaText): Promise<IFTextFinder>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:115
set the match formula text option
Parameters
Parameter | Type | Description |
---|---|---|
matchFormulaText | boolean | whether to match formula text |
Returns
Promise
<IFTextFinder
>
text-finder instance
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
await textFinder.matchFormulaTextAsync(true);
replaceAllWithAsync()
replaceAllWithAsync(replaceText): Promise<number>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:128
replace all the matched text with the given text
Parameters
Parameter | Type | Description |
---|---|---|
replaceText | string | the text to replace |
Returns
Promise
<number
>
the number of replaced text
Throws
if the find operation is not completed
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const replacedCount = await textFinder.replaceAllWithAsync('world');
console.log(replacedCount);
replaceWithAsync()
replaceWithAsync(replaceText): Promise<boolean>
Defined in: sheets-find-replace/src/facade/f-text-finder.ts:141
replace the current matched text with the given text
Parameters
Parameter | Type | Description |
---|---|---|
replaceText | string | the text to replace |
Returns
Promise
<boolean
>
whether the replace is successful
Throws
if the find operation is not completed
Example
const textFinder = await univerAPI.createTextFinderAsync('hello');
const replaced = await textFinder.replaceWithAsync('world');
console.log(replaced);