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.