I have a script that reads the information from a spreadsheet, and displays it in HTML. I try to adapt a button to it that activates the updating of the information when changes are made in the spreadsheet. I only manage to execute the part of window.location.reload(true);
. But the data is not updated.
These are the codes:
function doGet() {
return HtmlService
.createTemplateFromFile('Index')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function getData() {
return SpreadsheetApp
.openById('IDdelaspreadsheet')
.getActiveSheet()
.getDataRange()
.getValues();
}
function onSubmit(e){
doGet();
getData();
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<? var data = getData(); ?>
<table>
<? for (var i = 0; i < data.length; i++) { ?>
<tr>
<? for (var j = 0; j < data[i].length; j++) { ?>
<td><?= data[i][j] ?></td>
<? } ?>
</tr>
<? } ?>
</table>
// no es del código original. Aquí trato de incluir el botón
<form>
<input onclick="MostrarResultados()" type="button" value="Mostrar" />
</form>
<script type="text/javascript">
function MostrarResultados() {
google.script.run.onSubmit();
window.location.reload(true);
}
</script>
// hasta aquí la parte que inserto, no es del código original
</body>
</html>