Copy Table

Verb: copyTable

Available from: <Standard>

Copies all data from a data table, or just its structure, returning it on a new table.

Table structure is, by definition, its rows, columns, and table styles.

Syntax

copyTable [--schemaonly(Boolean)] --dataTable(DataTable) (DataTable)=value

Inputs

Script Designer Required AcceptedTypes Description
--schemaonly Schema only Optional Boolean Allows you to copy only the structure of the data table.
--dataTable Data Table Required Data Table Source data table where data and/or structure is copied from.

Outputs

Script Designer AcceptedTypes Description
value Data Table Data Table Returns a new data table with the copy of the data and/or structure of the source table.

Example

Example 1: Copies an Excel data table, which was obtained by the command Get Excel Table, and returns its data and structure in a "DataTable" variable.

defVar --name excelTable --type DataTable
defVar --name excelTableResult --type DataTable
defVar --name excelFile --type Excel
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
//
copyTable --dataTable ${excelTable} excelTableResult=value
logMessage --message "${excelTableResult}" --type "Info"
excelClose --file ${excelFile}
// The above example returns the following output:
// Company City
// IBM Corporation, Toronto
// Microsoft Corporation, São Paulo
// IBM Corporation, Armonk

Example 2: Copies only the structure of an Excel data table and returns it in a "DataTable" variable. The Get Column Structure command gets the column names of the table whose structure was copied.

defVar --name excelTable --type DataTable
defVar --name excelTableResult --type DataTable
defVar --name excelFile --type Excel
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
//
copyTable --schemaonly  --dataTable ${excelTable} excelTableResult=value
logMessage --message "${excelTableResult}" --type "Info"
excelClose --file ${excelFile}
// The above example returns the following output:
// Company City


Download File


For the correct operation of the scripts above, it is necessary to download the file and insert its path in the File parameter of the Open Excel File command.

Remarks

The data table inserted in the Data Table parameter must be previously obtained. Below are some commands that return Data Table variables:

  • Open Excel File;
  • See Also

  • Add Column
  • Add Row
  • Check for Column Existence in Table
  • Copy Rows
  • Delete Column
  • Delete Rows
  • Filter Table
  • Find Column by Name
  • Find Table Cell Occurrences
  • Get Cell Contents
  • Get Column Name
  • Get Column Structure
  • Get HTML Tables
  • JSON to Table
  • Map Table Row
  • Move Table Rows
  • Sort Table
  • Update Row
  • Write Table to File