跳到主要内容

REPLACE

Replaces part of a text string with a different text string.

Syntax

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

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | stringThe text where some characters will be replaced.
arg2RequiredApiRange | ApiName | numberThe position of the character in the original text that will be replaced with the new text.
arg3RequiredApiRange | ApiName | numberThe number of characters in the original text that will be replaced.
arg4RequiredApiRange | ApiName | stringThe text that will replace characters in the original text.

Returns

string

Example

let worksheet = Api.GetActiveSheet();
let func = Api.GetWorksheetFunction();
worksheet.GetRange("A1").SetValue(func.REPLACE("Online Office", 8, 6, "portal"));