How do you resolve a “The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues” error

后端 未结 1 964
心在旅途
心在旅途 2020-11-27 23:32

I am getting this error:

\"The parameters (number[]) don\'t match the method signature for SpreadsheetApp.Range.setValues.\"

in

相关标签:
1条回答
  • 2020-11-28 00:19

    setValues accepts(and getValues() returns):

    • 1 argument of type:
    • Object[][] a two dimensional array of objects

    It does NOT accept a 1 dimensional array. A range is always two dimensional, regardless of the range height or width.

    If A1:A2 is the range, then corresponding values array would be like:

    • [[1],[3]]

    Similarly, A1:B1 would be

    • [[1,2]]

    A1:B2 would be

    • [[1,2],[3,4]]

    Notice how the two dimension provides direction and that it is always a 2D array, even if the height or width of the range is just 1.

    Solution:

    Push a 1D array to make the output array 2D.

    Snippet:

    vWriteTable.push([""]);
    

    Related Answer:

    What does the range method getValues() return and setValues() accept?

    0 讨论(0)
提交回复
热议问题