After you do:
sheet.write(0, 1, 'whatevs')
Is it still possible to adjust the style of cell 0,1. The reason I am asking is that I have a list of errors I loop and I would like to color all the cells red that have an error.
I could do it when I write the cell but it will make my code a little more complex.
There is no API exposed to do it, you could look at the source code and come up with a way:
rows = ws.get_rows()
rows[0]._Row_cells[0].xf_idx = styleindex
You can get the styleindex by adding a style you created.
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
styleindex = wb.add_style(style0)
wb is a Workbook object and ws your Worksheet.
Beware: this isn't meant to be done this way, but I couldn't find another.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With