Autofilter - Multiple values(array of terms) on a single column

Hi.
How can I use an array of terms for filtering a single column of a spreadsheet? I tried using autofilter.AddFilter, but after autofilter,refresh() only the last filter become active, the rest of filtering terms being also checked.
Thank you!

Hi Ionut,

Thanks for your posting and using Aspose.Cells.

To better understand your requirements, please provide us your source Excel file and the expected output Excel file. You can create both of them using Microsoft Excel and attach here for our reference.

We will look into your requirement and provide you a sample code to achieve your desired output using Aspose.Cells APIs.

I just need an example of using this autofilter with multiple terms for the same column.
My excel is created by a script with data filtered from a database.

The filter is implemented like below:

asposeXL.AutoFilter autofilter = myBook.Worksheets[1].ListObjects[0].AutoFilter;
autofilter.AddFilter(8, “Outfitting”);
autofilter.Refresh();
if (radioButton4.Checked)
{
foreach (string activity in ActivitiesType)
{
autofilter.AddFilter(3, activity);
autofilter.Refresh();
}
}

After running this sequence, filters are checked, but excel worksheet is populated with data filtered only by the last term (last value in “ActivitiesType” array). If I open the list of on of the columns and press “OK” the sheed suddenly populates with data filtered.

See attached xls.

Hi Ionut,

Thanks for providing us the further information and using Aspose.Cells.

After some investigation, we were able to observe this issue as you described with your provided output Excel file namely 801.xlsx. Although, filter has been applied with multiple values but it shows the data of last value only and when OK is clicked, Excel populates all of the data.

Kindly also give a try to latest version: Aspose.Cells
for .NET v8.3.1.4
and see if it resolves your issue.

If your problem still occurs with the latest version, then please provide us simple runnable sample console application project replicating this issue with the latest version so that we could run it at our end and log this issue in our database for a fix.

Thanks for your cooperation.

Please see attached project. It still not working.

Hi Ionut,

Thanks for your sample project and using Aspose.Cells.

I have run your project and generated the output Excel file, when I opened it, I found it is giving correct results. I have attached the output Excel file and screenshot showing the output in Microsoft Excel for your reference. It means, Aspose.Cells is working fine.

Yes, in some situations, not in every situation !!
Anyway, thank you. I’ll keep searching.

Hi Ionut,

Thanks for your posting and using Aspose.Cells.

In case, you encounter this issue again, please provide us a replicable sample code with sample data so that we could fix this issue in our future versions for your needs.

Thanks for your cooperation.