跳到主要内容

SelectRange

选择当前表格中的单元格范围。

语法​

expression.SelectRange(startRowIndex, startCellIndex, endRowIndex, endCellIndex);

expression - 表示 ApiTable 类的变量。

参数​

名称必需/可选数据类型默认值描述
startRowIndex必需number起始行索引。
startCellIndex必需number起始行中的起始单元格索引。
endRowIndex必需number结束行索引。
endCellIndex必需number结束行中的结束单元格索引。

返回值​

boolean

示例​

选择幻灯片上表格中的矩形单元格范围。

// Highlight a block of cells spanning several rows and columns to apply changes to them.

// Select the cells from the first cell of the first row to the second cell of the second row.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const table = Api.CreateTable(3, 3);
table.SetPosition(0, 0);
slide.AddObject(table);
table.SelectRange(0, 0, 1, 1);
const selectedCells = table.GetSelectedCells();
selectedCells.forEach(function(cell){
cell.SetBackgroundColor(Api.RGB(150, 0, 0))
})