2
I would like to know how I send a spreadsheet from a spreadsheet on google.
I already have one script done, to send emails every day with information, however, I would like these emails to be downloaded in the form of .PDF
, how can I do this?
I already have this script ready:
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getRange(2, 1, 1000, 10);
var data = dataRange.getValues();
var message = '';
message += geraTabela(20, 30, data);
message += geraTabela(15, 20, data);
message += geraTabela(0, 15, data);
MailApp.sendEmail(
'email para qual eu envio',
'Pagamentos em vencimento',
'Utilize um leitor de e-mail compatível.',
{ htmlBody : message });
}
function geraTabela(inicio, fim, data) {
// Inicio da tabela 1
var message = '';
message += '<h3>Processos que vencerão em '+fim+' dias</h3>';
message += '<table border=1 cellpadding=4>';
message += '<tr><th>PGNET</th><th>Nome da Parte</th><th>Nº Administrativo</th></tr>';
for (i in data) {
var row = data[i];
if (row[4] && row[4] > inicio && row[4] <=fim) {
message += '<tr>';
message += '<td>' + row[6] + '</td>';
message += '<td>' + row[1] + '</td>';
message += '<td>' + row[8] + '</td>';
message += '</tr>';
}
}
message += '</table>';
// Fim da tabela 1
return message;
}
I would like to know how to generate this information in .PDF
, preferably horizontal, which command should I apply?
I ran, and ended up giving this error, how do I fix it? Referenceerror: "window" is not set. (line 1, file "Code")
– GuilhermeDias