Apply multiple filter in the same worksheet

Issue #627 resolved
MBOUP Papa Momar
created an issue

Actually it's not possible in Openpyxl to apply two or more filters in the same worksheet with worksheet.auto_filter.ref.
Ex: worksheet.auto_filter.ref = "B9:T9 D9:Q9"
So this issue is about to do this feature.
I join in attachements an example of xlsx file that contains two filters in the same worksheet. As you will see in the rows 9 and 25 containing different filter.
That's what i want to do with Openpyxl.
MBOUP Papa Momar

Comments (7)

  1. CharlieC

    I don't think there's a problem adding multiple filters: you just add more columns to the auto-filter.

    However, in this file the filters are actually stored in the data table parts that openpyxl doesn't support.

  2. MBOUP Papa Momar reporter

    Thanx to you for the reply.
    So how can i add more columns to the auto_filter? I have this code but it does'nt work :
    Can u please explain me more about your second sentence ?

  3. CharlieC

    Well, according to the specification, a worksheet can have only one range for filters:

      <autoFilter ref="B3:E8">
        <filterColumn colId="1">
    <customFilter operator="greaterThan" val="0.5"/>

    Individual filters for each column can be added to this with the column id being the zero-based index for the relevant column ('A' == 0) and vals being the values to be represented in the filter.

    In your file, however, tables have been added to the worksheet and the tables themselves contain filters. This is why you can have multiple filter ranges in the worksheet.

    However, as I initially said, openpyxl does not support tables to it is not possible to do this with openpyxl.

  4. Log in to comment