I am trying to send an email containing a table, I have managed to create the table but can not figure out how I copy over the format including the background colour and number format, as some cells contain currency as well as percentages and plain numbers.
As the data is colour coded, it is important to copy those over into the email.
here is the code I have, if someone could point me in the right direction, it would be extremely helpful, here is my code so far....
function createTable(data){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
//To be looped in the future, 10 in range to be replaced with k
var dataRange = sheet.getRange(10,4,1,9);
var data = dataRange.getValues();
//Table Header
var table = "<html><body><br><table border=1><tr><th>Compliance Score</th><th>STSOR Value</th><th>STSOR %</th><th>ZZ lines</th><th>ZZ%</th><th>PI lines Counted</th><th>PI %</th><th>NRDS Value</th><th>NRDS %</tr></br>";
//table Body
for (var i = 0; i < data.length; i++){
cells = data[i]; //puts each cell in an array position
table = table + "<tr>";
for (var u = 0; u < cells.length; u++){
table = table + "<td>"+ cells[u] +"</td>";
}
table = table + "</tr>"
//Send the email:
MailApp.sendEmail({
to: "example@gmail.com",
subject: "Example",
htmlBody: table});
}
}