user1592380
user1592380

Reputation: 36205

Incorrect range height, was 1 but should be 3 in apps script

enter image description here

I'm trying to use appscript aheets setvalues() to paste a row of headers into a sheet.I have:

var headingsArray = []
headingsArray.push(["A", "B", "C", "D", "E",  "F"]);
Logger.log(headingsArray)
sheet.getRange(3,1,3,6).setValues(headingsArray);  

getting the error in title.

What am I doing wrong?

Upvotes: 1

Views: 779

Answers (1)

Pierre-Marie Richard
Pierre-Marie Richard

Reputation: 2004

You trying to set values that are 1 row 6 columns large to a range of 3 row 6 columns. You should change your range to :

sheet.getRange(3,1,1,6).setValues(headingsArray);

since

setValues(values)

Sets a rectangular grid of values (must match dimensions of this range).

See getRange() method and setValues() method

Upvotes: 3

Related Questions