gpt4 book ai didi

google-sheets - 使用 Sheets API 调用隐藏列

转载 作者:行者123 更新时间:2023-12-04 06:34:45 31 4
gpt4 key购买 nike

我想通过 API v4 隐藏谷歌电子表格中的给定列,但我很难这样做。

有谁知道这是否可能并设法做到了?
我们在 Apps 脚本中有一个 dedicated method这样做,如果 REST API 中没有此功能,我会感到惊讶。

最佳答案

就在这里。这不是很简单。

以下是隐藏第 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()

关于google-sheets - 使用 Sheets API 调用隐藏列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40874293/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com