@@ -180,6 +180,13 @@ def frozen_col_count(self):
180
180
"""Number of frozen columns."""
181
181
return self ._properties ["gridProperties" ].get ("frozenColumnCount" , 0 )
182
182
183
+ @property
184
+ def tab_color (self ):
185
+ """Tab color style."""
186
+ if "tabColorStyle" in self ._properties :
187
+ return self ._properties ["tabColorStyle" ]["rgbColor" ]
188
+ return None
189
+
183
190
def _get_sheet_property (self , property , default_value ):
184
191
"""return a property of this worksheet or default value if not found"""
185
192
meta = self .spreadsheet .fetch_sheet_metadata ()
@@ -1157,6 +1164,43 @@ def update_title(self, title):
1157
1164
self ._properties ["title" ] = title
1158
1165
return response
1159
1166
1167
+ def update_tab_color (self , color ):
1168
+ """Changes the worksheet's tab color.
1169
+
1170
+ :param dict color: The red, green and blue values of the color, between 0 and 1.
1171
+ """
1172
+ body = {
1173
+ "requests" : [
1174
+ {
1175
+ "updateSheetProperties" : {
1176
+ "properties" : {
1177
+ "sheetId" : self .id ,
1178
+ "tabColor" : {
1179
+ "red" : color ["red" ],
1180
+ "green" : color ["green" ],
1181
+ "blue" : color ["blue" ],
1182
+ },
1183
+ "tabColorStyle" : {
1184
+ "rgbColor" : {
1185
+ "red" : color ["red" ],
1186
+ "green" : color ["green" ],
1187
+ "blue" : color ["blue" ],
1188
+ }
1189
+ },
1190
+ },
1191
+ "fields" : "tabColor,tabColorStyle" ,
1192
+ }
1193
+ }
1194
+ ]
1195
+ }
1196
+
1197
+ response = self .spreadsheet .batch_update (body )
1198
+ self ._properties ["tabColorStyle" ] = {
1199
+ "rgbColor" : color ,
1200
+ }
1201
+ self ._properties ["tabColor" ] = color
1202
+ return response
1203
+
1160
1204
def update_index (self , index ):
1161
1205
"""Updates the ``index`` property for the worksheet.
1162
1206
0 commit comments