【发布时间】:2022-01-22 10:32:24
【问题描述】:
我试图找出一个 excel 工作表是否包含一个数组(在第四个工作表的任何单元格中)。该变量是用户输入,如下所示:
$j = Read-Host "Enter sensor serial number"
$Sens_name = @("$j")
它尝试查找输入的行为如下所示,其中 $EPRB2_loca 是 excel 文件的位置,包括文件扩展名:
#Checking in EPRB 2 file
$Excel = New-Object -ComObject Excel.Application
$Workbook = $Excel.Workbooks.Open("$EPRB2_loca")
$WorkSheet = $Workbook.Sheets.Item(4)
$WorkSheet.Name
$EPRB2_file = $WorkSheet.Cells.Find("$Sens_name")
if ($EPRB2_file.HasArray -eq $false)
{
$EPRB2_file = $null
}
有人可以帮我弄清楚为什么当我知道它包含数组时它不会显示为它包含数组吗?
【问题讨论】:
-
你在下面的回答是否意味着你有这个工作?我使用 Doug Finke 的
ImportExcel模块取得了一些成功。
标签: excel powershell worksheet