I have this excel file, how to search cell have "-->" character then fill color for it I try research but all are solution for DataFrame is available
Asked
Active
Viewed 512 times
0
-
1did you try anything? What did you try? What's wrong with DataFrame solution you found? conversely why can't you just use conditional formatting in Excel? – JeffUK Jan 05 '21 at 09:43
-
https://stackoverflow.com/a/30486164/5386938 – Jan 05 '21 at 09:43
-
@JeffUK I tried use Conditional Formatting but don't know how to set value for value property .. I just saw value is number. Ex: `worksheet.conditional_format('A1', {'type': 'cell', 'criteria': 'greater than', 'value': 5, 'format': red_format})` – Trần Đình Khanh Jan 05 '21 at 09:46
-
I don't know what I need type for value property - @JeffUK – Trần Đình Khanh Jan 05 '21 at 09:48
-
1In Excel itself you can also check for substrings with: `=ISNUMBER(SEARCH("-->", E2))` – Swier Jan 05 '21 at 09:52
1 Answers
0
In order to check the presence of any character in the string, use the SEARCH function in the ISNUMBER function.
=ISNUMBER(SEARCH("-->", E2))
This will return True if E2 contains "-->".
And then you can fill color in excel sheet's cell.
After that use PatternFill to color cell as follows:
pattern_fill = PatternFill(patterntype = 'solid', fgcolor = 'C64747')
worksheet['E2'].fill = pattern_fill
patterntype, fgcolor data can be used as per requirement.

Apoorv Gunjan Pathak
- 65
- 6