跳到主要内容

SetCellMarginTop

指定表格中特定表格单元格的内容上边与 单元格边框之间的间距。

语法

expression.SetCellMarginTop(nValue);

expression - 表示 ApiTableCellPr 类的变量。

参数

名称必需/可选数据类型默认值描述
nValue必需twips单元格内容上边上方的间距值,以点的二十分之一为单位(1/1440 英寸)。如果此值为 <code>null</code>,则使用默认的表格单元格上边距,否则将使用当前单元格的指定值覆盖表格单元格上边距。

返回值

boolean

示例

此示例指定表格中特定表格单元格的内容上边与单元格边框之间的间距。

// How to add margin to the top of the cell.

// Create a 3x3 table and add the top cell margin.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
let cell = table.GetRow(0).GetCell(0);
cell.GetContent().GetElement(0).AddText("This is just a sample text to show that the top margin for all the table cells is 36 points.");
table.SetWidth("percent", 100);
let tableCellPr = tableStyle.GetTableCellPr();
tableCellPr.SetCellMarginTop(720);
table.SetStyle(tableStyle);
doc.Push(table);