Get one Cell Value from Google Sheets via HTML Javascript

OliG
OliG used Ask the Experts™
on
Hi all,
I am trying to get one specific cell from a google sheet for displaying on a website.
What i have found is a lot of examples to create a table in html from a google sheet source, but not how to get f.e. Cell "A4" only.

$.getJSON( "https://spreadsheets.google.com/feeds/cells/19weOqnGlADXwhxUUtVnfZYv2uH6UJUeSmV5WQXQ5Ccc/od6/public/values?alt=json-in-script&callback=?"
function (data) {
       //what to put in here??
});
any help appreciated
thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Any chance we can see more code and / or returned JSON?

Author

Commented:
Julian, hi
I only have a working example which generates a list:


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Title</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
      <h1>Ranking</h1>
      <div id="ranking-list"></div>
</body>
</html>
<script type="text/javascript">

$(document).ready(function() {      
//source file is https://docs.google.com/spreadsheets/d/19weOqnGlADXwhxUUtVnfZYv2uH6UJUeSmV5WQXQ5Ccc

$(function listBooks() {      
$.getJSON( "https://spreadsheets.google.com/feeds/list/19weOqnGlADXwhxUUtVnfZYv2uH6UJUeSmV5WQXQ5Ccc/od6/public/values?alt=json-in-script&callback=?",
      function (data) {      
            $('div#ranking-list').append('<ul class="items"></ul>');
            $.each(data.feed.entry, function(i,entry) {      
                  var item = '<span style="display:none">' + entry.id.$t + '</span>';      
                  item += 'erhalten: ' + entry.gsx$erhalten.$t;      
                  $('.items').append('<li>' + item + '</span></li>');      
                  });
            });
      });
});
</script>
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Your getJSON call URL returns
Invalid parameter value: callback=?

Open in new window


to answer the question we need to see the returned JSON as well.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
did you just click on the hyperlink? then yes.
but if you embed the whole html code on a website, it will return a list of 14 rows.

remove the ?callback to get the raw data:
https://spreadsheets.google.com/feeds/list/19weOqnGlADXwhxUUtVnfZYv2uH6UJUeSmV5WQXQ5Ccc/od6/public/values?alt=json-in-script
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Do you mean something like this?
$(function listBooks() {      
  $.getJSON( "https://spreadsheets.google.com/feeds/list/19weOqnGlADXwhxUUtVnfZYv2uH6UJUeSmV5WQXQ5Ccc/od6/public/values?alt=json-in-script&callback=?",
    function (data) {   
      var a4 = data.feed.entry[3].gsx$spielername.$t;
      $('#ranking-list').html('The entry in cell A4 is : ' + a4);
  });
});

Open in new window

Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Just a comment on your jQuery. In your source you have
$(document).ready(function() {      
...
  $(function listBooks() {      
  });
});

Open in new window

$(document).ready() is the same as $(function() - so nesting one in side the other is not required - you only need the one as shown in my previous post.

Author

Commented:
exactly what I've been looking for. Thank you so much.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You are most welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial