类型错误:无法读取属性“getSheet”未定义的
IM试图将自定义公式添加到G纸上,我可以在一定范围内计算具有特定背景颜色的单元格数。我不断收到不同的错误,但是最近的错误是“ TypeError:无法读取未定义的属性'getSheet'。
在此处进行参考公式:
function countColoredCells(countRange,colorRef) {
var activeRange = SpreadsheetApp.getActiveRange[(1576162255)];
var activeSheet = activeRange.getSheet('External Payment Requests!');
var formula = activeRange.getFormula();
var rangeA1Notation = formula.match(/((.*),/).pop();
var range = activeSheet.getRange(rangeA1Notation);
var bg = range.getBackgrounds();
var values = range.getValues();
var colorCellA1Notation = formula.match(/,(.*))/).pop();
var colorCell = activeSheet.getRange(colorCellA1Notation);
var color = colorCell.getBackground();
var count = 0;
for(var i=0;i<bg.length;i++)
for(var j=0;j<bg[0].length;j++)
if( bg[i][j] == color )
count=count+1;
return count;
};
我尝试添加表格的确切名称,希望这可以允许该功能,但是我一直收到相同的错误,无论get.sheet字段是否为空白。
Im attempting to add a custom formula to a G Sheet where I can count the number of cells with a specific background color within a certain range. I keep receiving different errors, but the most recent error has been "TypeError: Cannot read property 'getSheet' of undefined".
Formula here for reference:
function countColoredCells(countRange,colorRef) {
var activeRange = SpreadsheetApp.getActiveRange[(1576162255)];
var activeSheet = activeRange.getSheet('External Payment Requests!');
var formula = activeRange.getFormula();
var rangeA1Notation = formula.match(/((.*),/).pop();
var range = activeSheet.getRange(rangeA1Notation);
var bg = range.getBackgrounds();
var values = range.getValues();
var colorCellA1Notation = formula.match(/,(.*))/).pop();
var colorCell = activeSheet.getRange(colorCellA1Notation);
var color = colorCell.getBackground();
var count = 0;
for(var i=0;i<bg.length;i++)
for(var j=0;j<bg[0].length;j++)
if( bg[i][j] == color )
count=count+1;
return count;
};
I've tried adding the exact name of the sheet in hopes that this would allow the function, but I keep receiving the same error, whether the get.sheet field is blank or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论