可以检索打开的 Google 文档文档的元素,从
\n\nDocumentApp.openById(doc_id, folder_id)\nRun Code Online (Sandbox Code Playgroud)\n\n但文档上的评论是通过 Drive API 检索的Comments.list
在包含 2 条注释的文档上运行此命令:一条在图像上,一条在段落中的单词上,这表明虽然文本锚定注释可以,但图像不会返回条目context:
"content": "test comment on text",\n "deleted": false,\n "status": "open",\n "context": {\n "type": "text/html",\n "value": "some text the comment is placed on"\n },\n "anchor": "kix.xxxxxxxxxxx1",\nRun Code Online (Sandbox Code Playgroud)\n\n "content": "test comment on an image",\n "deleted": false,\n "status": "open",\n "anchor": "kix.xxxxxxxxxxx2",\nRun Code Online (Sandbox Code Playgroud)\n\n其中xxxxxxxxxxx1/xxxxxxxxxxx2是唯一的锚点 ID 后缀,以及kixGoogle“专有”锚点/编辑器系统的前缀(正如 Steven Bazyl 在“管理评论和讨论”开发者指南页面的视频中所描述的那样)。
\n“锚点基本上告诉我们该评论适用于文档中的哪个位置。因为这是我们的格式(在 …
我试图找出评论属于 Google 电子表格中的哪个单元格。从API我得到
{'kind': 'drive#comment',
...
'anchor': '{"type":"workbook-range","uid":0,"range":"285502171"}',
...}
Run Code Online (Sandbox Code Playgroud)
然而我无法将整数值转换为电子表格中range适当的单元格范围(即)。A1:A2根据文档,锚应该看起来完全不同。根据文档,我假设应该有一个type 的区域类matrix。workbook-range首先,文档中没有提及。
我无法弄清楚如何使用Google Apps脚本访问Google文档中的注释。查看API参考,我仅找到CommentSection类,但已将其标记为已弃用。寻求帮助。谢谢。
桑杰
我有一个带有三张幻灯片的谷歌幻灯片台,我想为每张幻灯片添加评论。我可以使用 for 循环到达幻灯片(工作表中的总行数与幻灯片总数相同,我使用的幻灯片是第二张幻灯片以后。所以我的循环没有问题)
// open the slide using slide id
var s=SlidesApp.openById(a.getId())
for(let r=2; r<=4; r++){
// get the current slide
var currentSlide=s.getSlides()[r-1];
var fileId = currentSlide.getObjectId();
var slideUrl = a.getUrl()+"#slide=id."+fileId;
var slideId = getIdFromUrl(slideUrl);
var comment = {'content':'hi'};
Drive.Comments.insert(comment, slideId);
}
function getIdFromUrl(url) { return url.match(/[-\w]{25,}/); }
Run Code Online (Sandbox Code Playgroud)
此代码有效,但它将注释添加到文件而不是单个幻灯片中。(*注意 - 要使此代码正常工作,我们必须在应用程序脚本中的服务中启用云端硬盘。)如何将评论添加到各个幻灯片。