Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!