我们是一个由4到5人组成的团队。我们有一个“模板”电子表格,我们为每个新的领导/客户复制。在复制方面,与该模板电子表格相关联的脚本是重复的,当然它们不是同步的(如果我想在所有“客户端”电子表格上更新/添加一个函数,我必须手动对每个脚本进行更新/添加)
本周,我终于尝试并设法创建了一个附加程序,它解决了这个问题,并且在更新脚本和添加新功能时将使一切变得更加有效。
这很好,但我想知道是否有可能更进一步。如果我想修改所有客户端电子表格中单元格或公式的内容,而不是脚本,该怎么办?或在所有客户端电子表格中添加列甚至工作表。
有没有办法同时“批量编辑”多个电子表格?这似乎不太可能,但你永远不知道.
否则,是否有方法使我的客户端电子表格更好地同步?
发布于 2022-06-17 10:37:58
若要添加到注释中,请执行以下操作。下面是一些样板代码:
/**
*
* @param {string} targetSheet sheetname where the change is made
* @param {string} tartgetRange A1 notation of the change(s) (assumes an 2d array)
* @param {array} data the values or formulas
* @param {"values"|"formulas"} type the type of values.
*/
function pushToChild(targetSheet, tartgetRange, data, type){
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('Childeren');
const ids = sheet.getRange(2,1, sheet.getLastRow() - 1).getValues().flat();
ids.forEach(id => {
const tss = SpreadsheetApp.openById(id)
const tSheet = tss.getSheetByName(targetSheet)
const range = tSheet.getRange(tartgetRange)
if(type == "values"){
range.setValues(data)
} else if(type == "formulas"){
range.setFormulas(data)
} else {
throw new Error('No valid type is given')
}
})
}
function createChange(){
pushToChild('Summary', 'A1', [['This is updated!']], "values")
}https://stackoverflow.com/questions/72657544
复制相似问题