I'm using the Python Google Sheets API, and I'd like to read the color of an individual cell. I've read the docs, but I could only find info on how to retrieve the text from cell, not the color formatting.
You can use the Method: spreadsheets.get to get the color of a specific cell.
Just pass the spreadsheetId
and make sure you set to true the includeGridData
parameter.
For example, this picture specifying the range B1.
By using this spreadsheets.get, you will get here a result of "backgroundColor": {"green": 1}
, and not only the background color, you will also get here the fontFamily
, fontSize
and if it is bold
, italic
, strikethrough
or underline
.
You can try it by creating a spreadsheet, then follow the picture above.
Here is the request that I use.
GET https://sheets.googleapis.com/v4/spreadsheets/YOUR_SPREADSHEET_ID?includeGridData=true&ranges=B1&key={YOUR_API_KEY}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With