将 HTML 插入到 google 工作表中的弹出窗口或注释中
inserting HTML into pop-ups or notes in google sheets
我喜欢使用弹出窗口来检索补充信息。
但如您所见,我想将数据整理成某种形式 table 以使其看起来更合适。
所以问题真的很简单:有没有办法在 Google Apps 脚本中将某种 html 插入到 setNote()
中,或者可能会想出某种 DIY 弹出窗口?
我说的当然是原始的网络应用程序。
简单对话框
此函数会将 A 列和 B 列中的所有内容放入无模式对话框的 table 中。一切都在 google 脚本中。
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 格式化的内容,您可以使用自定义对话框,但当用户单击带有分配的脚本、自定义菜单或侧边栏中的内容(按钮、事件等)
参考资料
我喜欢使用弹出窗口来检索补充信息。
但如您所见,我想将数据整理成某种形式 table 以使其看起来更合适。
所以问题真的很简单:有没有办法在 Google Apps 脚本中将某种 html 插入到 setNote()
中,或者可能会想出某种 DIY 弹出窗口?
我说的当然是原始的网络应用程序。
简单对话框
此函数会将 A 列和 B 列中的所有内容放入无模式对话框的 table 中。一切都在 google 脚本中。
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 格式化的内容,您可以使用自定义对话框,但当用户单击带有分配的脚本、自定义菜单或侧边栏中的内容(按钮、事件等)
参考资料