'Google Sheets, writing array to sheet via script [duplicate]

I've a sheet which I'm using arrays in the script (to save on time)

I have no problems writing a 2d Array to my sheets, however for some reason I can't get a 1D array to write properly

This is a screenshot in debug mode of my array. It's just a list of prices (500 rows) enter image description here

This is my code (I added in the log to show the counts)

Logger.log (costPerItem.length) 
shWorkspace.getRange(1,12,costPerItem.length,1).setValues(costPerItem);

I just want to put the data into the 12th column on the tab that I've called shWorkspace earlier in the code.

But I get the error:

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

And I can't figure out why.

I've used almost identical code:

shProductData.getRange(1,1,fullDataArrayProducts.length,fullDataArrayProducts[0].length).setValues(fullDataArrayProducts)

To apply a 2d array and this works fine



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source