跳到主要内容

CreateRun

创建要插入到当前段落或表格中的新的较小文本块。

语法

expression.CreateRun();

expression - 表示 Api 类的变量。

参数

此方法没有任何参数。

返回值

ApiRun

示例

此示例创建一个要插入到段落或表格中的新的较小文本块。

// Create a text to construct a paragraph.

// Add a text in a paragraph.

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 docContent = shape.GetContent();
let paragraph = docContent.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
paragraph.AddElement(run);
run = Api.CreateRun();
run.SetFontFamily("Comic Sans MS");
run.AddText("This is a text run with the font family set to 'Comic Sans MS'.");
paragraph.AddElement(run);