gpt4 book ai didi

google-apps-script - 未知函数 : 'getFontColor'

转载 作者:行者123 更新时间:2023-12-04 07:22:28 24 4
gpt4 key购买 nike

我试图在条件连接公式中使用 getFontColor(),但谷歌表格不断抛出错误未知函数:'getFontColor'。怎么会这样?该功能在谷歌的文档中。
这是完整的公式:

=IF(getFontColor('DRAFT Compliance Spreadsheet'!B2)="#cc0000", CONCATENATE('DRAFT Compliance Spreadsheet'!B$1, ", "))

最佳答案

将此粘贴到您的脚本编辑器中并保存:

function getFontColor(cell) {
var rangeName = cell.split("!");
var sheet = rangeName[0].replace(/[^a-zA-Z0-9 ]/g, "");
var range = rangeName[1].replace(/[^a-zA-Z0-9 ]/g, "");
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheet);
var fontColor = sheet.getRange(range).getFontColor();
return fontColor;
}
然后用这个替换你的公式:
=IF(getFontColor(CELL("address", 'DRAFT Compliance Spreadsheet'!B2))="#cc0000", CONCATENATE('DRAFT Compliance Spreadsheet'!B$1, ", "))
例子:
使用 getFontColor 自定义函数:
enter image description here

使用您的公式:
enter image description here
合规性电子表格示例数据草案:
enter image description here
引用:
  • Custom Function
  • Class Range
  • Class Sheet
  • Class Spreadsheet
  • 关于google-apps-script - 未知函数 : 'getFontColor' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68414551/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com