Multiple Conditional formatting rules for same cells

Issue #461 invalid
rhl84 created an issue

First of all: I've been very happy with openpyxl!

But I've encountered a problem: when opening an existing Excel file with 2 conditional formatting rules using the same cells, only the one with highest priority is preserved by openpyxl.

I have attached an Excel file showing this. In each of the sheets, there are two conditional formatting rules:
- If cell in col. G = "nee", the row turns purple
- If cells in cols. H, I, J and K = "ja", the row turns green.

Comments (9)

  1. CharlieC

    As the sheets are empty of values I'm not sure if I see the problem. Any row with "nee" in the G column is purple regardless of what's in cells H-K and that's true for the original file as for one saved by openpyxl. The rules look the same in the Excel management GUI. You've submitted the bug for 2.3 which hasn't been released yet. What version are you using?

  2. rhl84 reporter

    Sorry, I wasn't sure of the version, I thought I had the most recent version (which I assumed to be 2.3..), but actually I'm only using 1.8.5.

    The sheets are empty since this is a template file, which is going to be filled. And indeed, the 'purple' rule is preserved. However, whenever I open the file in openpyxl the 'green' rule is not.

    Might it just be that I'm working in a (way) too old version?

  3. Hamza Khchine

    Hi All,
    The bug not reproduced with the default version of openpyxl.
    The two rules work without errors.

  4. rhl84 reporter

    I've just reproduced it with this code:

    from openpyxl import Workbook, load_workbook
    def main():
        _exfile = 'Format.xlsx'
        _outputfile = 'testerxl.xlsx'
        book = load_workbook(_exfile)
    if __name__ == "__main__":

    The new file only has the rule with the highest priority, it seems..

  5. rhl84 reporter

    Thank you, you were right, it has been fixed in 2.2.

    I should've checked this myself, sorry :)
    Thanks again!

  6. Log in to comment