跳到主要内容

SetBasedOn

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

语法

expression.SetBasedOn(oStyle);

expression - 表示 ApiStyle 类的变量。

参数

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

返回值

boolean

示例

在文档中基于现有样式创建自定义表格样式。

// How do I build a new table style that inherits formatting from another style in a document?

// Reuse a built-in style as the foundation for a custom table style in a 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);