最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - inserting HTML into pop-ups or notes in google sheets - Stack Overflow

programmeradmin0浏览0评论

I love working with pop-ups to retrieve plementary information.

But as you can see I would like to arrange the data into some sort of table to give it a more proper look.
So the question is really simple: is there any way to insert a sort of html into setNote() in Google Apps Script or may be e up with some sort of DIY pop-up?

I am talking about the original web application of course.

I love working with pop-ups to retrieve plementary information.

But as you can see I would like to arrange the data into some sort of table to give it a more proper look.
So the question is really simple: is there any way to insert a sort of html into setNote() in Google Apps Script or may be e up with some sort of DIY pop-up?

I am talking about the original web application of course.

Share Improve this question asked Dec 15, 2019 at 12:34 John GalassiJohn Galassi 3182 silver badges18 bronze badges 1
  • 3 Guess no. You could however use a modal dialog. – TheMaster Commented Dec 15, 2019 at 12:38
Add a ment  | 

2 Answers 2

Reset to default 5

Simple Dialog

This function will put everything in Column A and B into a table in a modeless dialog. It's all in a google script.

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./ajax/libs/jquery/3.3.1/jquery.min.js"></script><link rel="stylesheet" href="//code.jquery./ui/1.12.1/themes/base/jquery-ui.css"><script src="https://code.jquery./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");
}

If you are looking to someway to show rich text on a mouse hover event over a Google Sheets cell, it's not possible by using built-in features or Google Apps Script.

Google Sheets note can only display plain-text, so in order to show content formatted by using HTML/CSS you could use a custom dialog but them are displayed when a user click a image with a script assigned, a custom menu or by something in a sidebar (a button, event, etc.)

References

  • https://developers.google./apps-script/guides/dialogs
  • https://developers.google./apps-script/guides/sheets
  • https://developers.google./apps-script/guides/triggers/events
发布评论

评论列表(0)

  1. 暂无评论