excel - Python xlsxwriter, add formatting to cell as I write them instead of bulk -
is possible apply formatting conditions write data worksheet instead of doing this:
worksheet.conditional_format('b3:k12', {'type': 'duplicate', 'format': format})
so like:
worksheet.write(cell, "yada yada yada", format=format)
yes, think possible.
you can start base format:
base = { 'num_format':'#,##0', 'font_size':'12' }
as write can use format.set_
methods change or add elements base format write data.
i typically write in loop fashion , change formatting based on columns.
example:
body = workbook.add_format(base) body.set_num_format(some_format) # number example body.set_font_name(some_format) # font example sheet.write(cell, data, body)
Comments
Post a Comment