Created
April 14, 2020 02:14
-
-
Save mfyz/f1e96610791bb060ab915eb888a73329 to your computer and use it in GitHub Desktop.
Google Sheets to HTML
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
<style> | |
body { | |
font: 16px/24px Helvetica, Sans-Serif; | |
padding: 30px; | |
} | |
</style> | |
<script | |
src="https://code.jquery.com/jquery-2.2.4.min.js" | |
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" | |
crossorigin="anonymous"></script> | |
<h2>Google Sheet to HTML</h2> | |
<p> | |
The following page content is generated from a google sheet using google sheet's json feed url for a publicly published document. | |
</p> | |
<p> | |
Original Google Sheet Document: <a href="https://docs.google.com/spreadsheets/d/1ZmdmQm3sVlGcUpiQBOd9JRFCSQJ5_HLeUjUXfvNic_I/edit#gid=0">https://docs.google.com/spreadsheets/d/1ZmdmQm3sVlGcUpiQBOd9JRFCSQJ5_HLeUjUXfvNic_I/edit#gid=0</a> | |
</p> | |
<hr> | |
<div class="results"></div> | |
<script> | |
// ID of the Google Spreadsheet | |
var spreadsheetID = "1ZmdmQm3sVlGcUpiQBOd9JRFCSQJ5_HLeUjUXfvNic_I"; | |
// Make sure it is public or set to Anyone with link can view | |
var url = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/od6/public/values?alt=json"; | |
$.getJSON(url, function(data) { | |
console.log('--> data', data) | |
var entry = data.feed.entry; | |
$(entry).each(function(){ | |
// Column names are name, age, etc. | |
$('.results').append('<h2>'+this.gsx$title.$t+'</h2><p>'+this.gsx$description.$t+'</p>'); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment