-
-
Save AlphaNerd/8fe9361916e56244f857 to your computer and use it in GitHub Desktop.
Google Sheets JSON pull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="results"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = 'https://spreadsheets.google.com/feeds/cells/1iuSmpZx2wN1N8xh9R6GUF5k0-o2budrCBPzKuY5IA-c/od6/public/values?alt=json-in-script&callback=?'; | |
var onSuccess = function(data) { | |
var html = ""; | |
var entries = data.feed.entry; | |
for (var i=0, len = entries.length; i<len; ++i) { | |
html += entries[i].content.$t + ' '; | |
if ((i + 1) % 3 == 0) { | |
html += '<br/>'; | |
} | |
} | |
$('#results').html(html); | |
} | |
$.getJSON(url, cellEntries); | |
function cellEntries(json) { | |
var table = document.createElement('table'); | |
table.setAttribute('id', 'output'); | |
var tbody = document.createElement('tbody'); | |
var tr; | |
for (var i=0; i < json.feed.entry.length; i++) { | |
var entry = json.feed.entry[i]; | |
if (entry.gs$cell.col == '1') { | |
if (tr != null) { | |
tbody.appendChild(tr); | |
} | |
tr = document.createElement('tr'); | |
} | |
var td = document.createElement('td'); | |
td.appendChild(document.createTextNode(entry.content.$t)); | |
tr.appendChild(td); | |
} | |
tbody.appendChild(tr); | |
table.appendChild(tbody); | |
document.getElementById('results').appendChild(table); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment