在电子表格中创建评论时,Google Drive API 会忽略锚参数 [英] Google Drive API ignores anchor parameter when creating comments in a spreadsheet
问题描述
所以,我正在研究 Google Drive API
但是,注释是针对整个电子表格进行的,而不是针对单元格
虽然单元格没有评论
因此,以某种方式发布了评论,但不尊重 anchor
位置.
我的方法遗漏了什么导致这种意外行为,我该如何解决?
您可以让您的用户在共享文件中插入评论和回复并继续评论中的讨论主题.您可以在您的应用中支持这些功能,以创建一个用户可以共享文件和协作编辑文件的环境.
您需要创建一个应用来处理这些评论.例如,'a': [{'matrix': {'r': 1, 'c': 1}}]}.
,如果设置了,可以被你自己的电子表格应用程序检索到(它处理文档以及评论系统)以在 A1 处显示一个虚拟标记.
另请在此处查看随附的 YouTube 视频.尽管 Google 表格应用程序使用相同的评论系统,但官方应用程序使用的 id 标记是专有的,并没有透露 Google 表格应用程序如何解释该 id.但是,您可以使用已创建的 id 回复锚定到某个单元格(例如 A2)的评论.
So, I am looking at Google Drive API v3 for creating comments on the sheet.
As I follow along, I am trying the API with their own explorer.
My payload for creating the comment is following
{
"content": "This is a comment - 02",
"anchor": "{'r': '46', 'a': [{'matrix': {'r': 1, 'c': 1}}]}"
}
The anchor
field is created based on their documentation
Each anchor requires:
r — A string ID that indicates for which revision of the file this anchor was created. Use the revision id retrieved with revisions.get.
a — The region or regions associated with the anchor. This must be a JSON array, and the type of object in that array is a region.
Based on this, I used Revisions.list API to fetch all the versions and took the id
for the object where the modifiedTime
is the latest.
That's how in my payload 'r': '46'
appears.
For anchor a
, I created the matrix
because their documentation matches closely with what I am trying to achieve
matrix
A location in a matrix-like structure. Use to define row and columns in spreadsheet documents or any other documents which have a row or column structure.
So, I want to create a comment in a cell with row=1, column=1
. That's how I arrived at the remaining part of the payload 'a': [{'matrix': {'r': 1, 'c': 1}}]}
.
Now, when I execute this API using the API explorer, the call succeeds
However, the comment is made on the entire spreadsheet, instead of the cell
While the cell has no comment
So, somehow the comments are posted, but the anchor
location is not honored.
What am I missing in my approach which is causing this unexpected behavior and how can I fix it?
You need to create a app to process those comments. For example, 'a': [{'matrix': {'r': 1, 'c': 1}}]}.
, if set, can be retrieved by your own spreadsheet app(which processes the document as well as the comment system) to display a virtual marker at A1.
Also see the attached YouTube video there. Although Google sheets app uses the same comment system, the id marker used by the official app is proprietory and it's not revealed how Google sheets app interprets that id. However, you can use the already created id to reply to a comment anchored to a certain cell such as A2.
这篇关于在电子表格中创建评论时,Google Drive API 会忽略锚参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!