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

265
Visualizações
Saving a floating value to a google sheet using a script

I want to use google script to make a request and save some data on google sheet. The problem is when I try to pass some non integer values as parameters in the request. I think it's something to do with the fact that sheets uses comma for separating decimal from integer while my program sends the numbers separated by a dot.

This is where I am now:


const doPost = (event) => {
  console.log(`doPost`, JSON.stringify(event));

  const { parameter } = event;
  const { temp, peso } = parameter;
  var date = new Date();

  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.appendRow([date, parseFloat(temp), peso]);
}

When I make a post request with parameters: { temp:1.234, peso:1.234 } the result on google sheet is a big mess.

Does someone have any idea how to fix this?

edit:

function Test(){
  var sheet = SpreadsheetApp.getActiveSheet();
  var d = 1.23456;

  var date = new Date();
  sheet.appendRow([date, d]);
}

This works fine... don't know if it can help you debug.

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

0

Post Data to Sheet

I don't actually do this all that much so I am by no means an expert at it

function doPost(e) {
  Logger.log(e.postData.contents);
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Sheet1");
  let data = JSON.parse(e.postData.contents);
  sh.appendRow([data.first,data.second])
}


function sendData(obj) {
  const url = ScriptApp.getService().getUrl();
  const params={"payload":JSON.stringify(obj),"muteHttpExceptions":true,"method":"post","headers": {"Authorization": "Bearer " +  ScriptApp.getOAuthToken()}};
  UrlFetchApp.fetch(url,params);
}

function saveMyData() {
  sendData({first:"1.234",second:"1.432"});
}

This worked for me.

about 4 years ago · Juan Pablo Isaza Relatório

0

Finally figured it out!

The problem was in the setting of the google sheet file. I'm from Italy so it enters as defult the Italian format. For some reasons this mess up all the new entries. The solution is very simple: change the format to the english one and the problem should solve itself!

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