GASを使って、二つの表をメールに記載したい。
こうすると、二つの表がつながってしまいます。
二つの表をきちんと分けて表示させたいのですが。。。
GAS
1function sendEmail() { 2 3let hani = sheet2.getRange(2,11).getValue(); 4 5 6 const range3 = sheet3.getRange(27,1,hani+2,11); 7 const range4 = sheet2.getRange(13,1,9,6) 8 9 let vals = range3.getDisplayValues(); 10 let vals2 = range4.getDIsplayValues(); 11 12let body1 = "今週は"+ hani + "件ありました。"; 13 14 15 //ここでforを使ってval⇒htmlのtable形式に 16 17let tbl1= "<table border='1' style='border-collapse: collapse ;'><tr><th>搬入日</th><th>工場</th><th>経由</th><th>店</th><th>c</th><th>D</th><th>E</th><th>F</th><th>担当者"; 18 19 20 let newtd =""; 21 22 vals.forEach(x=>{ //二次元配列valsから一つずつ配列取り出し 23 24 for(let elnum in x){ //取り出した一次元配列から一つずつ要素取り出し 25 newtd += "<td>"+x[elnum]+"</td>"; 26 } 27 let tr = "<tr>"+newtd+"</tr>" 28 tbl += tr; tr 29 newtd=""; 30 }) 31let tbl2="<table border='1' style='border-collapse: collapse ;'><tr><th>A</th><th>Bc</th><th>D</th><th>E</th><th>F"; 32 let newtd =""; 33 34 vals2.forEach(x=>{ //二次元配列valsから一つずつ配列取り出し 35 for(let elnum in x){ //取り出した一次元配列から一つずつ要素取り出し 36 newtd += "<td>"+x[elnum]+"</td>"; 37 } 38 let tr = "<tr>"+newtd+"</tr>" 39 tbl += tr; tr 40 newtd=""; 41 }) 42 43 44 let mailText1 = body1 + "<br><br>" + tbl1+ "<br><br>"+ tbl2 + "</table>"//ここでtableを閉じます。 45 46 // //オプションでHTMLメール本文を設定する 47 let options = {"htmlBody":mailText1,}; 48 49 GmailApp.sendEmail("****@****","テスト送信", mailText1 , options);
let tbl2 の前ですよね。
</table>を入れると、そこで構文エラーとなり、保存が出来ません。