excel - 如何从谷歌表格单元格中读取评论?

标签 excel python-3.x google-apps-script google-sheets gspread

我想从谷歌表格中的注释单元格中访问数据。我已经完成了一些工作,并且能够访问单元格中的值。

from oauth2client.service_account import ServiceAccountCredentials
import json

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('WorkSheet001-4d8ce6dbd79f.json', scope)

gc = gspread.authorize(credentials)
wks = gc.open_by_url('https://docs.google.com/spreadsheets/d/1ME7WatXOmSEytwu7Qxem-a6BzCew36RKmD7KdhKMwbA/edit#gid=0').sheet1

print(wks.cell(2, 2).value)

print(wks.get_all_records())


我想要来自注释单元格的数据。想要访问时间、日期和单元格上的评论等数据
[{'name': 'Naresh', 'technology': 'Php'}, {'name': 'kuldeep', 'technology': 'python'}]

最佳答案

您可以尝试使用 Sheetfu 库来完成此类任务,特别是使用 table 模块。

from sheetfu import Table

spreadsheet = SpreadsheetApp('path/to/secret.json').open_by_id('<insert spreadsheet id here>')
data_range = spreadsheet.get_sheet_by_name('people').get_data_range()

table = Table(data_range, notes=True)

for item in table:
    if item.get_field_note('name'):
        # DO SOMETHING IF THERE IS A NOTE ON FIELD NAME
        item.set_field_note('name', 'your note')

table.commit()

关于excel - 如何从谷歌表格单元格中读取评论?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55809706/

相关文章:

google-apps-script - 如何公开分发Google Apps脚本(处理Gmail邮件)?

javascript - Google Apps onEdit 事件 - event.source 未定义

excel - 使用带有两个参数的 Countif

Python单词计数器对单词是否被引号括起来敏感?

python - 如果不存在并基于 2 列条件,则在 df pandas 中添加行

google-apps-script - 谷歌脚本: Sending Hangout Messages using Script

vba - 通过合并现有行创建新行 excel

excel - 如何在 VBA 项目中创建新的 Excel 工作表并创建给定名称

C# VSTO Excel 自动筛选值和空白

python - 在 python 的 azure 函数中安装 google api 时出错