I am using this npm google-spreadsheet to manipulate the google spreadsheets but I don't found any method to add multiple rows at once like Google sheet Api is already providing.
I have already used .addRow() method but to add multiple rows I need to run a loop which is inefficient. Is anyone here who faced similar problem and solve it using this npm only.
How about just getting the rows and editing them and doing bulk save.
function workingWithCells(step) {
sheet.getCells({
'min-row': 1,
'max-row': 5,
'return-empty': true
}, function(err, cells) {
var cell = cells[0];
console.log('Cell R'+cell.row+'C'+cell.col+' = '+cell.value);
// cells have a value, numericValue, and formula
cell.value == '1'
cell.numericValue == 1;
cell.formula == '=ROW()';
// updating `value` is "smart" and generally handles things for you
cell.value = 123;
cell.value = '=A1+B2'
cell.save(); //async
// bulk updates make it easy to update many cells at once
cells[0].value = 1;
cells[1].value = 2;
cells[2].formula = '=A1+B1';
sheet.bulkUpdateCells(cells); //async
step();
});
},
https://www.npmjs.com/package/google-spreadsheet
Does this works for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.