I want to know the rows result of a filter in Google App Script but I dont achieve obtain them, I always obtain all the rows of the selection or the sheet. I've investigated and it seems that it is impossible with this API. Do you know if it is true or if exist another way to obtain these rows?. Thx
function docReport() {
try {
splashScreen("Generando informe...");
var activeSheet = SpreadsheetApp.getActiveSheet();
var numberOfColumns = activeSheet.getLastColumn();
var numberOfRows = activeSheet.getLastRow();
var activeRow = activeSheet.getRange(1, 1, numberOfRows, numberOfColumns).getValues();
var docReport = DocumentApp.create(REPORT_FILE_NAME);
var bodyReport = docReport.getBody();
bodyReport.setAttributes(stylePage);
for (var row = 1; row < numberOfRows; row++) {
if (!isEmpty(activeRow[row], numberOfColumns)) {
var image = UrlFetchApp.fetch(IMG_BBVA);
/*var paragraph = bodyReport.appendParagraph("");
paragraph.addPositionedImage(image).setHeight(100).setWidth(98);
paragraph.appendText("\r\n");
paragraph.setAttributes(styleTitle);*/
//bodyReport.appendImage(image).setHeight(100).setWidth(98); //Incluimos la imagen de cabecera
bodyReport.appendParagraph("").addPositionedImage(image).setHeight(100).setWidth(98).setLayout(DocumentApp.PositionedLayout.WRAP_TEXT);
bodyReport.appendParagraph(" SERVICIOS JURÍDICOS").setAttributes(styleTextBlue);
bodyReport.appendParagraph(DATE_REPORT + "\r\n\r\n").setAttributes(styleDate);
for (var col = 1; col < numberOfColumns; col++) { //Ignoramos la columna 1 que es el contador
if (activeRow[row][col] != "") { //Si el valor es vacio no lo imprimimos
if (activeRow[0][col] == "NORMA")
bodyReport.appendParagraph(String(activeRow[row][col]).trim()).setAttributes(styleTextNorma); //Incluimos contenido
else {
bodyReport.appendParagraph(activeRow[0][col] + ":").setAttributes(styleTitle); //Incluimos título
bodyReport.appendParagraph(String(activeRow[row][col]).trim()).setAttributes(styleText); //Incluimos contenido
}
bodyReport.appendParagraph("");
}
}
bodyReport.appendPageBreak();
}
}
bodyReport.appendPageBreak();
docReport.saveAndClose();
MailApp.sendEmail(Session.getActiveUser().getEmail(), "Informe " + REPORT_FILE_NAME + " generado",
'Se ha creado un nuevo informe "' + REPORT_FILE_NAME + '" en su unidad Google Drive: \n\r' + docReport.getUrl());
SpreadsheetApp.flush();
SpreadsheetApp.getUi().alert('Se ha creado un nuevo informe "' + REPORT_FILE_NAME + '" en su unidad Google Drive \r\n');
} catch(e) {
Logger.log("ERROR in function createPdf \r\nMessage: " + e.message + "\r\nFile gs: " + e.fileName + "\r\nLine: " + e.lineNumber)
Logger.log("\r\nUser: " + Session.getActiveUser().getEmail() + ", Date: " + Utilities.formatDate(new Date(), "GMT+1", "yyyyMMdd'_'HH:mm:ss"));
MailApp.sendEmail(EMAIL_DEV, SUBJECT_MAIL, Logger.getLog());
}
}