简体   繁体   English

使用getvalues时Google Apps脚本发生致命错误

[英]Google apps script fatal error while using getvalues

Getting error "The action you're trying to perform is causing a fatal error and cannot be performed" on this line- 在此行收到错误消息“您尝试执行的操作导致致命错误,无法执行”

sheet.getRange(m, k, enD, 1).setValues(sheet.getRange(m, k, enD, 1).getValues()); sheet.getRange(m,k,enD,1).setValues(sheet.getRange(m,k,enD,1).getValues());

My code has been running without errors for a week but since yesterday I am getting this error randomly. 我的代码已经运行了一周没有任何错误,但从昨天开始,我就随机出现此错误。 Sometime it works sometime it doesn't. 有时它起作用,有时却不起作用。 I don't wish to disclose the calculations and that's why I am using this. 我不想透露这些计算,这就是为什么我要使用它。

Any idea why this is happening? 知道为什么会这样吗? I tried reducing 'enD' values from 40s to 10s or 20s. 我尝试将“ enD”值从40s减少到10s或20s。 Doesn't help. 无济于事。 Tried splitting the code - read values using getValues() first and then write using setValues but again getting error on getValues() part. 尝试拆分代码-首先使用getValues()读取值,然后使用setValues进行写入,但再次在getValues()部分得到错误。

I tried this simple test script to check how it could work and I get this log : 我尝试了这个简单的测试脚本来检查它如何工作,并得到以下日志:

3.141592653589793  =PI()
3.14159265358979  

The script goes like this : 脚本如下所示:

function replaceFormulasByValues() {
  var ss = SpreadsheetApp.getActiveSheet();
  var sel = ss.getActiveRange();
  Logger.log(sel.getValues()+'  '+sel.getFormulas()); // show cell's content (value and formula) 
  sel.setValues(sel.getValues());// this is the same mechanism you use
  Logger.log(sel.getValues()+'  '+sel.getFormulas()); // no formulas anymore
}

So it works as expected doesn't it ? 所以它按预期工作,不是吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM