如何扩展Google应用程序脚本类 [英] How to extend Google apps script classes

查看:107
本文介绍了如何扩展Google应用程序脚本类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在一个脚本中扩展课程表,并且当它试图执行下面的代码时,Sheet没有定义:

I am trying to extend class Sheet in a script and i get Sheet is undefined when it tries to execute the folowing:

Sheet.prototype.moveColumn = function(SourceIndex, DestinationIndex){
  var source = this.getRange(1, SourceIndex, ss.getLastRow(), 1).getValues()
  var move = SourceIndex-DestinationIndex>0 ? sheet.getRange(1, DestinationIndex,  ss.getLastRow(), SourceIndex-DestinationIndex).getValues() : sheet.getRange(1, SourceIndex, ss.getLastRow(), DestinationIndex-SourceIndex).getValues();
  sheet.getRange(1, DestinationIndex, source.length, 1).setValues(source);
  SourceIndex-DestinationIndex>0 ? sheet.getRange(1, DestinationIndex+1, move.length, move[0].length).setValues(move) : sheet.getRange(1, SourceIndex, move.length, move[0].length);
  return this
}


推荐答案

您无法扩展Google类的原型。您可以在问题跟踪器中找到相关评论,问题708

You cannot extend prototypes of Google's Classes. You can find comments about this on the issue tracker, Issue 708

这篇关于如何扩展Google应用程序脚本类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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