Hi, I have to filter some excel rows based on on cell value like if the coloumn value,ID 1, i need to display all rows ID is not equal to 1
is there anything like this??
excelRange.AutoFilter(9, cellvalue !="1", Excel.XlAutoFilterOperator.xlFilterValues, Type.Missing, true);

Leon DRank #851 · 2.6K reputationPosted Sep 7, 2021, 9:08 PM EDT
Hi,
You can install Free Spire.XLS library to achieve this.
First, install it via nuget.
https://www.nuget.org/packages/FreeSpire.XLS/
Second, add the following code:
using Spire.Xls; using Spire.Xls.Collections; namespace CustomFilter { class Program { static void Main(string[] args) { Workbook workbook = new Workbook(); workbook.LoadFromFile(@"test.xlsx"); Worksheet sheet = workbook.Worksheets[0]; AutoFiltersCollection filters = sheet.AutoFilters; filters.Range = sheet.Range; for (int col = 0; col < sheet.LastColumn; col++) { filters.CustomFilter(col, Spire.Xls.Core.Spreadsheet.AutoFilter.FilterOperatorType.NotEqual, 1); } filters.Filter(); workbook.SaveToFile("output.xlsx", ExcelVersion.Version2013); } } }Ganesan CRank #369 · 6.8K reputationPosted Sep 7, 2021, 10:55 PM EDT
Sujeet RamanRank #1,329 · 1.3K reputationPosted Sep 8, 2021, 11:00 AM EDT
Sujeet RamanRank #1,329 · 1.3K reputationPosted Sep 8, 2021, 11:02 AM EDT