I am generating an excel file from Python using XlsxWriter.
I'm trying to "layer" formatting depending on the cell value. In pseudocode:
for rowId in rows:
for colId in cols:
value = table.loc[rowId, colId]
if value < 0:
# Make font red
for rowId in rows:
for colId in cols:
value = table.loc[rowId, colId]
if value > 1e6:
# Make bg orange
for rowId in rows:
for colId in cols:
value = table.loc[rowId, colId]
if value is False:
# Make bg purple
In practice I'm finding it hard to layer formatting without either creating a format object for each combination of attributes, or creating a format object per cell.
Any ideas of how this could be achieved?