I am trying to return the data in the spreadsheet to an Apps Script published as a webApp. However, for one of my spreadsheets (link), the returned data is null
. I logged the the data before returning to make sure that it isn't null, and I can see them in the logs.
This is my code:
function doGet(){
return HtmlService.createHtmlOutputFromFile('index');
}
function spreadsheetTest() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var maxRows = sheet.getMaxRows();
var data = sheet.getSheetValues(1, 1, maxRows, 10);
Logger.log(data)
return data;
}
<html>
<button type="button" onclick="clcked();">Click Me!</button>
<div id="Message"></div>
<script>
function clcked(){
google.script.run
.withSuccessHandler(function(response) {
console.log(response);
})
.spreadsheetTest();
}
</script>
</html>
See Question&Answers more detail:os