gspread numberFormat is not applied for a date

36 Views Asked by At

With gspread, I'm trying to apply date formatting for a column, but it doesn't see to work. Here's a minimal example:

sh = gc.create("new")
ws = sh.get_worksheet(0)
ws.update("A1", "20/10/2023")
ws.format(
    "A1",
    {
        "numberFormat": {
            "pattern": "dd-mmm-yyyy",
            "type": "DATE",
        },
        "textFormat": {"bold": True},
    },
)

Looking at the results in Google Sheets, the text formatting is applied, but not the date format. Any idea?

1

There are 1 best solutions below

0
mrgou On

Turns out a specific option needs to be add to the update method:

value_input_option=ValueInputOption.user_entered

The option is imported as: from gspread.utils import ValueInputOption