Xlwt conditional formatting

I saw several posts saying that you cannot perform conditional formatting with xlwt , but they were pretty old. I was curious if this developed?

I searched around noon. Also, if I will not write it directly from xlwt , can I create a .xls file containing one cell with the conditional format that I want, and xlrd to read this format and paste it into the sheet that I am aiming then use xlwt ?

+6
source share
2 answers

xlrd and xlwt still do not support conditional formatting. xlrd does not read, xlwt does not write.

There is a new amazing module called xlsxwriter . It supports conditional formatting out of the box. The project is active, the documentation is pretty good. In addition, there are many examples .

Here is an example:

 from xlsxwriter.workbook import Workbook workbook = Workbook('test.xlsx') worksheet = workbook.add_worksheet() worksheet.write('A1', 49) worksheet.write('A2', 51) format1 = workbook.add_format({'bold': 1, 'italic': 1}) worksheet.conditional_format('A1:A2', {'type': 'cell', 'criteria': '>=', 'value': 50, 'format': format1}) workbook.close() 
+8
source

It is true that xlswriter makes formatting quite simple, but I think it cannot be used to add tps data, which I consider to be a big drawback.

-1
source

Source: https://habr.com/ru/post/943473/


All Articles