We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose cells for java filter with contains option

I am working on the autofilter option in aspose cells for java .

AutoFilter autoFilter = worksheet.getAutoFilter();
autoFilter.setRange("A1:D1");
autoFilter.filter(1, "Student");

This is working fine. But for the 3rd column I want to filter with "contains" option . In excel we can click on text filter and click on contains option, then we can filter with the text which contains some sub text. For example if I want to filter all the text which contains "school" : (result might be like aaa school, bbb school, xxx school etc) How can I do that in aspose cells for java?

Hi,

Thanks for your posting and using Aspose.Cells

Please see the following sample code that creates the filter as you have shown in your Book1.xlsx file. I have also attached the source excel file used in this code and output excel file generated by it for your reference. If you open the output excel file, you will find it same as Book1.xlsx.

I have used the latest version: Aspose.Cells for Java v8.7.2.1 to test this code.

Java

Workbook wb = new Workbook(“source.xlsx”);

Worksheet ws = wb.getWorksheets().get(0);

ws.getAutoFilter().custom(0, FilterOperatorType.EQUAL, “zzz”);
ws.getAutoFilter().setRange(“F1:F8”);
ws.getAutoFilter().refresh();

wb.save(“output.xlsx”);