【发布时间】:2013-04-29 18:54:55
【问题描述】:
我正在尝试通过 PowerShell 使用 Excel 高级过滤器,但我没有任何运气。我可以通过运行以下代码成功使用自动过滤器:
$rangetofilter = $worksheet2.usedrange.select
$excel.selection.autofilter(2, "TestFilter")
但是,我不明白如何正确地将 Range.AdvancedFilter Method 中给出的语法转换为 PowerShell 可以接受的语法。比如我试过
$excel.selection.AdvancedFilter("xlFilterInPlace", "", "", "TRUE")
但我收到以下错误:
Exception calling "AdvancedFilter" with "4" argument(s): "AdvancedFilter method of
Range class failed"
At line:1 char:32
+ $excel.selection.AdvancedFilter <<<< ("xlFilterInPlace","","","TRUE")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
那么有没有办法通过 PowerShell 运行 Excel 高级过滤器?
我找到了这个:Delete duplicate rows in excel using advanced filter,但它也不起作用...
【问题讨论】:
标签: excel powershell filter