[C#VSTO Excel自动过滤值和空格

问题描述 投票:0回答:2

我在C#中具有以下自动过滤器代码,以过滤VSTO中的excel列。目前,我正在检查第11列,并根据值“永无库存”进行过滤,但我也想对任何空白单元格进行过滤。如何调整以下代码,以根据值永无库存和空白进行过滤。当前,过滤器中不包含空格。

xlrange.AutoFilter(11, "Never Out Of Stock", Microsoft.Office.Interop.Excel.XlAutoFilterOperator.xlAnd,Type.Missing, true);
c# excel vsto autofilter
2个回答
1
投票

来自documentation

使用“ =”查找空白字段,或使用“ <>”查找非空白字段。

所以您的代码应该是:

xlrange.AutoFilter(11, "Never Out Of Stock", Microsoft.Office.Interop.Excel.XlAutoFilterOperator.xlAnd, "=", true);

0
投票
xlrange.AutoFilter(11, "Never Out Of Stock", Microsoft.Office.Interop.Excel.XlAutoFilterOperator.xlOr, "=", true);
© www.soinside.com 2019 - 2024. All rights reserved.