Skip to main content

SelectRange

Selects a range of cells in the current table.

Syntax​

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

expression - A variable that represents an ApiTable class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
startRowIndexRequirednumberThe start row index.
startCellIndexRequirednumberThe start cell index within the start row.
endRowIndexRequirednumberThe end row index.
endCellIndexRequirednumberThe end cell index within the end row.

Returns​

boolean

Example​

Select a range of cells in a table in a PDF.

// Select several adjacent cells in a table at once in a PDF.

// Create a table and select a 2x2 block of cells starting from the top-left corner.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const table = Api.CreateTable(3, 3);
page.AddObject(table);

table.SelectRange(0, 0, 1, 1);
const paragraph = Api.CreateParagraph();
paragraph.AddText('Selected cells: ' + table.GetSelectedCells().length);
table.GetCell(0, 0).GetContent().Push(paragraph);