GetOutlineLvl
返回指定属性的大纲级别。
语法
expression.GetOutlineLvl();
expression - 表示 ApiParagraph 类的变量。
参数
此方法没有任何参数。
返回值
Number | undefined
示例
在电子表格中读取形状内每个段落所分配的大纲级别。
// How do I check the heading depth of a paragraph in a spreadsheet?
// Display each paragraph alongside its outline level to inspect the document structure in a spreadsheet.
const worksheet = Api.GetActiveSheet();
const fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
const content = shape.GetContent();
const firstParagraph = content.GetElement(0);
firstParagraph.AddText('Outline level of this paragraph is ' + firstParagraph.GetOutlineLvl() + '.');
for (let levelIndex = 0; levelIndex < 9; levelIndex++) {
const paragraph = Api.CreateParagraph();
paragraph.SetOutlineLvl(levelIndex);
const level = paragraph.GetOutlineLvl() + 1;
paragraph.AddText('This is a paragraph with outline level ' + level + '.');
content.Push(paragraph);
}