title: Xlsxwriter change format colour based on if statement
body: <p>I have a python script that creates a report.</p>
  
  <p>I would like to apply colour a to row a and then colour b to row b, ...
  I could create a variable <code>formatA = workbook.add_format({'bg_color': 'red'})</code> and <code>formatB = workbook.add_format({'bg_color': 'blue'})</code> and so on.</p>
  
  <p>However, I think it would be easier to do <code>format = workbook.add_format({'bg_color': 'red'})</code> and then when I loop through the rows I want to use, do format.set_bg_color('blue') and apply it.</p>
  
  <p>However, it does not change the background colour and only applies blue to every row.</p>