跳到主要内容

GetOutlineLvl

返回指定属性的大纲级别。

语法

expression.GetOutlineLvl();

expression - 表示 ApiParaPr 类的变量。

参数

此方法没有任何参数。

返回值

Number | undefined

示例

读取电子表格中分配给段落的大纲级别。

// How do I find out which heading depth a paragraph belongs to in a spreadsheet?

// Capture a paragraph's outline depth before and after changing it to track the update in a spreadsheet.

const worksheet = Api.GetActiveSheet();

const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
const shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);

const content = shape.GetContent();
const paragraph = content.GetElement(0);
const paraPr = paragraph.GetParaPr();

const levelBefore = paraPr.GetOutlineLvl();
paraPr.SetOutlineLvl(8);
const levelAfter = paraPr.GetOutlineLvl();
let text = 'Outline level (index) for this paragraph is currently set to ' + levelAfter;
text += ',\nbut originally was set to ' + levelBefore;
paragraph.AddText(text);