删除列

动词:deleteColumn

可从以下位置获取: <Standard>

根据列的索引或名称从数据表删除列。

语法

deleteColumn --column(String) [--getbyindex(Boolean)] --dataTable(DataTable)

输入

脚本 设计器 必需的 AcceptedTypes Description
--column 必需的 文本 要从数据表排除的列的名称或索引。
--getbyindex 使用索引 可选 BOOLEAN 启用后,将允许在数据表中从列索引删除该列。
--dataTable 必需的 数据表 从中删除列的数据表。

示例

示例 1:使用该命令删除名为“城市”的列。

defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
// Download the following file to execute the command
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
logMessage --message "Data table before excluding the \"City\" column:\r\n${excelTable}" --type "Info"
//
deleteColumn --column City --dataTable ${excelTable}
logMessage --message "Data table after excluding the \"City\" column:\r\n${excelTable}" --type "Info"
excelClose --file ${excelFile}
// The above example returns the following output:
// Table before deleting "City" column:
// Company City
// IBM Corporation, Toronto
// Microsoft Corporation, São Paulo
// IBM Corporation, Armonk
// Table after deleting "City" column:
// Company
// IBM Corporation
// Microsoft Corporation
// IBM Corporation

示例 2:使用该命令从数据表删除索引列 1。

defVar --name excelFile --type Excel
defVar --name excelTable --type DataTable
// Download the following file to execute the command
excelOpen --file "tableExcelCompanyCity.xlsx" excelFile=value
excelGetTable --file ${excelFile} --getfirstsheet  --entiretable  --hasheaders  excelTable=value
logMessage --message "Data table before deleting index column \"1\":\r\n${excelTable}" --type "Info"
// 
deleteColumn --column 1 --getbyindex  --dataTable ${excelTable}
logMessage --message "Data table after deleting index column \"1\":\r\n${excelTable}" --type "Info"
excelClose --file ${excelFile}
// The above example returns the following output:
// Data table before deleting index column "1":
// Company City
// IBM Corporation, Toronto
// Microsoft Corporation, São Paulo
// IBM Corporation, Armonk
//
// Data table after deleting index column "1":
// City
// Toronto
// São Paulo
// Armonk

下载文件


对于以上脚本的正确操作,需要下载这些文件并在打开 Excel 文件命令的文件参数中输入其路径。

备注

启用使用索引参数后,在参数中使用的值必须为数字值。

需要注意的是,列的位置从 1 开始。

另请参阅

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