在电子表格中创建注释时,Google Drive API会忽略锚参数 [英] Google Drive API ignores anchor parameter when creating comments in a spreadsheet

查看:54
本文介绍了在电子表格中创建注释时,Google Drive API会忽略锚参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在查看Google Drive API v3 在工作表上创建评论.

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

anchor字段是根据其文档创建的

每个锚点要求:

Each anchor requires:

r —字符串ID,指示创建此锚的文件版本.使用通过revisions.get获取的修订版ID.
a —与锚点关联的一个或多个区域.这必须是一个JSON数组,并且该数组中的对象类型是一个区域.

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.

基于此,我使用了 Revisions.list 提取所有版本并使用id作为最新modifiedTime对象的API.

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.

这就是我的有效载荷'r': '46'中出现的方式.
对于锚点a,我创建了matrix,因为其文档与我要实现的目标紧密匹配

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.

因此,我想使用row=1, column=1在单元格中创建注释.这就是我到达有效负载'a': [{'matrix': {'r': 1, 'c': 1}}]}其余部分的方式.

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

现在,当我使用API​​ 资源管理器时, a>,呼叫成功

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

该单元格没有评论

因此,以某种方式发布了评论,但不遵守anchor位置.

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 can let your users insert comments and replies in shared files and carry on discussion threads in the comments. You can support these features in your app to create an environment where users can share files and edit them collaboratively.

您需要创建一个应用来处理这些评论.例如,'a': [{'matrix': {'r': 1, 'c': 1}}]}.(如果已设置)可以通过您自己的电子表格应用程序(处理文档以及注释系统)进行检索,以在A1处显示虚拟标记.

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.

还请参见随附的YouTube视频.尽管Google表格应用程序使用相同的评论系统,但官方应用程序使用的ID标记是专有的,并且没有透露Google表格应用程序如何解释该ID.但是,您可以使用已经创建的ID来回复锚定在特定单元格(例如A2)上的评论.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆