Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda