【问题标题】:How to read comments from google sheet cells?如何从谷歌表格单元格中读取评论?
【发布时间】:2019-04-23 10:57:45
【问题描述】:

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

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'}]

【问题讨论】:

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


【解决方案1】:

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

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()

【讨论】:

    猜你喜欢
    • 2017-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    • 1970-01-01
    • 1970-01-01
    • 2012-08-17
    • 2022-01-28
    相关资源
    最近更新 更多