ReplaceTextSmart

ReplaceTextSmart(arrString, [sParaTab], [sParaNewLine])

Replaces each paragraph (or text in cell) in the select with the corresponding text from an array of strings.

Parameters:

Name Type Default Description
arrString Array

An array of replacement strings.

sParaTab string " "

A character which is used to specify the tab in the source text.

sParaNewLine string " "

A character which is used to specify the line break character in the source text.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oFParagraph = oDocument.GetElement(0);
oFParagraph.AddText("This is the text for the first line. The line break is added after it.");
oFParagraph.AddLineBreak();
var oSParagraph = Api.CreateParagraph();
oSParagraph.AddTabStop();
oSParagraph.AddText("This is just a sample text with a tab stop before it.");
oDocument.Push(oSParagraph);
var oRange1 = oFParagraph.GetRange();
var oRange2 = oSParagraph.GetRange();
var oRange3 = oRange1.ExpandTo(oRange2);
oRange3.Select();
var arr = ["test_1", "test_2"];
Api.ReplaceTextSmart(arr, "", "");
builder.SaveFile("docx", "ReplaceTextSmart.docx");
builder.CloseFile();

Resulting document