Skip to content

Instantly share code, notes, and snippets.

@neno-tech
Last active March 4, 2023 10:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neno-tech/a24c055ffd794565d9856ff0c3f4c4c4 to your computer and use it in GitHub Desktop.
Save neno-tech/a24c055ffd794565d9856ff0c3f4c4c4 to your computer and use it in GitHub Desktop.
function doGet() {
return HtmlService.createTemplateFromFile("index")
.evaluate()
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
}
function getSheetData() {
var data = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getDataRange().getValues()
return data
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<center><br>
<h2>ตารางแสดงข้อมูล</h2>
<table border="3" style="border:2px solid black" cellpadding="5px" >
<?var tableData = getSheetData();?>
<?for(var i = 0; i < tableData.length; i++) { ?>
<?if(i == 0) { ?>
<tr>
<?for(var j = 0; j < tableData[i].length; j++) { ?>
<th><?= tableData[i][j] ?></th>
<? } ?>
</tr>
<? } else { ?>
<tr>
<?for(var j = 0; j < tableData[i].length; j++) { ?>
<td><?= tableData[i][j] ?></td>
<? } ?>
</tr>
<? } ?>
<? } ?>
</table></center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment