0
votes

I'm trying to print a 2D array into a spreadsheet, but I am getting some error and I couldn't find any solution.

Here is my solution:

var URL = blabla
var Sheets = [bla,ble,bli]
var doc = SpreadsheetApp.openByUrl(URL);
var ss3 = doc.getSheetByName(Sheets[2]);
var FinalFacil = [[Matematicas, 1 Medio, Funciones, 6?, 
Facil, A;B;C;D;E, D], [Matematicas, 1 Medio, Funciones, 7?, Facil, 
A;B;C;D;E, E], [Matematicas, 1 Medio, Funciones, 3?, Facil, A;B;C;D;E, A], 
[Matematicas, 1 Medio, Funciones, 4?, Facil, A;B;C;D;E, B]]
ss3.getRange("A1:G4").setValues(FinalFacil);

And I am getting the following error: Cannot find method setValues((class))

1
Everything inside the array should be quoted."1 Medio" - TheMaster
I think that if FinalFacil in your script is [[Matematicas, 1 Medio, Funciones, 6?, Facil, A;B;C;D;E, D],,,], your script cannot be saved because of an error. But in your question, you say that an error of Cannot find method setValues((class)) occurs. So can you provide for replicating your issue? - Tanaike
@Tanaike, for the variable FinalFacil, I pasted the output of my variable as the content of it (thinking that it would be easy to troubleshot). Thing is FinalFacil its the result of several filters that I am doing before. So think that FinalFacil its just a 2D array. - angel guerrero
@TheMaster Even if I am getting those values strigth out of a spreadsheet? - angel guerrero
@angel The issue,IMO is - whatever you're doing to the array messes up the array(so much so that it's no more a 2D array) so that it can't be used in setValues. You need to provide minimal reproducible example or exact logs of the array FinalFacil just before using it in setValues - TheMaster

1 Answers

0
votes

The problem occurs because is ss3 is undefined. It's undefined because the third element of Sheets is undefined too.

If your spreadsheet has a sheet named bli replace

var Sheets = [bla,ble,bli]

by

var Sheets = [bla,ble,'bli']