Skip to content

Instantly share code, notes, and snippets.

@somidad
Last active September 7, 2016 03:35
Show Gist options
  • Save somidad/05b298c45a77fe476a66c1c7508b775f to your computer and use it in GitHub Desktop.
Save somidad/05b298c45a77fe476a66c1c7508b775f to your computer and use it in GitHub Desktop.
<head>
<script src="js/jquery-3.1.0.min.js"></script>
<script src="js/spreadcell.js"></script>
</head>
<body>
<div id="mlb">
Loading content...
</div>
<script>
// prepare a callback funciton
var mlb_callback = function(obj) {
console.log(mlb)
$("#mlb").html("<table>")
$("#mlb table").css("border-collapse", "collapse")
$("#mlb table").append("<tr>")
for (var i = 0; i < mlb.header.length; i++) {
$("#mlb table tr:last-child").append("<td>")
$("#mlb table tr:last-child td:last-child").append(mlb.header[i])
$("#mlb table tr:last-child td:last-child").css({"width": "75px",
"border-bottom": "2px solid #000",
"text-align": "center"})
}
for (var i = 0; i < Math.min(mlb.body.length, 10); i++) {
$("#mlb table").append("<tr>")
for (var j = 0; j < mlb.body[i].length; j++) {
$("#mlb table tr:last-child").append("<td>")
$("#mlb table tr:last-child td:last-child").append(mlb.body[i][j])
$("#mlb table tr:last-child td:last-child").css({"border-bottom": "1px solid #000",
"text-align": "center"})
}
}
}
// retrieve a spreadsheet
var mlb = new SpreadCell({id: "17EwNIgGf9YqVUgl0WQftCJybGy2cYlKk7PKeJi0T3qU",
contain_header: true,
callback: mlb_callback});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment