javascript - 添加多行 google-spreadsheet npm

标签 javascript node.js npm

我正在使用这个 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/

相关文章:

单击按钮时 JavaScript 显示/隐藏 div - 每页多个

sql - 过程数据库代码与多个数据库调用

javascript - 如何在 Ubuntu 上从命令行运行这个 html-minifier?

node.js - `npm publish` 和 `npm install` 失败取决于使用的 `.npmrc` 语法

javascript - Node.js 回调设计 - 如何在回调中使用 res

javascript - 尝试导入错误 : 'Routes' is not exported from 'react-router-dom'

javascript - Bootstrap 自定义轮播调整

javascript - 如果键等于变量,如何显示值

javascript - 具有两个值范围(最小值和最大值)的搜索栏

node.js - Node "npm ERR! code SELF_SIGNED_CERT_IN_CHAIN"