我是power shell脚本的新手我在excel中自动过滤后无法获得任何行。
谷歌搜索没有多大帮助。有人在这方面提供帮助
$xl = New-Object -comobject Excel.Application
$xl.Visible = $True
$xl.DisplayAlerts = $False
$wb = $xl.Workbooks.Open("C:\Users\Dinesh\Downloads\jtrac-export2")
$ws = $wb.Worksheets.Item(1)
$ws.activate()
$xl.Range("A1:G100").Select()
$rn = $xl.Range("A1:G100").Select()
sleep 7
$A = "Service Request"
$L = "Incident"
$G = "2 - High"
$H = "3 - Medium"
$COUNTA = 3
#$xlFilterValues = 7
$xl.selection.AutoFilter(6,$L)
$counter = $ws.UsedRange.SpecialCells(12).Rows.Count
Write-Host $counter
sleep 10
$xl.selection.AutoFilter(6,$A)
$counter = $ws.UsedRange.SpecialCells(12).Rows.Count
Write-Host $counter
______________________________________________________________________
结果为8,但在excel中,过滤后的行数为21,总行数为28(没有过滤)
$xl.selection.AutoFilter(6,$L)
$counter = $ws.UsedRange.SpecialCells(12).Rows.Count
Write-Host $counter
结果为1,但在excel中,过滤后的行数为7,总行数为28(没有过滤)
$xl.selection.AutoFilter(6,$A)
$counter = $ws.UsedRange.SpecialCells(12).Rows.Count
Write-Host $counter