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

193
Visualizações
Retrieving multiple cell value from google sheets in html

I am totally new in coding. I have a code which can retrieve cell value based on the specific range of google published sheet. specific cell value is coming from the google sheet url. Because I added &range=A1 specifically in the URL. The rage can be extended by changing the url into &range=A1:F20 as an example.

my code is working fine. The problem is, it only parses one cell value.

What I want:

I want to parse more specific cell values (e.g. A1, A3, C5, F9 etc) at the same time without requesting google sheet link for too many times.

By using the following below code I can retrieve and display only one cell value.

<body onload='loadData()'>
<div id="display"></div>

But I want to retrieve more individual cell values. (e.g. A1, A3, C5, F9 etc)

Here's the code:

<!DOCTYPE html>
<html>

<body>

<body onload='loadData()'>
<div id="display"></div>


<script>

function loadData() {
  var url="https://docs.google.com/spreadsheet/pub?key=p_aHW5nOrj0VO2ZHTRRtqTQ&single=true&gid=0&range=A1&output=csv";
  xmlhttp=new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
    if(xmlhttp.readyState == 4 && xmlhttp.status==200){
      document.getElementById("display").innerHTML = xmlhttp.responseText;
    }
  };
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}


</script>
</body>

</html>

Can you help please?

Thank you so much.

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

0

      var url="https://docs.google.com/spreadsheet/pub?key=p_aHW5nOrj0VO2ZHTRRtqTQ&single=true&gid=0&range=A1:F20&output=csv";
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState == 4 && xmlhttp.status==200){
          const result = xmlhttp.responseText;
          const values = result.split('\n').map(row => row.split(','));
          console.log(values[0][0]); // A1
          console.log(values[2][0]); // A3
          console.log(values[4][2]); // C5
          console.log(values[8][5]); // F9
        }
      };
      xmlhttp.open("GET",url,true);
      xmlhttp.send(null);
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