Search code examples
c#xlsxepplus

Possible to read filtered row data?


Scenario

  1. Having an existing Excel XLSX file with a table and data.
  2. This table is filtered. E.g. it would have 5 rows without a filter and is currently filtered to only have 3 rows visible.
  3. I want to use EPPlus to read that very filtered 10 rows from the XLSX file.

This is how the table could look like when being unfiltered:

enter image description here

And this is how the table could look like when being filtered:

enter image description here

Question

Is it possible to get only those filtered rows via EPPlus in C#?

I've searched through various issues in the EPPlus repository as well as through Google in general and did not find one single similar question/answer.

It seems that this is possible via PIA and Excel Interop, but I want to do it without any Office dependency.


Solution

  • I've also asked the question on EPPlus' GitHub page and got a working answer:

    One has to check if the ExcelRow.Hidden property is false to get only the unfiltered, visible rows.

    Example:

    if (!worksheet.Rows[rowNumber].Hidden)
    {
        // Process visible, unfiltered row.
    }