跳到主要内容

SetJc

指定当前表格相对于当前节中文本边距的对齐方式。

语法

expression.SetJc(sJcType);

expression - 表示 ApiTablePr 类的变量。

参数

名称必需/可选数据类型默认值描述
sJcType必需"left" | "right" | "center"用于当前表格放置的对齐类型。

返回值

boolean

示例

在文档中将表格水平定位在页面边距内。

// How do I align a table to the center or sides of the page in a document?

// Place a table at a specific horizontal position relative to the surrounding text in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("The table is aligned at the center of the page horizontally:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let tablePr = tableStyle.GetTablePr();
tablePr.SetJc("center");
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 50);
table.SetTableLook(true, true, true, true, false, false);
table.SetStyle(tableStyle);
doc.Push(table);