添加行
将空白行或填充行添加到现有数据表。
命令可用性: 本地 IBM RPA SaaS 和 IBM RPA
脚本语法
IBM RPA 的专有脚本语言的语法与其他编程语言类似。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。
addRow [--valuesmapping(String)] [--valueset(StringDictionary<String>)] --dataTable(DataTable)
输入参数
下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。
| 设计器方式标签 | 脚本方式名称 | 必需的 | 接受的变量类型 | Description |
|---|---|---|---|---|
| 数据表 | dataTable |
Required |
Data Table |
已评估的数据表。 |
| 值映射 | valuesmapping |
Optional |
Text |
设置了以下字段: “参数”:要将新行插入其中的列的名称。 “值”:要插入到新行中的值。 |
| 值集 | valueset |
Optional |
String Dictionary<Text>, List<Text>, List<Primitives> |
输入要设置为列和行对的值。 请参阅 标量数据的 types 以获取更多信息。 |
标量数据的 types
下表显示了可用于 type 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 |
|---|---|
| 布尔值 | Boolean |
| 字节 | Byte |
| 日期时间 | DateTime |
| 日期 | Date |
| 货币 | Money |
| 数字 | Numeric |
| 电话号码 | PhoneNumber |
| 安全字符串 | SecureString |
| 文本 | String |
| 时间范围 | TimeSpan |
示例
示例 1:使用添加行命令,通过文本列表来添加已填充的行。
defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name ListCompanyCity --type List --innertype String --value "[IBM,Armonk]"
// Enter the file path to the excel file
excelOpen --file "excelFile.xlsx" --savechanges excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable excelTable=value
// Adds a row using a list of texts
addRow --valueset ${ListCompanyCity} --dataTable ${excelTable}
logMessage --message "Table contents after adding new rows:\r\n${excelTable}\r\n\r\n" --type "Info"
excelClose --file ${excelFile}
// Displays the data table in the console
示例 2:使用添加行命令将填充的行映射添加到列。
defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name ListCompanyCity --type List --innertype String --value "[IBM,São Paulo]"
// Enter the file path to the excel file
excelOpen --file "excelFile.xlsx" --savechanges excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable excelTable=value
// Adds the value "IBM" to the "Company" column.
addRow --valuesmapping "Company=IBM" --dataTable ${tableExcel}
logMessage --message "Table contents after adding new rows:\r\n${tableExcel}\r\n\r\n" --type "Info"
excelClose --file ${excelFile}
// Displays the data table in the console