跳到主要内容

SetBorders

使用指定的参数设置单元格/单元格范围的边框。

语法

expression.SetBorders(bordersIndex, lineStyle, oColor);

expression - 表示 ApiRange 类的变量。

参数

名称必需/可选数据类型默认值描述
bordersIndex必需BordersIndex指定单元格边框位置。
lineStyle必需LineStyle指定用于形成单元格边框的线条样式。
oColor必需ApiColor指定要设置给单元格边框的颜色的颜色对象。

返回值

boolean

示例

在电子表格中为单元格添加边框。

// How do I draw a border on a specific side of a cell in a spreadsheet?

// Define which edge of a cell gets a border, its thickness, and its color in a spreadsheet.

let worksheet = Api.GetActiveSheet();
worksheet.SetColumnWidth(0, 50);
worksheet.GetRange("A2").SetBorders("Bottom", "Thick", Api.CreateColorFromRGB(255, 111, 61));
worksheet.GetRange("A2").SetValue("This is a cell with a bottom border");