HTML
xxxxxxxxxx
1
<div class="container my-5">
2
3
<div class="row">
4
5
<div class="col-md-7 mb-4 mb-md-0">
6
7
<div class="text-center mb-4">
8
<a class="btn btn-primary mb-4" target="_blank" href="https://docs.google.com/spreadsheets/d/1MjMoMbuRJqnrfhxjetvdny-dnsFfmLJX24OWiSFUYvk" role="button"
9
>Click to see the source sheet</a
10
>
11
12
<p>The data in the table below was imported from Google Spreadsheet. Thanks to this, they can be edited by editing this sheet, and the changes will be reflected in the html table.</p>
13
14
</div>
15
16
<!-- Table -->
17
<table class="table table-striped mb-0">
18
<thead id="table-head"></thead>
19
<tbody id="table-body"></tbody>
20
</table>
21
22
</div>
23
24
<div class="col-md-5 mb-4 mb-md-0 text-center">
25
26
<p class="font-weight-bold"><strong>Watch the tutorial </strong></p>
27
28
<a href="" target="_blank" class="btn btn-lg btn-danger">
29
<i class="fab fa-youtube mr-3"></i>Watch on youtube
30
</a>
31
32
33
</div>
34
35
</div>
36
37
<hr class="mt-5">
38
39
<p>Built with <a target="_blank" href="https://mdbootstrap.com/">Material Design for Bootstrap</a> - free and powerful Bootstrap UI KIT</p>
40
41
<a class="btn btn-danger me-2" href="https://mdbootstrap.com/" target="_blank" role="button">Download MDB UI KIT</a>
42
<a class="btn btn-success me-2" target="_blank" href="https://mdbootstrap.com/docs/standard/getting-started/" role="button">Tutorials</a>
43
<a class="btn btn-dark mr-2" target="_blank" href="https://github.com/mdbootstrap/mdb-ui-kit" role="button">GitHub <i class="fab fa-github ml-2"></i></a>
44
45
46
</div>
CSS
1
1
JS
xxxxxxxxxx
1
{
2
{
3
// Your API KEY
4
const API_KEY = "AIzaSyA2t3evClUKvKsgbXOBrAaqfLuIHjiJC3k";
5
6
function displayResult2(response) {
7
let tableHead = "";
8
let tableBody = "";
9
10
response.result.values.forEach((row, index) => {
11
if (index === 0) {
12
tableHead += "<tr>";
13
row.forEach((val) => (tableHead += "<th>" + val + "</th>"));
14
tableHead += "</tr>";
15
} else {
16
tableBody += "<tr>";
17
row.forEach((val) => (tableBody += "<td>" + val + "</td>"));
18
tableBody += "</tr>";
19
}
20
});
21
22
document.getElementById("table-head").innerHTML = tableHead;
23
document.getElementById("table-body").innerHTML = tableBody;
24
}
25
26
function loadData() {
27
// Spreadsheet ID
28
const spreadsheetId = "1MjMoMbuRJqnrfhxjetvdny-dnsFfmLJX24OWiSFUYvk";
29
const range = "A:Z";
30
getPublicValues({ spreadsheetId, range }, displayResult2);
31
}
32
33
window.addEventListener("load", (e) => {
34
initOAuthClient({ apiKey: API_KEY });
35
});
36
37
document.addEventListener("gapi-loaded", (e) => {
38
loadData();
39
});
40
}
41
}
Console errors: 0