【发布时间】:2021-05-12 12:50:08
【问题描述】:
问题与this answer有关。
我正在过滤一些具有特定单元格值的行:
.filter(row => row[position_1] == 'value')
我想更新所选行中的另一个单元格:
row[position_2] = 'new_value'
我尝试包含类似上一行代码的内容,但它不起作用。
所以,如果我们有这样的代码:
function selectRecords() {
const ss = SpreadsheetApp.getActiveSheet();
const dataRange = ss.getDataRange();
const headers = 2;
const dataValues = dataRange
.offset(headers, 0, dataRange.getNumRows() - headers)//offsetting the headers from the whole range
.getValues();
dataValues
.filter(row => row[position_1] == 'value')
.forEach(row => {
//update the value of a specific cell within the row.
//extract some cell's values: row[pos_x], row[pos_y], row[pos_z],.. to use it inside the loop
});
}
如何更新每个过滤行的单元格?
【问题讨论】:
标签: javascript google-apps-script google-sheets