I have 2 sheet on my spreadsheet. My code works with first sheet but when i try with second sheet it returns null. I can’t understand why. Also i checked realtime requests it looks returns my data but my sidebar value null still.
function getAllRowsData() {
try {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getActiveSheet();
// Get the spreadsheet name
var spreadsheetName = sheet.getName();
// Get the values of all rows
var allRows = sheet.getDataRange().getValues();
// Get the column names from the first row
var columnNames = allRows[0];
// Get the data rows (excluding the header row)
var dataRows = allRows.slice(1);
var result = { spreadsheetName: spreadsheetName, columns: columnNames, rows: dataRows };
Logger.log(result);
return result;
} catch (error) {
Logger.log("An error occurred: " + error.message);
return null;
}
}
function getActiveCellValue() {
google.script.run.withSuccessHandler(setData).withFailureHandler(function(e){console.error(e)}).withLogger(function(e){console.warn("The following log was generated:"+e)}).getAllRowsData();
}
I wanted to get my data but it returns null
New contributor
uysalibov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.