Created
October 6, 2020 22:01
-
-
Save ogawa0071/69555cf16e205eaa5c7e572729adc5b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const colorText = { | |
| "#00b050": "green", | |
| "#00b0f0": "aqua", | |
| "#ff0000": "red", | |
| "#cc0099": "purple", | |
| "#996633": "olive", | |
| "#ffff00": "yellow", | |
| "#bfbfbf": "gray", | |
| "#808080": "white", | |
| "#203764": "navy", | |
| "#6600ff": "blue", | |
| "#9966ff": "blue", | |
| }; | |
| function myFunction() { | |
| const sheet = SpreadsheetApp.getActiveSheet(); | |
| const startCol = 1; | |
| const startRow = 1; | |
| const range = sheet.getDataRange(); | |
| // const range = sheet.getRange("A200:EA250"); | |
| const results = range.getFontColors(); | |
| for (let i = 0; i < results.length; i++) { | |
| for (let j = 0; j < results[i].length; j++) { | |
| const cell = sheet.getRange(i + startRow, j + startCol); | |
| const cellA1Notation = cell.getA1Notation(); | |
| Logger.log(cellA1Notation, results[i][j]); | |
| const _color = Object.keys(colorText).find( | |
| (color) => color === results[i][j] | |
| ); | |
| const _text = colorText[_color]; | |
| if (_text) { | |
| cell.setValue(colorText[_color]); | |
| } else { | |
| Logger.log(cellA1Notation, ": no match"); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment