我正在使用这个 npm google-spreadsheet 来操作 google 电子表格,但我没有找到任何像 Google Sheet Api 已经提供的那样一次添加多行的方法。
我已经使用了 .addRow() 方法,但要添加多行,我需要运行一个效率低下的循环。这里是否有人遇到过类似的问题并仅使用此 npm 解决它。
最佳答案
如何获取行并编辑它们并进行批量保存。
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
这对你有用吗?
关于javascript - 添加多行 google-spreadsheet npm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57786039/