WP Table get rows
WP Table get rows ( targetObj ) | ( tableRef ; startRow | wk header rows {; numRows} ) -> Function result
Parameter | Type | Description | |
---|---|---|---|
targetObj | Object | → | Range or element or 4D Write Pro document |
tableRef | Object | → | Table reference |
startRow | wk header rows | Longint, String | → | Position of first row OR wk header rows |
numRows | Longint | → | Number of rows to get |
Function result | Object | ← | New row range containing selected rows |
Description
The WP Table get rows command returns a new row range object containing a selection of rows from targetObj or tableRef.
Pass either:
- targetObj:
- a range, or
- an element (row / paragraph / body / header / footer / inline picture / section / subsection), or
- a 4D Write Pro document
If targetObj does not intersect with a table or text range where a selection of rows can be retrieved, the command returns Null.
OR
- tableRef: the reference of the table whose selection of rows you want to get.
- startRow: points to the first table row to return, and
- (optional) numRows - specifies how many rows to return. If numRows is omitted, the single startRow row is returned.
If startRow plus numRows exceeds the number of rows in tableRef, or if startRow is greater than the number of rows in tableRef, the returned range contains the maximum possible rows.
OR
- tableRef: the reference of the table whose header row(s) you want to get.
- wk header rows: to indicate that you want to get header rows
In that case, the command returns a row range containing the repeated header rows (if passed, the numRows parameter is ignored). The command returns Null if there are no defined header rows.
Example 1
You want to set a specific background color for the first two rows of a table, and modify the border of the third row:
var $wpTable;$wpRange;$wpRow1;$wpRow2;$wpRow3;$wpRow4;$wpRow5;$rows;$rows2 : Object
$wpRange:=WP Text range(WParea;wk start text;wk end text)
$wpTable:=WP Insert table($wpRange;wk append)
$wpRow1:=WP Table append row($wpTable;"Paul";"Smith";25)
$wpRow2:=WP Table append row($wpTable;"John";"Richmond";40)
$wpRow3:=WP Table append row($wpTable;"Mary";"Trenton";18)
$wpRow4:=WP Table append row($wpTable;"Christopher";"Lee";53)
$wpRow5:=WP Table append row($wpTable;"Henry";"Cartier";42)
$rows:=WP Table get rows($wpTable;1;2)
WP SET ATTRIBUTES($rows;wk background color;0x00E0F0FF)
$rows2:=WP Table get rows($wpTable;3)
WP SET ATTRIBUTES($rows2;wk border style;wk solid)
WP SET ATTRIBUTES($rows2;wk border width;4)
Example 2
To get a range of rows starting from the 10th to the end:
WP Table get rows(tableRef;10;MAXLONG)
Example 3
You want to retrieve the rows a user has selected:
var $userSelection;$rows : Object
$userSelection:=WP Selection range(myWPArea)
$rows:=WP Table get rows($userSelection)
Example 4
The following example:
- Gets the first two rows of the first table in WParea.
- Sets them as header rows.
- Sets their text color to white and their background color to black.
var $table;$range : Object
$table:=WP Get elements(WParea;wk type table)[0] // Select the first table in WParea
WP SET ATTRIBUTES($table;wk header row count;2) // Set the first two rows as header rows
$range:=WP Table get rows($table;wk header rows) // Get the header rows defined above
WP SET ATTRIBUTES($range;wk text color;"white";wk background color;"#000") // Set text and background color for the header rows
See also
WP Insert table
WP Table append row
WP Table get cells
WP Table get columns