Aller au contenu principal
Version: Next

VP CREATE TABLE

Historique
ReleaseModifications
19 R8Support of theme options: bandColumns, bandRows, highlightFirstColumn, highlightLastColumn, theme
19 R7Support of allowAutoExpand option
19 R6Ajout

VP CREATE TABLE ( rangeObj : Object ; tableName : Text {; source : Text} {; options : cs.ViewPro.TableOptions} )

ParamètresTypeDescription
rangeObjObject->Objet plage
tableNameText->Nom de la table
sourceText->Nom de la propriété du Data context à afficher dans la table
optionscs.ViewPro.TableOptions->Options supplémentaires

Description

The VP CREATE TABLE command creates a table in the specified range. Vous pouvez créer une table dans une plage de cellules pour faciliter la gestion et l'analyse d'un groupe de données connexes. A table typically contains related data in rows and columns, and takes advantage of a data context.

In rangeObj, pass the cell range where the table will be created.

In tableName, pass a name for the table. Le nom doit :

  • être unique dans la feuille
  • inclure au moins 5 caractères
  • ne pas inclure d'espaces ou commencer par un nombre

In source, you can pass a property name of a data context to display its data in the table. This binds the table to the data context. When the data context is updated, the data displayed in the table is updated accordingly. The source property must contain a collection of objects and each element represents a row.

  • If you don't specify a source, the command creates an empty table with the size defined in rangeObj.
  • If the specified source cannot be fully displayed in the document, no table is created.

In the options parameter, pass an object of the cs.ViewPro.TableOptions class that contains the table properties to set.

Within the options object, the tableColumns collection determines the structure of the table's columns. The length of the tableColumns collection must be equal to the range column count:

  • When the column count in rangeObj exceeds the number of columns in tableColumns, the table is filled with additional empty columns.
  • When the column count in rangeObj is inferior to the number of tableColumns, the table displays a number of columns that match the range's column count.

If you pass a source but no tableColumn option, the command generates columns automatically. In this case, rangeObj must be a cell range. Otherwise, the first cell of the range is used. When generating columns automatically, the following rules apply:

  • If the data passed to the command is a collection of objects, the property names are used as column titles. Par exemple :
([{ LastName: \"Freehafer\", FirstName: \"Nancy\"},{ LastName: \"John\", FirstName: \"Doe\"})

Here the titles of the columns would be LastName and FirstName.

  • If the data passed to the command is a collection of scalar values, it must contain a collection of subcollections:

    • La collection de premier niveau contient des sous-collections de valeurs. Chaque sous-collection définit une ligne. Passez une collection vide pour sauter une ligne. The number of values in the first subcollection determines how many columns are created.
    • The subcollections' indices are used as column titles.
    • Chaque sous-collection définit les valeurs des cellules de la ligne. Values can be Integer, Real, Boolean, Text, Date, Null, Time or Picture. A Time value must be an a object containing a time attribute, as described in VP SET VALUE.

This only works when generating columns automatically. You cannot use a collection of scalar data with the tableColumns option.

Exemple

Pour créer une table en utilisant un contexte de données :

// Définir un contexte de données
var $data : Object

$data:=New object()
$data.people:=New collection()
$data.people.push(New object("firstName"; "John"; "lastName"; "Smith"; "email"; "johnsmith@gmail.com"))
$data.people.push(New object("firstName"; "Mary"; "lastName"; "Poppins"; "email"; "marypoppins@gmail.com"))


VP SET DATA CONTEXT("ViewProArea"; $data)

// Définir les colonnes de la table
var $options : cs.ViewPro.TableOptions

$options:=cs.ViewPro.TableOptions.new()
$options.tableColumns:=New collection()
$options.tableColumns.push(cs.ViewPro.TableColumns.new("name"; "First name"; "dataField"; "firstName"))
$options.tableColumns.push(cs.ViewPro.TableColumns.new("name"; "Last name"; "dataField"; "lastName"))
$options.tableColumns.push(cs.ViewPro.TableColumns.new("name"; "Email"; "dataField"; "email"))

// Créer une table à partir de la collection "people"
VP CREATE TABLE(VP Cells("ViewProArea"; 1; 1; $options.tableColumns.length; 1); "ContextTable"; "people"; $options)

Voici le résultat :

Voir également

VP Find table
VP Get table column attributes
VP Get table column index
VP INSERT TABLE COLUMNS
VP INSERT TABLE ROWS
VP REMOVE TABLE
VP RESIZE TABLE
VP SET DATA CONTEXT
VP SET TABLE COLUMN ATTRIBUTES
VP SET TABLE THEME