我需要在Google应用程序脚本中为数组输出创建一个GUI。谷歌搜索了3个小时,却找不到如何在谷歌应用程序脚本中输出数组的解决方案。有什么想法吗?
电子表格中的二维数组的GUI。
function guioutput() {
const ss=SpreadsheetApp.getActive();
const sh=ss.getSheetByName('Sheet1');
const rg=sh.getDataRange();
const vA=rg.getValues();
var html='<style> th,td{border:1px solid black;}</style><table>'
vA.forEach(function(r,i){
html+='<tr>';
r.forEach(function(c,j){
if(i==0) {
html+=Utilities.formatString('<th>%s</th>',c);
} else {
html+=Utilities.formatString('<td>%s</td>',c);
}
});
html+='</tr>';
});
html+='</table>';
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html), "Your GUI is less than ten minutes")
}
这是一个测试它的数据表。
COL1 | COL8 | COL9 | COL10 | |
---|---|---|---|---|
21 | 3 | 19 | ||
4 | 5 | 12 | ||
1 | 12 | 14 | ||
18 | 2 | 12 | ||
15 | 2 | 18 | ||
14 | 5 | 6 | ||
18 | 19 | 18 | ||
13 | 24 | 6 | ||
4 | 11 | 3 | ||
8 | 6 | 15 | ||
7 | 5 | 21 | ||
23 | 19 | 23 | ||
18 | 16 | 7 | ||
13 | 18 | 6 | ||
16 | 21 | 16 | ||
12 | 15 | 21 | ||
21 | 11 | 0 | ||
24 | 1 | 10 | ||
16 | 9 | 17 | ||
4 | 11 | 2 | ||
21 | 22 | 7 | ||
23 | 6 | 1 | ||
0 | 17 | 12 | ||
17 | 24 | 10 | ||
15 | 15 | 11 |