跳到主要内容

SetText

用指定文本替换段落内容。

语法

expression.SetText(text);

expression - 表示 ApiParagraph 类的变量。

参数

名称必需/可选数据类型默认值描述
text必需string要设置的文本。

返回值

ApiRun

示例

// How do I overwrite a paragraph's text inside a shape in a spreadsheet?

// Clear a paragraph and write a new sentence into it using a shape in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
let paragraph = content.GetElement(0);
paragraph.AddText("Original text inside the shape.");
paragraph.SetText("Updated text inside the shape.");