Search code examples
pandasgoogle-sheetsgoogle-sheets-apigspread

save style to google spreadsheet


I'm writting dataframes to google spreadsheets with gspread_dataframe, gspread. I'm trying to assign a yellow background to cells depends on the values with pandas style. https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html Is there a way to save the assigned background color to the google spreadsheet too? Thanks


Solution

  • With this one, you can use gspread_formatting

    from gspread_formatting import *
    
    bGYellow = cellFormat(backgroundColor=color(1, 1, 0))
    
    format_cell_range(worksheet, 'A1:E1', bGYellow)
    

    Please see gspread-formatting for more details