【问题标题】:I want to know editor Name or Modified Name我想知道编辑名称或修改名称
【发布时间】:2021-09-21 18:39:03
【问题描述】:

我想知道表格中的编辑者或修改过的人名。

like...A2 单元格为空或一些数据,如果任何一个修改后的 A2 单元格我想知道在 B2 或 C2 列等其他列中修改的用户名...。

我想要编辑单元格 A2 的编辑名称,编辑名称应该反映在其他单元格 (B2,C2) 中

【问题讨论】:

    标签: google-apps-script google-sheets-formula google-sheets-api


    【解决方案1】:

    您可以使用onEdit(e) 检查编辑是否在特定范围内完成,例如列或行,然后将更改连同日期一起记录到另一张表中。在 Stackoverflow 的某个地方,您应该会发现有人已经这样做了,但为了让您开始,这里是 reference to the trigger 和一个简单的启动器:

     function onEdit(e){
    
      // Assuming you only want to track changes in column A
      const targetCol = 1 
    
      const row = e.range.getRow();
      const col = e.range.getColumn();
    
      // Return if not the right column
      if(col != targetCol) return
      
      // log the change, along with the date and user to Sheet
      const oldValue = e.oldValue
      const newValue = e.value
      const today = new Date().toISOString().substr(0,10)
      const user = e.user.getEmail()
    
      // Assuming you do not want to track if no change occured
      if( oldValue == newValue ) return
    
      // Log the entry to Sheets
      const logEntry = [today, username, oldValue, newValue]
      const targetSheetName = "Changes"
    SpreadsheetApp.getActive().getSheetByName(targetSheetName).appendRow(logEntry)
    
     }
    

    【讨论】:

    • 感谢您的帮助,但我无法理解错误,请您帮忙解决这个问题.... 12:55:09 PM Error TypeError: Cannot read property 'changeType' of undefined onEdit @Code.gs:3
    • 对不起,我的错误。属性changeType 用于函数onEdit(event),因此必须手动安装。我从代码中删除了它,然后它就可以工作了。
    • 错误:- TypeError:无法读取未定义的属性“范围”
    • 您应该在工作表中进行编辑,然后在您编辑单元格时自动运行此功能。您不能按 Apps 脚本运行它。
    • 示例文件名为“Ruff”,工作表名为 sheet1, sheet2.sheet3 我可以在三张工作表中得到相同的结果吗?特别是(谁正在编辑从'I2到整个I列'的单元格,编辑器名称应该反映在其他单元格列'P2到整个P列'
    猜你喜欢
    • 2020-12-21
    • 1970-01-01
    • 2017-11-28
    • 2016-09-12
    • 2011-11-19
    • 1970-01-01
    相关资源
    最近更新 更多