This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
WP Insert table

WP Insert table 


 

WP Insert table ( targetObj ; mode {; rangeUpdate {; nbCols {; nbRows}}} ) -> Function result 
Parameter Type   Description
targetObj  Object in Range or element or 4D Write Pro document
mode  Longint in Insertion mode
rangeUpdate  Longint in Range update mode
nbCols  Longint in Number of columns to set in the table
nbRows  Longint in Number of rows to set in the table
Function result  Object in Table object

The WP Insert table command inserts a new table in the targetObj according to the specified insertion mode and returns the corresponding new table object. Optionally, you can pass a rangeUpdate parameter as well as a predefined number of columns and rows in nbCols and nbRows.

In targetObj, pass:

  • a range, or   
  • an element (table / paragraph / body / header / footer / inline picture / section / subsection), or   
  • a 4D Write Pro document.

Note: If targetObj is a table, the newly inserted table will replace or be inserted before or after it, depending on the mode used. Inserting a table within another table is not possible.

In the mode parameter, pass one of the following constants to indicate the insertion mode to be used for the table in the document:

Constant Type Value Comment
wk append Longint 2 Insert contents at end of target
wk prepend Longint 1 Insert contents at beginning of target
wk replace Longint 0 Replace target contents
  • If targetObj is a range, you can use the optional rangeUpdate parameter to pass one of the following constants to specify whether or not the inserted table is included in the resulting range:
     
    Constant Type Value Comment
    wk exclude from range Longint 1 Inserted contents not included in updated range
    wk include in range Longint 0 Inserted contents included in updated range (default)

    If you do not pass a rangeUpdate parameter, by default the inserted table is included in the resulting range.
     
  • If targetObj is not a range, rangeUpdate is ignored.

You can pass in nbCols and nbRows the number of columns and rows to define in the table. By default, if nbCols and nbRows are omitted, a new table with 0 column and 0 row is created. You will then be able to add these elements using the WP Table append row command.

The command returns the new table as a table object, that you can pass thereafter to the other WP table commands. The table is created with default font, border, and color attributes that you can customize using the WP SET ATTRIBUTES command.

Example  

In a blank document, you want to add a new table with 3 columns and 2 rows:

 C_OBJECT($WPRange;$WPTable)
 $WPRange:=WP Text range(WParea;wk start text;wk end text)
 $WPTable:=WP Insert table($WPRange;wk append;wk exclude from range;3;2)

Result:



See also 

WP Table append row
WP Table get rows

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language
Number: 1473

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v16 R4
Modified: 4D v17 R5

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v20 R7)