计算特定工作表上的评论数 [英] Count the number of comments on a particular worksheet

查看:87
本文介绍了计算特定工作表上的评论数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码为我提供了一张纸上的注释数量,而不是注释.我需要一张纸上的评论数.每张纸上的评论数显示在工作表选项卡上,但是我有很多选项卡,我想以编程方式获取该数字.

My code below gives me the number of notes on a sheet, not comments. I need the number of comments on a sheet. The number of comments per sheet is shown on the worksheet tab, but I have many tabs and I want to get this number programmatically.

range 中有用于注释的方法,但是有没有处理注释的不推荐使用的方法. 人们将此称为问题.

There are methods for notes in the class range but there are no non-deprecated methods that deal with comments. People have made this an issue.

function getCommentNumber() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  var range = sheet.getRange("A1:A12");
  var results = range.getNotes();
  Logger.log(results);
  var commentNumber = 0;
  for ( i in results) {
    if (results[i] != ""){
    commentNumber += 1;
     }
  }
  Logger.log(commentNumber);
 }

是否可以计算特定工作表上的评论数量?

Is there a way to count up the number of comments on a particular worksheet?

可以将注释转换为笔记然后转换回吗?

Could comments be converted to notes then converted back?

是否可以通过编程方式从工作表标签上显示的数据中获取评论编号?

Is there a way to programmatically get the comment number from the data that is shown on the worksheet tab?

推荐答案

您可能想通过启用Google Drive API来尝试?

You may want to try by enabling Google Drive API?

function countComments() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var commentsList = Drive.Comments.list(sheet.getId());
  Logger.log(commentsList.items.length);
}

以上代码将为您提供与电子表格相关的所有注释.获得列表后,您可以处理响应以检查您感兴趣的评论. 需要从Resources -> Advanced Google services

Above code will give you all the comments associated with the spreadsheet. Once you get the list you can process the response to check what comments you are interested in. Google Drive API needs to be enabled from Resources -> Advanced Google services

这篇关于计算特定工作表上的评论数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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