A
A
Adven01042018-07-27 10:52:27
Google Apps Script
Adven0104, 2018-07-27 10:52:27

How to get the values ​​of all cells in a column?

Good afternoon!
I work with Google sheets and Google App Script.
It is necessary to get all the values ​​of column "C" (there are more than 2 thousand cells in the column), but I ran into a problem that only a little more than 1000 values ​​are written to the array. I get the values ​​using the getRange(startRow, startColumn, rowsNum, columnsNum).getValues() method;

var arr = mainSheet.getRange(3,3,1500,2).getValues();

What is the problem and how, if possible, can it be solved?
Thanks for viewing the question!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ivanov, 2018-08-28
@oshliaer

/**
 * @param {GoogleAppsScript.Spreadsheet.Sheet} sheet Лист Таблицы
 * @param {number} column Номер столбца
 * @param {number} [startRow] Пропускает количество строк сначала
 * @param {number} [numColums] Количество возвращаемых колонок
 * @returns {Object[][]} Массив значений
 * @see {@link https://toster.ru/q/549725}
 */
var getValuesFromColumn = function(sheet, column, startRow, numColums) {
    startRow = startRow || 1;
    numColums = numColums || 1;
    var lastRow = sheet.getLastRow();
    return sheet
        .getRange(startRow, column, lastRow - startRow + 1, numColums)
        .getValues();
};

var arr = getValuesFromColumn(mainSheet, 3, 3, 2);

V
Victor L, 2018-07-27
@Fzero0

so what if?

var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
  values.forEach( function(row) {
    Logger.log(row[2] );
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question