我有舰队维护谷歌工作表,因为我需要复制和粘贴数据到另一个表格时,标准匹配。
当数据表中的服务状态等于“服务预警报”或“服务警报”或“过期”时,该行应复制并粘贴到具有选定列和日期戳的输出工作表中。这是可能的应用程序脚本。
注:数据表,服务状态栏将在HMR读取被更新时自动更新,因此它将进行重复处理。
电子表格链接:https://docs.google.com/spreadsheets/d/1UkPGyBFTXUAtlpGmdEDLYo0p1G-tAazjjCFMsu2FqgM/edit?usp=sharing
提前谢谢
约翰恩
发布于 2022-03-15 13:26:27
尝尝这个
function alert2() {
// with integration of the extra column
var sh1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data");
var sh2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Output2");
var output = []
if (sh1.getLastRow() == 1) { return }
if (sh2.getLastRow() > 2) {
output = sh2.getRange(2, 1, sh2.getLastRow() - 1, sh2.getLastColumn()).getValues().filter(e => (e[12] == "Completed"))
sh2.getRange('A2:L'+(sh2.getLastRow())).clearContent()
}
var data = sh1.getRange(2, 1, sh1.getLastRow() - 1, sh1.getLastColumn()).getValues().filter(e => (e[14] == "Expired" || e[14] == "Service Alert" || e[14] == "Service Pre Alert"))
try {
data.forEach(function(r){
var alertData = []
r.forEach((c, col) => {
if (col<=9 || col==14) alertData.push(c);
})
alertData.push(new Date())
var workSatus = r[14] == 'Expired' ? 'Pending' : 'Service due'
alertData.push(workSatus)
output.push(alertData)
});
} catch (e) { }
sh2.getRange(2,1,output.length,output[0].length).setValues(output)
}https://stackoverflow.com/questions/71482151
复制相似问题