我正在尝试将电子表格中的数据返回到作为 webApp 发布的 Apps 脚本。但是,对于我的其中一个电子表格(链接),返回的数据是null. 我在返回之前记录了数据以确保它不为空,并且我可以在日志中看到它们。
这是我的代码:
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;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。:)