I'm trying to update some cell ranges with defined format, but I'm running into a problem when the ranges overlap. For example, if I have a range of cells A1:C3
and I want to set cells A2:B2
to have a green background color, and then to have them all have bold font style, the result is only the latter - the background color of the previous cells is overwritten by the bold style. If I do it in the reverse order, the cells have green background but no bold font.
I'm using pygsheets library and this is roughly how my calls work:
# wks is a worksheet object from the created spreadsheet
wks.range("A2:B2", "range").apply_format(L_GREEN_BG, fields="userEnteredFormat")
wks.range("A1:C3", "range").apply_format(BOLD, fields="userEnteredFormat")
The BOLD
and L_GREEN_BG
are cell objects initialized with a dictionary in json-like format specified by Google Sheets API to match these updates.
My question is: is there any way to not overwrite previously made changes? Doing it sequentially like this would be a lot more handy than making more complex updates to singular cells.