跳到主要内容

GetText

返回当前表格单元格的内部文本。

语法

expression.GetText(pr);

expression - 表示 ApiTableCell 类的变量。

参数

名称必需/可选数据类型默认值描述
pr可选object返回文本的格式选项。
pr.Numbering可选booleantrue定义结果字符串是否包含编号。
pr.Math可选booleantrue定义结果字符串是否包含数学表达式。
pr.TableCellSeparator可选string'\t'定义表格单元格分隔符在结果字符串中的指定方式。
pr.TableRowSeparator可选string'\r\n'定义表格行分隔符在结果字符串中的指定方式。
pr.ParaSeparator可选string'\r\n'定义段落分隔符在结果字符串中的指定方式。
pr.TabSymbol可选string'\t'定义制表符在结果字符串中的指定方式。
pr.NewLineSeparator可选string'\r'定义行分隔符在结果字符串中的指定方式。

返回值

string

示例

// How do I retrieve the plain text from a table cell in a presentation?

// Extract text from a cell and display it in a separate text box on the slide.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const table = Api.CreateTable(2, 2);
const cell = table.GetRow(0).GetCell(0);
cell.AddText("Cell content.");
const text = cell.GetText({TableCellSeparator : ""});

const fill = Api.CreateSolidFill(Api.HexColor('#E8D5B7'));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape('roundRect', Api.MillimetersToEmus(200), Api.MillimetersToEmus(30), fill, stroke);
shape.SetPosition(Api.MillimetersToEmus(20), Api.MillimetersToEmus(120));
shape.GetContent().GetElement(0).AddText("Cell text: " + text);

slide.AddObject(table);
slide.AddObject(shape);