Why do we need to pass the row and column coordinates to the custom function? Why not just reference the cell directly like you would in other functions? The function takes the row and column coordinates of a single cell and it returns the background color of the cell.
The above code creates a custom function that you can use from your spreadsheet like any other built-in function. Var background = SpreadsheetApp.getActive().getDataRange().getCell(row, column).getBackground() * The Hexadecimal value of the cell's background color. * Returns the Hexadecimal value of a cell's background color. Open the script editor from the Tools menu (Tools -> Script editor) and replace the code in the editor with the code below. Step 1 - Create a Google Sheets spreadsheet and fill a couple of cells with different colors Step 2 - Write a Custom Function to return the HEX code of a cell's background color
You know how to create a Custom Function using Google Apps Script.
You're familiar with HTML color codes: What they are and how to use them. You're familiar with the basics of Google Sheets. In this tutorial, I'll show you how to get the Hexadecimal codes (also known as HTML color codes) of the colors in Google Sheets' color picker. How to get the Hexadecimal codes of colors in Google Sheets (Note that to make colours lighter you have to raise each of the RGB values) css extension be sure to set the MIME-type correctly so that the browser knows to interpret the file as CSS. Links to this CSS-generating page would look something like: Generate CSS incorporating the new colour.Experiment with this to get the results you are after. Increment each of the three components by a set amount.Break up the colour into its red, green and blue components.Use a URL parameter rather than a session variable so that you can still cache the CSS. Check a URL parameter to determine the user and therefore the user's chosen colour.CSS stylesheets are normally static assets, but there is no reason they couldn't be dynamically generated by server-side code. I also created a CSS framework (still in early stage) to provide basic CSS variables support called root-variables.Īs far as I know, there's no way you can do this in CSS.īut I think that a little server-side logic could easily do as you suggest. link-color-dark: hsl(var(-link-color-h), var(-link-color-s), calc(var(-link-color-l) *. link-color-light: hsl(var(-link-color-h), var(-link-color-s), calc(var(-link-color-l) /. link-color-lowest: hsl(var(-link-color-h), calc(var(-link-color-s) / 4), var(-link-color-l)) link-color-low: hsl(var(-link-color-h), calc(var(-link-color-s) / 2), var(-link-color-l)) link-color-cold: hsl(calc(var(-link-color-h) - 80), var(-link-color-s), var(-link-color-l)) link-color-warm: hsl(calc(var(-link-color-h) + 80), var(-link-color-s), var(-link-color-l)) link-color-90: hsla(var(-link-color-hsl). link-color-80: hsla(var(-link-color-hsl).
link-color-70: hsla(var(-link-color-hsl). link-color-60: hsla(var(-link-color-hsl). link-color-50: hsla(var(-link-color-hsl).
link-color-40: hsla(var(-link-color-hsl). link-color-30: hsla(var(-link-color-hsl). link-color-20: hsla(var(-link-color-hsl). link-color-10: hsla(var(-link-color-hsl). link-color-hsl: var(-link-color-h), var(-link-color-s), var(-link-color-l)