跳到主要内容

Push

推送段落或表格以将其实际添加到文档中。

语法

expression.Push(oElement);

expression - 表示 ApiDocumentContent 类的变量。

参数

名称必需/可选数据类型默认值描述
oElement必需DocumentElement将推送到文档的元素类型。

返回值

boolean

示例

向电子表格中形状内容的末尾追加新段落。

// How do I add a paragraph to the bottom of a shape's text area in a spreadsheet?

// Build a paragraph separately and place it at the end of 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", 60 * 36000, 35 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
content.RemoveAllElements();
let paragraph = Api.CreateParagraph();
paragraph.SetJc("left");
paragraph.AddText("We removed all elements from the shape and added a new paragraph inside it.");
content.Push(paragraph);