$Filename = "檔案路徑"
$Excel = New-Object -ComObject Excel.Application
$Excel.DisplayAlerts = $false
$Workbook = $Excel.Workbooks.Open($Filename)
$Excel.Visible = $True
$Worksheet1 = $Workbook.Worksheets.item(1)
$Worksheet1.Select()
$xlFilterValues = 7 # found in MS documentation
$FL = @("未審核","已審核", "已取消")
$Range = $Worksheet1.cells.item(1,10).entirecolumn
$Range.select | Out-Null
$Excel.Selection.AutoFilter(7,$FL,$xlFilterValues))
想要使用powershell篩選Excel表 列J1 ,顯示未審核、已審核、已取消
但都會顯示無法取得類別Range的AutoFilter屬性
無法取得類別 Range 的 AutoFilter 屬性
位於 線路:13 字元:1
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
參考文章:https://stackoverflow.com/questions/22497502/powershell-script-to-filter-a-particular-item-in-excel
請求支援