0
我试图在列上设置日期格式,以便日期显示如下:14-Aug-2017
。这是我做的方式:我希望所有列E除了头部细胞的细胞更新,因此范围定义使用API和Python在Google表格中设置日期格式
requests = [
{
'repeatCell':
{
'range':
{
'startRowIndex': 1,
'startColumnIndex': 4,
'endColumnIndex': 4
},
'cell':
{
"userEnteredFormat":
{
"numberFormat":
{
"type": "DATE",
"pattern": "dd-mmm-yyyy"
}
}
},
'fields': 'userEnteredFormat.numberFormat'
}
}
]
body = {"requests": requests}
response = service.spreadsheets().batchUpdate(spreadsheetId=SHEET, body=body).execute()
。我使用http://wescpy.blogspot.co.uk/2016/09/formatting-cells-in-google-sheets-with.html和https://developers.google.com/sheets/api/samples/formatting作为此方法的基础。
但是,单元格不会使用该格式显示其内容。他们仍然处于“自动”格式,要么显示我正在存储的数字值(从1900年1月1日起的天数)或(有时)显示日期。
将sheetId添加到范围定义不会改变结果。
我没有收到服务返回的错误,并且响应只包含spreadsheetId和一个空的答复结构[{}]。
我得到什么错误?