[英]inserting HTML into pop-ups or notes in google sheets
簡單對話框
此函數會將 A 列和 B 列中的所有內容放入無模式對話框中的表格中。 這一切都在谷歌腳本中。
function simpleDialog() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getRange(2,1,sh.getLastRow()-1,2);
var vA=rg.getValues();
var html='<html><head><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"><script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script></head><body>';
html+='<style>th,td{border:1px solid black;}</style><table>';
html+=Utilities.formatString('<tr><th>%s</th><th>%s</th></tr>',"Asset","Rate");
vA.forEach(function(r,i){
html+=Utilities.formatString('<tr><td>%s</td><td>%s</td></tr>',r[0],r[1]);
});
html+='</table><br /><input type="button" value="Exit" onClick="google.script.host.close();" />';
html+='</body></html>';
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, "Data Dialog");
}
如果您希望以某種方式在 Google 表格單元格上的鼠標懸停事件上顯示富文本,則無法使用內置功能或 Google Apps 腳本。
Google Sheets note 只能顯示純文本,因此為了顯示使用 HTML/CSS 格式化的內容,您可以使用自定義對話框,但是當用戶單擊帶有腳本、自定義菜單或側邊欄(按鈕、事件等)
參考
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.