Saltar al contenido principal
Versión: 20 R8 BETA

WP Table append row

WP Table append row ( tableRef ; value {; value2 ; ... ; valueN} ) : Object
WP Table append row ( tableRef ; valueColl ) : Object

ParámetrosTipoDescripción
tableRefObjectTable reference
valueText, Number, Time, Date, Picture, ObjectValue(s) to set in the row
valueCollCollectionCollection of values to set in the row
ResultadoObjectRow range object

Descripción

he WP Table append row commandT appends one row to the tableRef table, fills it with value(s) or a valueColl collection, and returns the corresponding row range object.

The command supports two syntaxes:

  • Using values as parameters: Adds as many cells in the row as there are values provided in the value parameter(s). You can pass any number of values of different types.

  • Using a collection of values (valueColl): Fills the row with values from the valueColl collection. Each element of the collection corresponds to a cell in the row.

    The following value types are supported in both syntaxes: Text, Number, Time, Date, Picture and Object (formulas or named formulas returning a row element).

The default cell alignment will depend on the value type:

  • text: left aligned
  • pictures: centered
  • other types (numbers, date, and time): right aligned
Notas
  • Array type values are not supported.
  • Ensure the number of values or the size of the collection matches the number of cells in the table to avoid unexpected results.

The command returns the new row as a row range object.

Ejemplo 1

You want to create an empty table and append several rows of different sizes. Puede escribir:

 var $wpTable;$wpRange;$wpRow1;$wpRow2;$wpRow3 : 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;"New!")

Ejemplo 2

You want to create an empty table and append a row using a collection :

$table:=WP Insert table(WParea; wk replace; wk include in range)

$row:=WP Table append row($table; "Reference"; "Date"; "Time"; "rnd 1"; "rdn 2")
WP SET ATTRIBUTES($row; wk background color; "lightgrey")

$colItems:=[]
$colItems.push("KX-825")
$colItems.push(Formula(Current date))
$colItems.push(Formula(String(Current time; HH MM SS)))
$colItems.push(Formula(Random))
$colItems.push({name: "RND NUMBER"; formula: Formula(Random)})

$row:=WP Table append row($table; $colItems)

Ejemplo 3

In a billing application, you want to create a table automatically filled with related invoice lines:

 var $wpTable;$wpRange : Object

$wpRange:=WP Text range(4DWPArea;wk start text;wk end text)

$wpTable:=WP Insert table($wpRange;wk append) //create the table

// add the header row
$row:=WP Table append row($wpTable;"Name";"Quantity";"Unit Price";"Discount Rate";"Total")
WP SET ATTRIBUTES($row;wk font bold;wk true;wk text align;wk center)

//simply apply to selection
APPLY TO SELECTION([INVOICE_LINES];WP Table append row($wpTable;[INVOICE_LINES]ProductName;[INVOICE_LINES]Quantity;[INVOICE_LINES]ProductUnitPrice;[INVOICE_LINES]DiscountRate;[INVOICE_LINES]Total))

//add a footer row
$row:=WP Table append row($wpTable;"Total:";Sum([INVOICE_LINES]Quantity);"";"";Sum([INVOICE_LINES]Total))

//format the table
$range:=WP Table get columns($wpTable;1;5)
WP SET ATTRIBUTES($range;wk width;"80pt")
WP SET ATTRIBUTES($wpTable;wk font size;10)

Ver también

WP Insert table
WP Table get rows