I would like to know how I generate a spreadsheet from a spreadsheet in google .
I already have a script done, to send emails every day, with information, however, I would like these emails to be downloaded as .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 horizontally, which command should I apply?