I'm using this code to update the background color of a range of cells in a google sheet:
from pygsheets import Workbook, Color
gc = pygsheets.authorize(service_file='path/to/credentials.json')
workbook = gc.open('spreadsheet_name')
worksheet = workbook.worksheet_by_title('Sheet1')
cell_range = worksheet.range('E2:J37')
for row in cell_range:
for cell in row:
cell.color = (0.8, 0.8, 0.8)
But the program is extremely slow. After it does a chunk of cells, it will hang for several minutes before continuing, and as a result for a range this size it takes like 20 minutes, somewhat undermining the point of automating this. Is there a way to speed this up? From what I can tell there isn't a way to set the formatting for a range of cells directly, necessitating this iterative approach.