0

我有一个脚本,它从例程中获取一个数组,然后想将它写入电子表格中的一个范围。当我尝试将数组写入范围时收到以下错误消息。

Incorrect range width, was 53 but should be 25 (line 120, file "ScrubRowsFromVolDBSpreadsheet")

编写的脚本如下所示:

var cleanedRows=cleanData(source, source_sheet_name,cleanDataSheet);

  var numCleanedRows=cleanedRows.length;

  var numCleanedCols=cleanedRows[0].length;

  Logger.log("numCleanedRows = "+numCleanedRows);

  Logger.log("numCleanedCols = "+numCleanedCols);

  var tempRange=ssOut.getSheetByName("ScrubbedRows").getRange(2,1,numCleanedRows,numCleanedCols);

  Logger.log("tempRangeRows="+tempRange.getHeight());

  Logger.log("tempRangeCols="+tempRange.getWidth());

  //

  tempRange.setValues(cleanedRows);  //// LINE 120

执行期间生成的记录器条目如下所示:

[13-10-17 16:43:07:888 PDT] numCleanedRows = 100

[13-10-17 16:43:07:888 PDT] numCleanedCols = 25

[13-10-17 16:43:07:905 PDT] tempRangeRows=100

[13-10-17 16:43:07:906 PDT] tempRangeCols=25

是什么导致了这种脱节?如何将数组写入范围?

4

1 回答 1

1

您只检查第一行的长度。也许cleanedRows 有一些包含更多项目(列)的行?

于 2013-11-13T17:33:51.443 回答