跳到主要内容

SetPaddings

设置当前形状的文本内边距。

语法

expression.SetPaddings(nLeft, nTop, nRight, nBottom);

expression - 表示 ApiShape 类的变量。

参数

名称必需/可选数据类型默认值描述
nLeft必需EMU左内边距。
nTop必需EMU上内边距。
nRight必需EMU右内边距。
nBottom必需EMU下内边距。

返回值

boolean

示例

此示例设置当前形状的文本内边距。

// How to update paddings of the drawing.

// Create a shape and set its paddings.

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, 50 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
content.RemoveAllElements();
shape.SetVerticalTextAlign("bottom");
let paragraph = Api.CreateParagraph();
paragraph.SetJc("left");
paragraph.AddText("This is a sample text with paddings set to it. ");
paragraph.AddText("Left: 2cm, Top: 0.5cm, Right: 0.5cm, Bottom: 0.3cm");
shape.SetPaddings(20 * 36000, 5 * 36000, 5 * 36000, 3 * 36000);
content.Push(paragraph);