Export CSV File from Spreadsheet and Make Download Button
This is a script to export a CSV file from spreadsheet and make an user download it. When the users download it, they can download by push a button made by this script.
In order to use this script, put both HTML and script in a GAS project.
html :
This file name is “download.html”.
<!DOCTYPE html>
<html>
<body>
Download CSV?
<form>
<input type="button" value="ok" onclick="google.script.run
.withSuccessHandler(executeDownload)
.saveAsCSV();" />
</form>
</body>
<script>
function executeDownload(url) {
window.location.href = url;
}
</script>
</html>
Script :