File tree 3 files changed +37
-1
lines changed
3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ properties that can be applied and the equivalent object method:
278
278
+------------+------------------+----------------------+------------------------------+
279
279
| | Right color | ``'right_color' `` | :func: `set_right_color() ` |
280
280
+------------+------------------+----------------------+------------------------------+
281
- | Misc. | Cell border | ``'quote_prefix' `` | :func: `set_quote_prefix() ` |
281
+ | Other | Cell border | ``'quote_prefix' `` | :func: `set_quote_prefix() ` |
282
282
+------------+------------------+----------------------+------------------------------+
283
283
| | Checkbox format | ``'checkbox' `` | :func: `set_checkbox() ` |
284
284
+------------+------------------+----------------------+------------------------------+
Original file line number Diff line number Diff line change @@ -110,3 +110,34 @@ def test_create_file_with_boolean_and_format(self):
110
110
workbook .close ()
111
111
112
112
self .assertExcelEqual ()
113
+
114
+ def test_conditional_format_with_boolean (self ):
115
+ """Subtest for conditional format value as a Python boolean."""
116
+
117
+ workbook = Workbook (self .got_filename )
118
+ worksheet = workbook .add_worksheet ()
119
+
120
+ cell_format1 = workbook .add_format ({"checkbox" : True })
121
+
122
+ worksheet .write ("E9" , False , cell_format1 )
123
+
124
+ cell_format2 = workbook .add_format (
125
+ {
126
+ "font_color" : "#9C0006" ,
127
+ "bg_color" : "#FFC7CE" ,
128
+ }
129
+ )
130
+
131
+ worksheet .conditional_format (
132
+ "E9" ,
133
+ {
134
+ "type" : "cell" ,
135
+ "format" : cell_format2 ,
136
+ "criteria" : "equal to" ,
137
+ "value" : False ,
138
+ },
139
+ )
140
+
141
+ workbook .close ()
142
+
143
+ self .assertExcelEqual ()
Original file line number Diff line number Diff line change @@ -2936,6 +2936,11 @@ def conditional_format(
2936
2936
if "criteria" in options and options ["criteria" ] in criteria_type :
2937
2937
options ["criteria" ] = criteria_type [options ["criteria" ]]
2938
2938
2939
+ # Convert boolean values if required.
2940
+ if "value" in options :
2941
+ if isinstance (options ["value" ], bool ):
2942
+ options ["value" ] = str (options ["value" ]).upper ()
2943
+
2939
2944
# Convert date/times value if required.
2940
2945
if options ["type" ] in ("date" , "time" ):
2941
2946
options ["type" ] = "cellIs"
You can’t perform that action at this time.
0 commit comments