Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets SpreadsheetApp插入带有标题和公式的新列_Google Sheets - Fatal编程技术网

Google sheets SpreadsheetApp插入带有标题和公式的新列

Google sheets SpreadsheetApp插入带有标题和公式的新列,google-sheets,Google Sheets,我需要在第5列之后插入一列,带有标题(平均点击次数),并且此列中的值必须根据公式(=E4*F4)计算。 我可以使用此选项在第5列之后插入列 sheet.insertColumns(5, 1); 是否可以使用页眉创建,还需要设置公式 谢谢您可以使用ArrayFormula函数将公式填充到多行中 function insertColumns() { var sheet = SpreadsheetApp.getActiveSheet(); sheet.insertColumnAfter(6)

我需要在第5列之后插入一列,带有标题(平均点击次数),并且此列中的值必须根据公式(=E4*F4)计算。 我可以使用此选项在第5列之后插入列

sheet.insertColumns(5, 1);
是否可以使用页眉创建,还需要设置公式


谢谢

您可以使用ArrayFormula函数将公式填充到多行中

function insertColumns() {
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.insertColumnAfter(6).getRange(1, 7).setValue("Average Clicks");
  sheet.getRange(2,7).setFormula("=ArrayFormula(E2:E*F2:F)");
}

可以使用ArrayFormula函数将公式填充到多行中

function insertColumns() {
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.insertColumnAfter(6).getRange(1, 7).setValue("Average Clicks");
  sheet.getRange(2,7).setFormula("=ArrayFormula(E2:E*F2:F)");
}