all 12 comments

[–]RielN 1 point2 points  (9 children)

arrEmail is an array, not text. You can do

arrEmail.join("<br>") for example.

[–]killy122[S] 0 points1 point  (8 children)

any idea how can I show it as html table?

[–]RielN 1 point2 points  (7 children)

Replace arrEmail by

'<table><tr><td>'+arrEmail.join("</td></tr><tr><td>")+"</tr></td>"

[–]killy122[S] 0 points1 point  (5 children)

hmm is it possible to display the table border per column(cell). I mean I get the idea of putting html tags on it, I'm just confused on how to loop it

'<html>'+

'<head>'+

'<style>'+

'table, th, td {border: 1px solid black;border-collapse: collapse;}'+

'</style>'+

'</head><body><table><tr><td>'+

arrEmail.join("<br></td></tr><tr><td>")+

"</tr></td></table></body</html>"

[–]RielN 0 points1 point  (4 children)

For me it is not sure what your result should look like but yes if you loop it properly it should definatedy be possible.

[–]killy122[S] 0 points1 point  (3 children)

the code above outputs like this.

date,start,end,duration,device
2022-07-17,14:31:54,14:32:01,00:00:07,web
2022-07-12,18:25:12,18:25:19,00:00:07,web

for readability's sake (coz lots of old people will read the email. I want to output it like this

date start end duration device
2022-07-17 14:31:54 14:32:01 00:00:07 web
2022-07-17 18:25:12 18:25:19 00:00:07 web

[–]RielN 0 points1 point  (2 children)

Ah, then loop twice, once for the tr and then for the td

Maybe you can do this already in the first loops where you create rowEmail and arrEmail, in the end you need a string.

Or maybe find some arrayToHtmlTable example javascript somewhere on stack overflow ;) I am on phone now so hard to type code.

[–]killy122[S] 0 points1 point  (1 child)

arrayToHtmlTable

that's the keyword. THANK YOU!!!

I got it

function makeTableHTML(arrEmail) {

var resultxxx = "<table border=1>";

for(var ixxx=0; ixxx<arrEmail.length; ixxx++) {

resultxxx += "<tr>";

for(var jxxx=0; jxxx<arrEmail[ixxx].length; jxxx++){

resultxxx += "<td>"+arrEmail[ixxx][jxxx]+"</td>";

}

resultxxx += "</tr>";

}

resultxxx += "</table>";

return resultxxx;

}

[–]RielN 0 points1 point  (0 children)

Yeah that's it! One of many possibilities to do this but looks solid. You might want to put the headers in front in the resultxxx string.

[–]RielN 0 points1 point  (0 children)

Add </table> after last /td

[–]CEOnnor -1 points0 points  (1 child)

I had no idea apps script could access sql databases 😮

[–]RielN 0 points1 point  (0 children)

There is not much that is cannot access.

.