I am using Google Apps Script to work with a spreadsheet. My code isn’t working, so I’m working on getting out the bugs. It’s supposed to copy the spreadsheet values into an array, make some changes in the array, and then use those changes to re-write some parts of the spreadsheet and re-format other parts.
As part of my bug-checking, I tried writing the array back to a cell in the spreadsheet after all the desired changes are made. When I do, I get the error in the question title:
error: Matrix is not rectangular {" ","Score","Max Poss.","","","","asdf","","","","","","","";"Steve:",1,133,"","","","eFEf","","","","","","","";"Chris:",0,126,"","","","First we test the color change.","","","","","","","";"Tyler:",5,130,"","","","And now let's see...","","","","","","","";"Billy:",3,127,"","","","df","","","","","","","";"Drew:",0,122,"","","#N/A","gtttt","","","","","","","";"Yllib:",9,133,"","","","vrrr","","","","","","","";"","","","","","","","","","","","","","";"-W/L-","Drew","Steve","Chris","Tyler","Billy","HOME","AWAY","Billy","Tyler","Chris","Steve","Drew","-W/L-";"l",4,"",4,6,"","","",3,"","",1,"","w";"W","","","",5,"","","",9,"",6,3,5,"l";"",3,12,2,2,2,"","","","","","",""," ";"","","","","","","","",11,1,5,8,6," ";"",10,15,15,8,13,"","","","","","",""," ";"",8,10,14,16,12,"","","","","","",""," ";"","","","","","","","",10,14,10,16,14," ";"",13,13,11,13,16,"","","","","","",""," ";"","","","",4,"","","",4,"",9,6,16," ";"","",9,"","","","","",1,3,8,"",9," ";"","","","","","","","",8,12,13,2,12," ";"","","",1,"",5,"","","",11,"",4,1," ";"","","","","","","","",15,10,12,14,11," ";"",2,"",3,"",6,"","","",9,"",5,""," ";"W";"",2,"",7,7,7,"NYG -2.5","","","","",7,""," "}
I’ve tried creating the array both using
var sheetArray = new Array (30);
and
var sheetArray = [];
with the same results.
I haven’t turned up much on Google. I guess my big question is whether I am getting this error because I’m trying to display a rectangular array in a spreadsheet cell that isn’t compatible, or if the problem is with the creation of the array itself or some other aspect unrelated to display.
I presume you are testing by writing an embedded array in a spreadsheet formula:
={"a","b","c";"d","e","f"}You are getting the error message because your matrix is not rectangular. 🙂
The offending row is the second last row, where you have one element “W” in that row:
..." ";"W";"",2,"",7,7,7,"NYG -2.5","","","","",7,""," "}So I guess there is an error somewhere in your construction of the array (if you needed help with that, feel free to post some code into the question).