Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
Google apps script html to spreadsheet

I am learning google apps script at the moment by myself.

I have been trying to get someone's mail and append it to a google spreadsheets.

My code.gs looks actually like this:

function doGet() {
  return HtmlService.createHtmlOutputFromFile("page");
};

function addEmail (mail) {
  var mysheet = SpreadsheetApp.openById("1k3vWmg9859mYykNNl0xDWoR_LUhnvLlq1qW8kSRuL_Q").getSheetByName("Sheeet1");
  mysheet.appendRow(mail);
};

And my html file looks like this:

<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <h1>hello</h1>
  </body>
  <label for="getUserMail">Type your mail here</label> <input type="text" id="getUserMail">
  <button id="trigger">Submit!</button>
  <script>
    document.getElementById("trigger").addEventListener("click",sendMailToCode);
    function sendMailToCode () {
     var umail = document.getElementById("getUserMail");
     google.script.run.addEmail(umail);
    };
  </script>
</html>

But it doesn't work. I have tried doing multiple stuff to fix it, even adding a tag on html but it does not save the value on the spreadsheet. Could someone please give an advice?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try this:

This will append the html to the sheet but it will not render it.

    function addEmail (mail='<html><head><basetarget="_top"></head><body><h1>hello</h1></body><labelfor="getUserMail">Typeyourmailhere</label><inputtype="text"id="getUserMail"><buttonid="trigger">Submit!</button><script>document.getElementById("trigger").addEventListener("click",sendMailToCode);functionsendMailToCode(){varumail=document.getElementById("getUserMail");google.script.run.addEmail(umail);};</script></html>') {
      var ss = SpreadsheetApp.getActive();
      const sh = ss.getSheetByName('Sheet0');
      sh.appendRow([mail]);
    }

appendRow

Reading the description of row contents: "An array of values to insert after the last row in the sheet."

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda