【发布时间】:2017-08-25 09:26:10
【问题描述】:
我正在尝试在列上设置日期格式,以便日期显示如下:14-Aug-2017。我就是这样做的:
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()
我希望更新 E 列中除标题单元格之外的所有单元格,因此要更新范围定义。我使用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 添加到范围定义不会改变结果。
我没有从服务返回错误,响应仅包含电子表格 ID 和空回复结构 [{}]。
我做错了什么?
【问题讨论】: