跳到主要内容

SUBSTITUTE

Replaces existing text with new text in a text string.

Syntax

expression.SUBSTITUTE(arg1, arg2, arg3, arg4);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | stringThe text or the reference to a cell containing text in which the characters will be substituted.
arg2RequiredApiRange | ApiName | stringThe existing text to replace. If the case of the original text does not match the case of text, the function will not replace the text.
arg3RequiredApiRange | ApiName | stringThe text to replace the original text with.
arg4OptionalApiRange | ApiName | stringSpecifies which occurrence of the original text to replace. If omitted, every instance of the original text will be replaced.

Returns

string

Example

let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue(func.SUBSTITUTE("Online Office is a cloud business service portal", "Office", "portal"));