WP Table append row
WP Table append row ( tableRef ; ...value ) : Object
WP Table append row ( tableRef ; valueColl ) : Object
Paramètres | Type | Description | |
---|---|---|---|
tableRef | Object | → | Référence du tableau |
value | Text, Number, Time, Date, Picture, Object | → | Valeur(s) à définir dans la ligne |
valueColl | Collection | → | Collection de valeurs à définir dans la ligne |
Résultat | Object | ← | Objet plage ligne |
Description
El comando WP Table append row añade una fila a la tabla tableRef, la llena con value(s) o una colección valueColl, y devuelve el objeto de rango de filas correspondiente.
The command supports two syntaxes:
-
Usando valores como parámetros: Añade tantas celdas en la fila como valores proporcionados en el parámetro o parámetros value. Puede pasar cualquier número de valores de diferentes tipos.
-
Usando una colección de valores (valueColl): Llena la fila con valores de la colección valueColl. Cada elemento de la colección corresponde a una célula en la fila.
En ambas sintaxis se admiten los siguientes tipos de valores: Texto, Número, Hora, Fecha, Imagen y Objeto (fórmulas o fórmulas con nombre que devuelven un elemento de fila).
The default cell alignment will depend on the value type:
- text: left aligned
- pictures: centered
- other types (numbers, date, and time): right aligned
- 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.
El comando devuelve la nueva fila como un objeto de rango de filas.
Exemple 1
Vous voulez créer une table vide et ajouter plusieurs lignes de différentes tailles. Vous pouvez écrire :
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!")
Exemple 2
Vous voulez créer une table vide et ajouter une ligne en utilisant une 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)
Exemple 3
Dans une application de facturation, vous souhaitez créer un tableau automatiquement rempli avec les lignes de facture correspondantes :
var $wpTable;$wpRange : Object
$wpRange:=WP Text range(4DWPArea;wk start text;wk end text)
$wpTable:=WP Insert table($wpRange;wk append) //créer le tableau
// ajouter la ligne d'en-tête
$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)
//simplement appliquer à la sélection
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))
//ajouter une ligne de pied de page
$row:=WP Table append row($wpTable;"Total:";Sum([INVOICE_LINES]Quantity);"";"";Sum([INVOICE_LINES]Total))
//formater le tableau
$range:=WP Table get columns($wpTable;1;5)
WP SET ATTRIBUTES($range;wk width; "80pt")
WP SET ATTRIBUTES($wpTable;wk font size;10)