Add Row
Verb: addRow
Available from: <Standard>
Adds a new blank or filled row to an existing data table.
Syntax
addRow [--valuesmapping(String)] [--valueset(StringDictionary<String>)] --dataTable(DataTable)
Inputs
| Script | Designer | Required | AcceptedTypes | Description |
|---|---|---|---|---|
| --valuesmapping | Values mapping | Optional | Text | The following fields are set:
|
| --valueset | Value set | Optional | String Dictionary<Text>, List<Text>, List<Primitives> | Values to add to each column of a table by the new row. The order of the values entered in the data types below is as follows:
These are the types of scalar data: |
| --dataTable | Data table | Required | Data Table | Data table that should receive the new row. |
Example
Example 1: Adds a new row to the data table from a list with the values "Google" and "Sao Paulo" in the "Company" and "City" columns, respectively.
defVar --name excelFile --type Excel
defVar --name tableExcel --type DataTable
defVar --name ListCompanyCity --type List --innertype String --value "[Google,São Paulo]"
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders tableExcel=value
logMessage --message "Table contents before the \"Add Row\":\r\n${tableExcel}\r\n\r\n" --type "Info"
// Add the values of a list to this row, respecting the column orders.
addRow --valueset ${ListCompanyCity} --dataTable ${tableExcel}
logMessage --message "Table contents after adding new rows:\r\n${tableExcel}\r\n\r\n" --type "Info"
excelClose --file ${excelFile}
//Returns the following output:
//Table contents before "Add Row":
//IBM Corporation, Toronto
//Microsoft Corporation, São Paulo
//IBM Corporation, Armonk
//
//Table contents after adding new rows:
//IBM Corporation, Toronto
//Microsoft Corporation, São Paulo
//IBM Corporation, Armonk
//Google, São Paulo
Example 2: Adds a new row with the value "Oracle" in the "Company" column of the data table from the value mapping.
defVar --name excelFile --type Excel
defVar --name tableExcel --type DataTable
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders tableExcel=value
logMessage --message "Table contents before the \"Add Row\":\r\n${tableExcel}\r\n\r\n" --type "Info"
// Adds, through value mapping, the "Oracle" information to the "Company" column.
addRow --valuesmapping "Company=Oracle" --dataTable ${tableExcel}
logMessage --message "Table contents after adding new rows:\r\n${tableExcel}\r\n\r\n" --type "Info"
excelClose --file ${excelFile}
//Returns the following output:
//Table contents before "Add Row":
//IBM Corporation, Toronto
//Microsoft Corporation, São Paulo
//IBM Corporation, Armonk
//
//Table contents after adding new rows:
//IBM Corporation, Toronto
//Microsoft Corporation, São Paulo
//IBM Corporation, Armonk
//Oracle
Example 3: Adds a new row to the data table from a string dictionary with the value "IBM" in the "Company" column.
defVar --name excelFile --type Excel
defVar --name tableExcel --type DataTable
defVar --name dictionaryStringCompany --type "StringDictionary" --innertype String
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders tableExcel=value
logMessage --message "Table contents before the \"Add Row\":\r\n${tableExcel}\r\n\r\n" --type "Info"
//Adds the "Company" key and "IBM" value to a text dictionary, and then adds that dictionary value to the new line.
strDictAdd --key Company --value IBM Corporation --dictionary ${dictionaryStringCompany}
addRow --valueset ${dictionaryStringCompany} --dataTable ${tableExcel}
logMessage --message "Table contents after adding new rows:\r\n${tableExcel}\r\n\r\n" --type "Info"
excelClose --file ${excelFile}
//Returns the following output:
//Table contents before "Add Row":
//IBM Corporation, Toronto
//Microsoft Corporation, São Paulo
//IBM Corporation, Armonk
//
//Table contents after adding new rows:
//IBM Corporation, Toronto
Microsoft Corporation, São Paulo
//IBM Corporation, Armonk
//,
//IBM Corporation,
Remarks
If you need to enter data in the row to be added to the data table, you can only use one of the Values mapping or Value set parameters, not being able to assign values to both of them simultaneously. If these are empty, the new line will be blank.