Как зациклить значения в скрипте Google Sheets Node.js? - PullRequest
0 голосов
/ 25 июня 2019

Мне нужно вставить значения в следующую строку после выполнения этого скрипта. Разница между строками 13 *.

Как мне зациклить этот скрипт, чтобы после выполнения значения отображались в следующей строке?

// Google Sheets API
const GoogleSpreadsheet = require('google-spreadsheet');
const {promisify} = require('util');
const creds = require('./client_secret.json');
var counter = 0; // Used to debug cellnumber association

    // Define Spreadhseet Scope
    const cells = await promisify(sheet.getCells)({
        'min-row': 1,
        'max-row': 106,
        'min-col': 1,
        'max-col': 13,
        'return-empty': true
    });

    // Get a list of all the cells and relate them to a counter for assigning variables
    for(const cell of cells){
        counter++;
        console.log(`${counter-1} -- ${cell.row}, ${cell.col}: ${cell.value}`);
    }

    /* Assign all variables to related spreadsheet cell */
    cells[17].value = value + '%';
    cells[17].save();
    cells[18].value = value + '%';
    cells[18].save();
    cells[19].value =  value+ '%';
    cells[19].save();
    cells[20].value =  value+ '%' ;
    cells[20].save();
    cells[21].value = value+ '%';
    cells[21].save();
    cells[22].value =  value + '%';
    cells[22].save();


}

sendToGoogleSpreadsheet();
...