跳到主要内容

SetBasedOn

指定此样式在样式层次结构中继承的父样式的引用。

语法

expression.SetBasedOn(oStyle);

expression - 表示 ApiStyle 类的变量。

参数

名称必需/可选数据类型默认值描述
oStyle必需ApiStyle样式继承属性的父样式。

返回值

boolean

示例

此示例指定此样式在样式层次结构中继承的父样式的引用。

// How to get the specific style from the document and create table style based on it.

// Inherit bordered style of the document.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);