Google SpreadSheets 获取单元格颜色

Cat*_*rus 6 google-sheets-api

我在这个问题上浪费了一整天,还是没有解决。我到底如何创建一个返回指定单元格背景颜色的函数?如何获取函数参数的范围及其背景颜色?这是我尝试过的:

/**
 * Returns the Hexadecimal value of a cell's background color.
 * @param {cel} input The cell to get color.
 * @customfunction
 */
function getColor(cel) {
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(cel);
  var background = ss.getBackground();
  return background;
 
}
Run Code Online (Sandbox Code Playgroud)

小智 0

早上好,附加提案将 A1 放在引号“A1”中

function myBackgroundRanges(myRange,myTigger) {  
  return SpreadsheetApp.getActiveSpreadsheet()
          .getActiveSheet()
            .getRange(myRange)
              .getBackgrounds();}
Run Code Online (Sandbox Code Playgroud)

埃耶普洛斯