Skip to main content
Version: Next

WP Table get columns

WP Table get columns ( targetObj ) | ( tableRef ; startCol {; numCols} ) : Object

ParameterTypeDescription
targetObjObjectRange or element or 4D Write Pro document
tableRefObjectTable reference
startColIntegerPosition of first column
numColsIntegerNumber of columns to get
Function resultObjectNew table range containing selected columns

Description

The WP Table get columns command returns a new cell range object containing the selection of columns from targetObj or tableRef (defined by startCol and numCols).

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 columns can be retrieved, the command returns Null.

OR

  • tableRef - the reference of the table whose selection of columns you want to get.
  • startCol - points to the first table column to return, and
  • (optional) numCols - specifies how many columns to return. If numCols is omitted, the single startCol column is returned.

If startCol plus numCols exceed the number of columns in tableRef, or if startCol is greater than the number of columns in tableRef, the returned range contains the maximum possible columns.

Example 1

You want to modify the attributes of the last two columns of a table:

 var $wpTable;$wpRange;$wpRow1;$wpRow2;$wpRow3;$wpRow4;$wpRow5;$cols : Object
 $wpRange:=WP Create 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)
 
 $cols:=WP Table get columns($wpTable;2;2)
 WP SET ATTRIBUTES($cols;wk background color;0x00E0E0E0;wk text color;"red";wk height;"36pt";wk text align;wk center)

Result:

Example 2

To get a range of columns starting from the 10th to the end:

 WP Table get columns(tableRef;10;MAXLONG)

Example 3

You want to retrieve the columns a user has selected:

 var $userSelection;$columns : Object
 
 $userSelection:=WP Selection range(myWPArea)
 
 $columns:=WP Table get columns($userSelection)

See also

WP Table get cells
WP Table get rows