简体   繁体   English

使用C#在Excel中清除自动筛选

[英]Clear Autofilter in Excel using C#

I am exporting data from my WPF application to Excel successfully. 我正在将数据从WPF应用程序成功导出到Excel。 In that Excel sheet I am filtering two columns at "AM" and "AL" . 在该Excel工作表中,我在“ AM”和“ AL”过滤两列。 When I am going to reload the excel sheet the new filter values are conflicted with old filtered values. 当我要重新加载excel工作表时,新的过滤器值与旧的过滤器值冲突。

I want to clear that two columns autofilter values. 我想清除两列自动过滤值。 So can anybody give some suggestion about this problem and let me know how shall I proceed for this problem or send me some sample code for clear Autofilters for specific columns in Excel. 因此,任何人都可以对这个问题提出一些建议,并让我知道该如何处理该问题,或者向我发送一些示例代码,以便为Excel中的特定列提供清晰的自动过滤器。

Here MyCode is 这是MyCode

if (_taskPaneViewModel.TTLrecQtySelectionStart == _taskPaneViewModel.TTLrecQtyMinimum )
{
    range.AutoFilter(TTLrecQtyColumnNumber, Type.Missing, XlAutoFilterOperator.xlAnd,        Type.Missing, true);
}

Now I want to clear this autofilter in this range. 现在,我要清除此范围内的自动过滤器。 Can ANYONE tell me the solution of this problem? 任何人都可以告诉我该问题的解决方案吗? It's breaking my head. 真伤了我的头。

range.WorkSheet.AutoFilterMode = false;

Put the above statement before setting the filter using new columns. 在使用新列设置过滤器之前,请放置以上语句。
Does that help? 有帮助吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM