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

149
Visualizações
Getting null when getting value from spreadsheet if special characters where used in App Script

I'm not a good programmer or English speaker, sorry.

I try to access a Google spreadsheet with app script and from fixer .gs I can get the record I want but at the same time switching it to javascript the console returns "null".

This only happens when there are special characters in the fields I'm looking for, such as colon.

function recullEntrades(){
  const ss = SpreadsheetApp.openByUrl(url);
  const ws = ss.getSheetByName("Dades");
  Logger.log(ws.getRange(2,1, ws.getLastRow()-1,7).getDisplayValues())
  return ws.getRange(2,1, ws.getLastRow()-1,7).getValues();
}

This is ok in the Logger but then,

function miraEntrades(entrades) {
  console.log("entrades: " + entrades);
}

$('#vomita').click(function(){
  google.script.run.withSuccessHandler(miraEntrades).recullEntrades();
})   

In the chrome console i get "null", this is not happening if i not use colon.

Thanks.

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

0

Like pointed above by @Josep, it looks like you're logging the values using getDisplayValues but you're returning the values using getValues.

According to the Apps Script documentation:

getDisplayValues

Returns a two-dimensional array of displayed values, indexed by row, then by column. The values are String objects. The displayed value takes into account date, time and currency formatting, including formats applied automatically by the spreadsheet's locale setting. Empty cells are represented by an empty string in the array.

getValues

Returns a two-dimensional array of values, indexed by row, then by column. The values may be of type Number, Boolean, Date, or String, depending on the value of the cell. Empty cells are represented by an empty string in the array.

Therefore, depending on the exact use-case, you might benefit from returning the values using the getDisplayValues method instead.

Reference

  • Apps Script Range Class - getDisplayValues();

  • Apps Script Range Class - getValues().

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