簡體   English   中英

將 HTML 插入到 Google 表格中的彈出窗口或備注中

[英]inserting HTML into pop-ups or notes in google sheets

我喜歡使用彈出窗口來檢索補充信息。

在此處輸入圖片說明

但是正如您所看到的,我想將數據排列成某種表格,以使其看起來更合適。
所以問題真的很簡單:有沒有辦法在 Google Apps Script 的setNote()中插入一種 html 或者可能想出某種 DIY 彈出窗口?

當然,我說的是原始的 Web 應用程序。

簡單對話框

此函數會將 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM