在PowerShell中循环工作表时,如何忽略隐藏的工作表?
假设我有一个像这样的循环
$excel = New-Object -ComObject excel.application
$excel.visible = $False
$excel.displayalerts=$False
$workbook = $excel.Workbooks.Open($ExcelPath)
foreach ($ws in $workbook.Worksheets)
{
#do stuff
}
答案 0 :(得分:1)
if($ws.Visible -eq 0) {
# Hidden
} else {
# Visible
}