按名称查找列
动词:findColumnByName
可从以下位置获取: <Enterprise>
通过搜索列名来查找数据表中列的位置。
语法
findColumnByName --dataTable(DataTable) --name(String) (Numeric)=value
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | 描述 |
|---|---|---|---|---|
| --dataTable | 数据表 | 必需的 | 数据表 | 要在其中查找列的数据表。 |
| --name | 列名 | 必需的 | 文本 | 包含要执行搜索的列名的文本。此参数不区分大小写,因此搜索列时,接受小写或大写字母。 |
输出
| 脚本 | 设计器 | AcceptedTypes | 描述 |
|---|---|---|---|
| 值 | 列 | 成员 | 返回数据表中与列位置对应的索引号。 |
示例
使用按名称查找列命令在指定数据表中查找“城市”列的位置,并返回其索引号。
defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
defVar --name columnIndex --type Numeric
// Download the following file to execute the command.
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet --entiretable --hasheaders excelTable=value
findColumnByName --dataTable ${excelTable} --name City columnIndex=value
logMessage --message "Column position found: ${columnIndex}" --type "Info"
excelClose --file ${excelFile}
// This example returns the following output:
// Column position found: 2
要正确处理上述脚本,需要下载该文件并在打开 Excel 文件命令的文件参数中输入其路径。