0

It would seems I am stuck with a consistant "Server Encountered an Error" when I am trying in my function to use the insertRows() call or insertRowsAfter() and then do a getRange() operation call within the range of cells newly created (like changing the font weight, or setvalues in the new cells).

When I call my function I always get a google "Server Encountered and Error". When I call my function in debug mode, step by step: no errors!!! I have no error logs showing when doing a catch.

I tried a Spreadsheet.flush() call before the getRange() operation, not helping.

  function test() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sdebtcal = ss.getSheetByName('Debt');  
    var max_rows = sdebtcal.getMaxRows(); // sheet set with only 5 rows to test
    sdebtcal.insertRowsAfter( max_rows , 20); // adding 20 rows 
    sdebtcal.getRange(max_rows+5, 1, 2, 1).setFontWeight('bold'); // trying to setFontWeight in the new range of cells
  }

我不得不说我尝试了一个空白电子表格,但我没有问题。仅使用我当前的大型电子表格。虽然测试表很小(要测试 2 行!)。此外,我没有达到电子表格上的任何最大单元格限制。

有人有提示吗?带有大型电子表格的电子表格脚本 API 可能存在错误?

问候,

4

1 回答 1

0

我发现如果在脚本执行时电子表格没有在客户端打开,我在使用 InsertRowsBefore() 和 InsertRowsAfter() 时遇到的问题就会消失。因此,如果您可以从不同电子表格中的脚本或定时触发器中插入行,那么您可能会发现可以解决该问题。祝你好运!

这是我在 GAS 论坛上发表的一篇文章的链接,如果您想了解更多详细信息,并且您可能也有兴趣在问题 1270中添加关于它的评论。

于 2012-05-04T09:02:15.697 回答