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

标签 google-sheets google-sheets-api

我想通过 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/

相关文章:

python - oauth googlesheet python共享失败

javascript - 谷歌应用可视化可以吗?具有缩放选项的时间轴

google-apps-script - 向 onOpen 条目对象中的函数添加参数

c# - 如何在 C# 中的 Google Sheets API v4 中格式化标题行?

java - 访问谷歌电子表格API以使用过滤器获取数据

python - 如何下载带有 Gspread 的 Google Docs excel 表并在本地访问数据(A1 表示法)?

javascript - 如何将实时 Google 表格数据嵌入到 Google 协作平台中

google-sheets - Google 电子表格 : conditional formatting with custom formula based on values from different sheet

google-sheets - 如何获得最后 3 个结果的滚动总和,其中键值在谷歌电子表格的一列或另一列中

c# - 如何在谷歌电子表格中间插入一行