我是一个 javascript 新手,正在尝试为电子表格编写一个脚本,以便从中提取各种内容。马上,我在定义将在电子表格中的名称数组时遇到了麻烦。错误显示“缺少;语句之前(第 10 行)”
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
//var values = rows.getValues();
var Names = sheet.getRange("A2:A7");
var Name = new Array(6);
var Name_cell = Names.getCell(1, 1);
var Name[0] = Name_cell.getValue(); // <-- Here's the issue
var Name_cell = Names.getCell(2, 1);
var Name[1] = Name_cell.getValue();
var Name_cell = Names.getCell(3, 1);
var Name[2] = Name_cell.getValue();
var Name_cell = Names.getCell(4, 1);
var Name[3] = Name_cell.getValue();
var Name_cell = Names.getCell(5, 1);
var Name[4] = Name_cell.getValue();
var Name_cell = Names.getCell(6, 1);
var Name[5] = Name_cell.getValue();
// ...
}