跳到主要内容

Last

返回段落的最后一个元素。

语法

expression.Last();

expression - 表示 ApiParagraph 类的变量。

参数

此方法没有任何参数。

返回值

ParagraphContent

示例

此示例展示如何获取段落中非空的最后一个元素。

// How to get the last paragraph.

// Get the last paragraph and make it bold.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run1 = Api.CreateRun();
run1.AddText("This is an Run with text. ");
paragraph.Push(run1);
let run2 = Api.CreateRun();
run2.AddText("And this is the last Run in the paragraph.");
paragraph.Push(run2);
let lastRun = paragraph.Last();
lastRun.SetBold(true);