ale*_*rjh 4 javascript google-apps-script
我试图在脚本中扩展Sheet类,并且在尝试执行以下操作时得到Sheet是未定义的:
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
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,只有谷歌,而不是它的用户,可以做到这一点,特别是在GAS(谷歌Apps脚本),可以延长{不属于本地JavaScript类,这是类由谷歌},所以可以做一些如“ 表 .prototype.MyMethod = function(..){..}”,其中Google定义的这些类在每个{功能组件下的“类”下定义,作为正式GAS参考中的第一个“日历”} 。
__proto__
.MyMethod = ..'得到'TypeError:无法将未定义的属性“ MyMethod”设置为“(class)@ 26d5fab1”。 归档时间: |
|
查看次数: |
2208 次 |
最近记录: |