my first script... sheet.getRange isn't working
I just found out about google's apps script today, so I'm starting simple. I was able to find the number of cols and rows, which I simply printed to the console.
So then I tried a simple loop to print the sheet, but it's acting like I'm using the wrong parameters for getRange().
Error: The parameters (number,number,number,number) don't match the method signature for SpreadsheetApp.Spreadsheet.getRange.
function myFunction() {
const sheet = SpreadsheetApp.openById("theSecretID");
const rowToRead = 1; // Example: Read the first row
const numCols = sheet.getLastColumn();
const numRows = sheet.getLastRow();
// getRange(row, column, numRows, numColumns)
//const range = sheet.getRange("A1:O1",);
//const values = range.getValues(); // Returns a 2D array: [[val1, val2, ...]]
//const rowData = values[0]; // Access the first (and only) inner array
for (i = 1; i<numRows+1; i++) {
let range = sheet.getRange(i, 1, 1, numCols);
let values = range.getvalues();
let rowData = values[0]
Logger.log(rowData);
}
}
I looked up the syntax of getRange(), and it accepts numbers, so what am I doing wrong?
Thanks! :)
u/Happytrees-123 — 3 days ago