Articles

Affichage des articles du avril, 2022

CRÉER UNE BOITE DE DIALOGUE (INPUTBOX) AVEC LISTE DE CHOIX

Image
  Ce script permet d'inclure un menu déroulant dans une boite de dialogue.  La liste des choix se trouve dans une zone nommée  choix  du fichier La valeur est recueillie par la fonction   getInputBoxValue Il suffit de lancer cette fonction var   choix  =  SpreadsheetApp . getActiveSpreadsheet (). getRange ( 'choix' ). getValues (). flat () function   inputBoxListe () {    var   page  =  `<html> <style>   body {     font-family: Roboto, Arial, sans-serif;   }   select {     display: block;     width: 90%;     box-sizing: border-box;     margin-bottom: 1rem;     padding: 0.6rem 0.7rem;     background: #f3f3f3;     border: none;     font-size: 1.08rem;     border-radius: 0.4rem;   } </style> <body> <select onchange="retourner(this.value);">   <option value="" disabled selected >texte d'invitation ...</option>`    choix . forEach ( c  =>  page  +=  `<option value=" ${ c } "> ${ c } </option&

CRÉER UNE BOITE DE DIALOGUE (INPUTBOX) AVEC CASES À COCHER

Image
Ce script permet d'inclure un ensemble de cases à cocher dans une boite de dialogue.  La liste des options se trouve dans une zone nommée choix du fichier La valeur est recueillie par la fonction   getInputBoxValue Il suffit de lancer cette fonction var   choix  =  SpreadsheetApp . getActiveSpreadsheet (). getRange ( 'choix' ). getValues (). flat () function   inputBoxCheck () {    var   page  =  `<html> <style>   body {     font-family: Roboto, Arial, sans-serif;     font-size: 1.08rem;   } </style> <body>`    choix . forEach ( c  =>  page  +=  `<input type="radio" name="choix" value=" ${ c } " onchange="retourner(this.value);" /> ${ c } <br>` )    page  +=  ` </body><script> window.close = function(){window.setTimeout(function(){google.script.host.close()},100)}; function retourner(valeur) {   google.script.run.getInputBoxValue(valeur);   close(); } </script> </html>`   

CRÉER UNE BOITE DE DIALOGUE (INPUTBOX) AVEC CHOIX D'UNE DATE

Image
Ce script permet d'inclure une zone formattée en date dans une boite de dialogue. La valeur est recueillie par la fonction   getInputBoxValue Il suffit de lancer cette fonction function   inputBoxDate () {    var   html  =  HtmlService . createHtmlOutput ( ` <html> <style>   input[type="date"] {     font-family: Roboto, Arial, sans-serif;     display: block;     width: 100%;     box-sizing: border-box;     margin-bottom: 1rem;     padding: 0.6rem 0.7rem;     background: #f3f3f3;     border: none;     font-size: 1.08rem;     border-radius: 0.4rem;   } </style> <body> <input type="date" name="date" id="date" value="" onchange="retourner(this.value);"> </body><script> window.close = function(){window.setTimeout(function(){google.script.host.close()},100)}; function retourner(valeur) {   google.script.run.getInputBoxValue(valeur);   close(); } </script> </html>    ` )     .

OUVRIR UNE URL À PARTIR D'UN SCRIPT

Voici un code simplissime, compatible Chrome et Edge a minima, permettant d'ouvrir une URL dans un autre onglet du navigateur. function openUrl(url) { var html = HtmlService.createHtmlOutput(` <html><script> window.close = function(){window.setTimeout(function(){google.script.host.close()},9)}; var a = document.createElement("a"); a.href="${url}"; a.target="_blank"; a.click() close(); </script> </html> `) .setWidth(90).setHeight(1); SpreadsheetApp.getUi().showModalDialog(html, "Opening ..."); }