A table selection represents a contiguous region of cells in a particular table.
Note: as of v2.0.5 you may treat any TableSelection object as a Selection object, eg: all properties/commands listed under Selection are valid for TableSelection objects.
TableSelection Type Commands
Returns the first TableSelection in the active Document, or the @undefined value if no table is selected.
A table is considered as selected only if either a table cell region (of rows and columns) is directly selected, or a text selection rests inside a table cell’s text. A table is not considered as selected if a text selection in the outer enclosing text object encompasses the entire table.
TableSelection.new tableObject, [rowOrRange], [columnOrRange] v1.1
Returns a new selection describing a cell region within the given table. The row and column arguments can be either a Range object describing multiple cells, or a single cell index (integer). The row and column must be in-bounds for the table or an error will be displayed.
If no row or column information is given, then the selection will encompass all rows/columns.
TableSelection Object Properties
Returns the Table object in which the selection has been made. Read-only.
.rowRange v1.1
Returns a Range object that describes which rows in the table object are selected. The range is zero-based (eg: the first row in the table has location zero).
.columnRange v1.1
Returns a Range object that describes which columns in the table object are selected. The range is zero-based (eg: the first column in the table has location zero).
.firstCell v2.0.7
Returns the first TableCell object in the selected region, or @undefined if none.
.cells v2.0.7
Returns an array of all TableCell objects in the selected region.
TableSelection Object Commands
.applyShadingAttributes shadingAttrs v2.0.7
Changes the background shading of all cells in the selected region to use those specified by the given ShadingAttributes object.
.applyLineAttributesToEdges lineAttrs, edgeNames v2.0.7
Changes the appearance of cell border edges in the selected region to use those specified by the given LineAttributes object.
The edges that are affected depends on the edgeNames argument, which should be one or more of the names (separated by commas) from the following list.
Edge Name |
Affected Edges |
All |
All edges in the selected region. |
Normal |
All edges in the selected region, excluding slashes inside cells. |
Top |
Just the top edge of the first row in the selected region. |
Bottom |
Just the bottom edge of the last row in the selected region. |
Left |
Just the left edge of the first column in the selection region. |
Right |
Just the right edge of the last column in the selection region. |
SlashLeft |
The diagonal inside a cell going from the top-left to bottom-right. |
SlashRight |
The diagonal inside a cell going from the top-right to bottom-left. |
X |
Both the SlashLeft and SlashRight edges, forming an X inside cells. |
Inner |
All edges interior to the selected region (eg: excluding top, etc) |
InnerHorizontal |
Horizontal edges interior to the selected region. |
InnerVertical |
Vertical edges interior to the selected region. |
Outer |
All edges around the selected region, ie: top, left, bottom, and right. |
OuterHorizontal |
Horizontal edges around the selected region, ie: top and bottom. |
OuterVertical |
Vertical edges around the selected region, ie: left and right. |
TableSelection & Table Object Example
If the selection currently rests inside a table cell, the following code changes the selection to reside just after the end of the table:
$doc = Document.active
# check if there is a table selection
$tableSel = $doc.tableSelection
If $tableSel
$table = $tableSel.table
$text = $table.enclosingText
$textRange = $table.enclosingTextRange
# place a caret just after the table's range
$textRange.location = $textRange.bound
$textRange.length = 0
$textSel = TextSelection.new( $text, $textRange )
$doc.setSelection( $textSel )
End
Previous Chapter TextSelection Object |
<< index >> |
Next Chapter Selection Commands |