// Sheets · Apps Script

Fix "The parameters don't match the method signature" in Apps Script.

The parenthesized type in the error message tells you exactly what you passed. When setValues throws (number[]) or (String), you handed it a flat array or a single value instead of a 2-D array of rows. Here is the precise fix.

I am calling setValues on a range in Google Apps Script and it throws "The parameters don't match the method signature" even though my data looks correct.

The script

copy · paste · trigger
fix_setvalues_signature.gs
Apps Script
// Fix: setValues requires Object[][] (array of rows), not a flat array
function writeColumnData() {
  var sheet = SpreadsheetApp.getActiveSheet();

  // BAD: flat 1-D array — throws "parameters don't match the method signature"
  // var flat = [10, 20, 30];
  // sheet.getRange('A1:A3').setValues(flat);

  // GOOD: wrap each value as a one-element row
  var flat = [10, 20, 30];
  var grid = flat.map(function(v) { return [v]; });
  sheet.getRange('A1:A3').setValues(grid);

  // For a single cell, use setValue (singular) — no wrapping needed
  sheet.getRange('B1').setValue('done');
}

Need a variant? Gnaw writes a custom version from one sentence — fields, triggers, edge cases handled.

Walkthrough

Read the type in parentheses first

The full error reads something like: "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues." That parenthesized fragment is the diagnostic. It is not a vague complaint about your range — it is a type receipt for exactly what you passed. (number[]) means a flat number array. (String) means a bare string. (Object[]) means a 1-D array of mixed values. Every one of those is wrong because setValues accepts exactly one type: Object[][], a 2-D array where each inner array is one row.

The method enforces this because a range has rows and columns. Even a single-column range is still a grid, so the API makes no exception. Passing a flat array is the most common trigger; passing the result of a JSON.parse that returned an array of scalars is a close second.

Wrap a 1-D array into rows with map

If you have a flat array and want to write it down a column, the one-liner is flat.map(function(v) { return [v]; }). Each value becomes a one-element inner array, which satisfies the Object[][] contract. The first time I hit this error I spent ten minutes checking the range address before noticing the type receipt — the fix took two seconds once I saw it.

For writing across a single row instead of down a column, you wrap the whole array once: sheet.getRange('A1:C1').setValues([flat]). One outer array, one inner array of three values. The shape has to match the range dimensions exactly: a 3-row 1-column range needs three inner arrays of length 1; a 1-row 3-column range needs one inner array of length 3. A dimension mismatch throws a different error — "Incorrect range height" or "width" — so if you see that after fixing the 2-D wrapping, recheck your getRange address against your array dimensions.

When getValues feeds setValues and it still breaks

getValues always returns Object[][], so a round-trip through getValues and setValues should never trigger this error on its own. Where it breaks is when something in the middle flattens the structure: Array.prototype.flat(), a map that returns scalars instead of rows, JSON.stringify followed by JSON.parse, or a push into a plain array inside a loop. I keep a small guard in a utils file for this: if (!Array.isArray(data[0])) throw new Error('setValues input is not 2-D'); It surfaces the real culprit before the API does.

For a single cell, skip setValues entirely and use setValue (singular). No array needed — it takes any scalar, Date, or boolean directly. Using setValues on a 1x1 range with a value wrapped in [[...]] works too, but it is unnecessary ceremony. Reserve setValues for multi-cell ranges.

Want a custom version?

Describe your sheet and the rule you want. Gnaw writes the Apps Script — fields, triggers, edge cases — in one shot.

FAQ

4 questions
Why does the error say (Object[]) if I passed an array?
Object[] is the type receipt for a 1-D array of mixed or object values. Apps Script reports the runtime type it saw, not what you intended. It still does not match Object[][], so the fix is the same: wrap each element in an inner array with map(function(v) { return [v]; }).
Does setValues work on a named range?
Yes. SpreadsheetApp.getActiveSpreadsheet().getRangeByName('MyRange').setValues(grid) works identically — the method signature requirement is the same. The range just has to exist and your 2-D array dimensions have to match its row and column count.
I wrapped my array but now I get "Incorrect range height" — what is wrong?
The number of inner arrays must equal the number of rows in the range, and the length of each inner array must equal the number of columns. If your range is A1:A5 (5 rows, 1 column), your grid must have exactly 5 inner arrays each of length 1. Recount both.
Can I use setValues to write a single value to one cell?
Technically yes: sheet.getRange('A1').setValues([[42]]) works. In practice, sheet.getRange('A1').setValue(42) is cleaner and avoids the wrapping overhead. Only use setValues when you have more than one cell to write.