跳到主要内容

GetText

返回段落文本。

语法

expression.GetText(options);

expression - 表示 ApiParagraph 类的变量。

参数

名称必需/可选数据类型默认值描述
options可选object返回文本的格式选项。
options.Numbering可选booleanfalse定义结果字符串是否包含编号。
options.Math可选booleanfalse定义结果字符串是否包含数学表达式。
options.NewLineSeparator可选string'\r'定义在结果字符串中如何指定行分隔符。可以使用任何字符串。默认分隔符为 “\r”。
options.TabSymbol可选string'\t'定义在结果字符串中如何指定制表符(不适用于编号)。可以使用任何字符串。默认符号为 “\t”。

返回值

string

示例

// How do I retrieve the plain text from a paragraph inside a shape in a spreadsheet?

// Extract the paragraph text and write it to a cell to verify the content in a spreadsheet.

const worksheet = Api.GetActiveSheet();
const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
const content = shape.GetContent();
const paragraph = content.GetElement(0);
paragraph.AddText("Sample paragraph text.");
const text = paragraph.GetText();
worksheet.GetRange("A1").SetValue("Paragraph text: " + text);