2
我希望通过API v4隐藏谷歌电子表格中的给定列,但我很努力地这样做。Google电子表格API v4 - 隐藏列
有没有人知道是否有可能并设法做到这一点?
我们在AppScript中有一个dedicated method这样做。 我会惊讶的发现,这个功能在API v4中不可用。
Thx!
我希望通过API v4隐藏谷歌电子表格中的给定列,但我很努力地这样做。Google电子表格API v4 - 隐藏列
有没有人知道是否有可能并设法做到这一点?
我们在AppScript中有一个dedicated method这样做。 我会惊讶的发现,这个功能在API v4中不可用。
Thx!
是的,有。这不是非常简单。
这里是隐藏5列的一个示例:
import httplib2
from apiclient.discovery import build
credentials = get_credentials() ## See Google's Sheets Docs
http = credentials.authorize(httplib2.Http())
service = build('sheets', 'v4', http=http)
spreadsheet_id = '#####################'
sheet_id = '#######'
requests = []
requests.append({
'updateDimensionProperties': {
"range": {
"sheetId": sheet_id,
"dimension": 'COLUMNS',
"startIndex": 4,
"endIndex": 5,
},
"properties": {
"hiddenByUser": True,
},
"fields": 'hiddenByUser',
}})
body = {'requests': requests}
response = service.spreadsheets().batchUpdate(
spreadsheetId=spreadsheet_id,
body=body
).execute()