gpt4 book ai didi

javascript - 设置背景 RGB 不接受函数参数

转载 作者:行者123 更新时间:2023-12-02 15:20:22 25 4
gpt4 key购买 nike

我想做什么

Make a function in google sheets that will allow me to select a cell and enter "=rgbcolour", select 3 separate cells containing numbers between 0 and 255 to act as rgb values so that the cell that I entered "=rgbcolour" into will turn the appropriate colour as per the 3 separate rgb inputs

我的研究

setBackGroundRGB not accepting stringThis person ran into the same error put his desired result, his methods used and the solution to his problem would not seem to apply

This setBackground() or setFontColor not working in GAS helped me try and figure out how to pass the cell, that the function would be entered into, into the setBackgroundRGB method. I ended up using var cell = sheet.getActiveCell();Although I may have been unsuccessful in this endeavour which may be contributing to my problems

I have been using https://developers.google.com/apps-script/guides/sheets/functions#using_a_custom_function as a guide

这是我的代码

function RGBCOLOUR(r,g,b)
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getActiveCell();

return cell.setBackgroundRGB(r,g,b);
}

这是我的错误

Cannot find method setBackgroundRGB((class),(class),(class)). (line7, file "RGB Colour Cell")

最佳答案

这是不可能的。根据文档,自定义函数只能返回值。不操纵格式。

https://developers.google.com/apps-script/guides/sheets/functions#return_values

如果我错了,请有人纠正我,以便我可以学到新的东西。

关于javascript - 设置背景 RGB 不接受函数参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34132202/

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