2

I am applying filters for multiple columns via ClosedXML; however, only the last one is applied. Those filters work when they are alone. How can I apply all of them? I found similar question here ClosedXML Excel filter rows by values in multiple columns

But there is no correct answer.

Here is the code:

var wb = new XLWorkbook(loc1);
var ws2 = wb.AddWorksheet("Итоги");
var ws1 =  wb.Worksheet(1);
var rowCount = ws1.RowsUsed().Count();
ws1.Range(ws1.Cell(3,1), ws1.LastCellUsed()).SetAutoFilter().Column(48).EqualTo("1");
ws1.Range(ws1.Cell(3,1), ws1.LastCellUsed()).SetAutoFilter().Column(8).NotContains("CLS");
ws1.Range(ws1.Cell(3,1), ws1.LastCellUsed()).SetAutoFilter().Column(2).BeginsWith("I");
wb.SaveAs(loc1);

Here, only filter for Column 2 is applied, but I want all filters being applied. Is there a way to do so? Thank you for your answers.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
D Ace
  • 21
  • 2

1 Answers1

0

It is not a direct solution, but you can apply Multiple Excel formulas using IF(OR(condition1, condition2,...),0,1) and then use only filter to get 1 or 0

Bakytzhan
  • 15
  • 2