按名称查找列

动词: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 文件命令的文件参数中输入其路径。

另请参阅

  • 添加列
  • 添加行
  • 检查列在表中是否存在
  • 复制行
  • 复制表
  • 删除列
  • 删除行
  • 过滤表
  • 查找表单元格出现项
  • 获取单元格内容
  • 获取列名
  • 获取列结构
  • 获取 HTML 表
  • 基于 JSON 生成表
  • 映射表行
  • 移动表行
  • 对表排序
  • 更新行
  • 将表写入文件