1

In the text file, I create a list for user input their condition, in order to filter out these four value in the excel file.

abc=<>10,<>20,<>30,<>40

And into program, I wrote this to read the list:

try
{
    abc = dic["abc"];
    if (abc == null || abc.Trim() == "")
    {
        MessageBox.Show("abc can't be empty!");
        this.Close();
    }
}
catch (KeyNotFoundException)
{
    MessageBox.Show("abc can't be found in Config.txt!");
    this.Close();
}

And in the final steps, I want to add the list into string list in my source code, then use autofilter function to filter the excel

string[] abc_list = abc.Split(',');

newSheet.Range["$A:$OO"].AutoFilter(12, abc_list, Excel.XlAutoFilterOperator.xlFilterValues);

And this is the error I got:

23:49:16
Line No.: 5778
System.Runtime.InteropServices.COMException (0x800A03EC): _AutoFilter method of Range class failed
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Microsoft.Office.Interop.Excel.Range.AutoFilter(Object Field, Object Criteria1, XlAutoFilterOperator Operator, Object Criteria2, Object VisibleDropDown)

But I found that it is not working. Can anyone tell me why?

Thanks.

  • Does this answer your question? [HRESULT: 0x800A03EC on Worksheet.range](https://stackoverflow.com/questions/7099770/hresult-0x800a03ec-on-worksheet-range) – quaabaam Sep 20 '21 at 16:28
  • Hi quaabaam. Nope, the problem caused by the special character <>, which I want to set the filter NOT equal to. But the program cannot accept this character – Jason Wong Sep 20 '21 at 16:36

1 Answers1

0

I found that change .xlFilterValue to .xlOr can solve this question.