HODD
HODD
<h3>MTD Sales</h3>
${htmlTable1}
<h3></h3>
${htmlTable11}
<h3></h3>
${htmlTable12}
<h3></h3>
${htmlTable14}
<h3>Category Sales</h3>
${htmlTable2}
<h3>Product Summary</h3>
<table style="border-collapse: collapse; width: 80%; border: 2px solid black;">
${productTableRows}
</table>
recipients.forEach(function(emailAddress) {
console.log(recipients)
console.log(emailAddress)
// Send the email
MailApp.sendEmail({
to: emailAddress,
subject: "DSR MTD - " + new Date().toLocaleDateString('en-GB'),
htmlBody: emailBody
});})
}
// Function to convert range into HTML table for "HOD mail body" sheet
function rangeToHtmlTable1(range) {
// Multiply 16th, 18th, and 21st columns by 100 and add percentage sign
(starting from 3rd row)
if (row >= 2) { // From 3rd row onward
if (col === 12 || col === 14 || col === 16|| col === 19) { // Columns 16,
18, 21 (zero-indexed 15, 17, 20)
if (typeof cellValue === 'number') {
formattedValue = (cellValue * 100).toFixed(2) + "%";
}
}
}
htmlTable += "</tr>";
}
htmlTable += "</table>";
return htmlTable;
}
// Function to convert range into HTML table for "Hod mail body PDF 2" sheet (with
green background for empty first column)
function rangeToHtmlTable2(range) {
var values = range.getValues();
var numRows = values.length;
var numCols = values[0].length;
var htmlTable = "<table border='1' cellpadding='5' cellspacing='0' style='border-
collapse: collapse; border: 1px solid black;'>";
// Multiply 16th, 18th, and 21st columns by 100 and add percentage sign
(starting from 3rd row)
if (row >= 2) { // From 3rd row onward
if (col === 15 || col === 17 || col === 20) { // Columns 16, 18, 21 (zero-
indexed 15, 17, 20)
if (typeof cellValue === 'number') {
formattedValue = (cellValue * 100).toFixed(2) + "%";
}
}
}
htmlTable += "</tr>";
}
htmlTable += "</table>";
return htmlTable;
}
function rangeToHtmlTable14(range) {
var values = range.getValues();
var numRows = values.length;
var numCols = values[0].length;
var htmlTable = "<table border='1' cellpadding='5' cellspacing='0' style='border-
collapse: collapse; border: 1px solid black;'>";
// Multiply 16th, 18th, and 21st columns by 100 and add percentage sign
(starting from 3rd row)
if (row >= 2) { // From 3rd row onward
if (col === 7 || col === 9 || col === 12) { // Columns 16, 18, 21 (zero-
indexed 15, 17, 20)
if (typeof cellValue === 'number') {
formattedValue = (cellValue * 100).toFixed(2) + "%";
}
}
}
htmlTable += "<td style='" + cellStyle + "'>" + formattedValue + "</td>";
}
htmlTable += "</tr>";
}
htmlTable += "</table>";
return htmlTable;
}