Chaining Conditional Formatting with xlsxwriter

Viewed 40

I am trying to effectively chain two conditional formats together, so conditional on whether one cell is positive or negative, the icon set used in another cell would be flipped. So currently I have:

 for row in range(4, cond_length + 1, 3):
        ws.conditional_format(
            f"P{row}:AM{row}",
            {
                'type': 'icon_set',
                'icon_style':'3_traffic_lights_rimmed',
                'icons':[
                    {'criteria': '>', 'type':'number', 'value':0},
                    {'criteria': '=', 'type':'number', 'value':0},
                    {'criteria': '<', 'type':'number', 'value':0},
                ]
            },
        )

This works wonderfully if I want to disregard another parameter. What I would like to do is something like this:

for (row, col) in itertools.product(
        list(range(2, cond_length, 3)), list(range(index_length, index_length + 25))
    ):
        cell = xl_rowcol_to_cell(row, col)
        cell_below = xl_rowcol_to_cell(row + 1, col)
        ws.conditional_format(
            f"{cell_below}:{cell_below}",
            {
                "type": "formula",
                "criteria": f'={cell} = "False"',
                "format": icon_conditional_formatter,
            },
        )

where icon_conditional_formatter is an icon set.

I have read through documentation exhaustively and can't seem to find anything that would work.

0 Answers
Related