Javascript 如何在google电子表格中准确使用updateDimensionProperties

Javascript 如何在google电子表格中准确使用updateDimensionProperties,javascript,node.js,google-sheets,Javascript,Node.js,Google Sheets,我尝试在我的谷歌工作表中添加列,使用。但我总是收到错误未处理的PromisejectionWarning:TypeError:doc.updateDimensionProperties不是函数 这是我的密码: const doc = new GoogleSpreadsheet('google-id'); async function updateTable(token){ await doc.useServiceAccountAuth(require('./credentials.json

我尝试在我的谷歌工作表中添加列,使用。但我总是收到错误
未处理的PromisejectionWarning:TypeError:doc.updateDimensionProperties不是函数

这是我的密码:

const doc = new GoogleSpreadsheet('google-id');

async function updateTable(token){
  await doc.useServiceAccountAuth(require('./credentials.json'));
  await doc.updateDimensionProperties("COLUMNS", 5, 1);
}

我相信你的目标和你的处境如下

  • 您想使用
    updateDimensionProperties()
    using
  • 您已经能够使用Sheets API获取和放置值
  • 您正在使用最新版本的google电子表格
修改点:
  • 当我看到“node google spreadsheet”的脚本时,似乎
    updateDimensionProperties()
    需要用于
    sheet
    对象
  • 而且,
    updateDimensionProperties()
    的参数似乎是
    columnsores
    props
    bounds
    bounds.startIndex
    bounds.endIndex
当上述各点反映到脚本中时,它将变成如下所示

修改脚本: 发件人: 致:
  • 在这个修改后的脚本中,作为示例,电子表格中第一张工作表的列“C”的宽度更改为200像素
参考资料:
    • 该对象似乎被用作
      updateDimensionProperties()
      props
await doc.useServiceAccountAuth(require('./credentials.json'));
await doc.updateDimensionProperties("COLUMNS", 5, 1);
await doc.useServiceAccountAuth(require('./credentials.json'));
await doc.loadInfo();
const sheet = doc.sheetsByIndex[0];
await sheet.updateDimensionProperties("COLUMNS", { pixelSize: 200 }, { startIndex: 2, endIndex: 3 });