[英]How can i load data from a spreadsheet to an html using google apps script?
I'm trying to pass information that is in my current SpreadSheet to an HTML file i have, the html was made with google app script, if someone can guide me with this it would be very helpful.我正在尝试将我当前的电子表格中的信息传递给我拥有的 HTML 文件,html 是用谷歌应用程序脚本制作的,如果有人可以指导我这将非常有帮助。 I'm i little bit lost about this
我对此有点迷茫
Html Html
<body>
<!--3.x snippet-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!--2.x snippet-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!--1.x snippet-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Source -->
<!-- Google Hosted Libraries: https://developers.google.com/speed/libraries#jquery -->
<script>
window.writeData = function() {
var userInformation = document.getElementById('form');
google.script.run.registerUser(userInformation);
};
</script>
<blockquote class="trello-card">
<a href="" id="myLink">Trello Card</a>
</blockquote>
<script src="https://p.trellocdn.com/embed.min.js"></script>
<script>
google.script.run.withSuccessHandler(myname => {
var elem = document.getElementById('myLink');
elem.href += myname;
console.log('This is myname:' + myname);
}).getCardById();
</script>
</body>
Function that should return the information of the sheet应该返回工作表信息的Function
function getCardById(){
var app = SpreadsheetApp;
var activeSp = app.getActiveSpreadsheet();
var activeSheet = activeSp.getActiveSheet();
var linkCol = activeSheet.getRange("B2").getValue();
//Logger.log(' LINKCOL:' + linkCol);
return linkCol;
}
Function that show the html Function 显示 html
function seeCard() {
var templateFileId = '1upA3JHioEyxLScebasmsmwXW-SxsiKaPRznKLCKFYhw';
var sheetName = 'Trello sheet';
SpreadsheetApp.openById(templateFileId).copy(sheetName);
var excel = SpreadsheetApp.create("Probando un html interno a ver ")
var html = HtmlService.createHtmlOutputFromFile('index') //index is the name of your HTML file
.setTitle('Trello card')
.setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
Video of what is happening right now现在正在发生的事情的视频
*Picture in the console * *控制台中的图片*
https://www.screencast.com/t/6tHH15yz https://www.screencast.com/t/6tHH15yz
getCardById()
to the variable of myname
using Google Apps Script and Javascript.getCardById()
中的值用于myname
的变量。 If my understanding is correct, how about this modification?如果我的理解是正确的,那么这个修改呢?
Unfortunately, google.script.run
doesn't return no values.不幸的是,
google.script.run
没有返回任何值。 Ref So in this case, please use withSuccessHandler
as follows. 参考所以在这种情况下,请使用
withSuccessHandler
如下。 When your script is modified, please modify as follows.当您的脚本被修改时,请进行如下修改。
var elem = document.getElementById('myLink'),
var myname = google.script.run.getCardById();
elem.href += myname ;
google.script.run.withSuccessHandler(myname => {
var elem = document.getElementById('myLink');
elem.href = myname;
}).getCardById();
If I misunderstood your question and this was not the direction you want, I apologize.如果我误解了您的问题并且这不是您想要的方向,我深表歉意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.