WP Table insert rows
WP Table insert rows ( targetObj | {tableRef ; rowNumber} {; numRows} ) : Object
Parameter | Type | Description | |
---|---|---|---|
targetObj | Object | → | Range or element or 4D Write Pro document |
tableRef | Object | → | Table reference |
rowNumber | Integer | → | Row index number |
numRows | Integer | → | Number of rows to insert (default value = 1) |
Function result | Object | ← | Range of table rows |
Description
The WP Table insert rows command inserts one or several row(s) into a 4D Write Pro table.
This command supports two syntaxes:
- If you pass a targetObj as the first parameter, the command will insert the row(s) in the first table intersecting the target. targetObj can contain:
- a range, or
- an element (row / paragraph / body / header / footer / inline picture / section / subsection), or
- a 4D Write Pro document.
- If you pass both a tableRef and a rowNumber as parameters, the command will insert the row(s) in the designated table and at the specified row index. If the rowNumber is higher than the number of rows in tableRef, the rows are appended to the table rather than inserted.
The optional numRows parameter defines the number of rows to insert into targetObj or tableRef. By default, if this parameter is omitted, one row is inserted.
Result
The command returns a row range representing inserted row(s), or Null if nothing was inserted.
Example
You want to insert two rows at the end of the Invoice table:
var $row : Object
var $table;$row : Object
var $rowNum : Integer
$table:=WP Get element by ID(WParea;"Invoice") //retrieve "Invoice" table
If($table#Null)
$rowNum:=$table.rowCount+1 //add 1 to last row to designate where to insert rows
$row:=WP Table insert rows($table;$rowNum;2)
End if
will insert the two new rows at the correct location: