Conditionally formatting text strings from Excel using python
问题 I would like to format a spreadsheet (xls or xlsx) so that any cells containing a word or ending with a certain string are formatted by filling the background with a specific color. For example, if the cell contains the word 'deleted', fill it black and paint the text white. if the cell ends with '.pf', paint the cell red. I found a similar question from several years ago that suggested the following: import xlrd import xlutils.copy inBook = xlrd.open_workbook('input.xls', formatting_info