如何读取Google表格中单元格的颜色 [英] How to read the color of a cell in Google sheets

查看:138
本文介绍了如何读取Google表格中单元格的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python Google Sheets API,我想读取单个单元格的颜色.我已经阅读了文档,但只能找到有关如何从单元格中检索文本的信息,而不是颜色格式.

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.

推荐答案

您可以使用方法:sheetsheets.get 获取特定单元格的颜色.

You can use the Method: spreadsheets.get to get the color of a specific cell.

只需传递spreadsheetId并确保将includeGridData参数设置为 true .

Just pass the spreadsheetId and make sure you set to true the includeGridData parameter.

例如,此图片指定范围B1.

For example, this picture specifying the range B1.

通过使用sheets.get,您将在这里获得"backgroundColor": {"green": 1}的结果,不仅获得背景色,还将获得fontFamilyfontSizebolditalicstrikethroughunderline.

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.

这是我使用的请求.

GET https://sheets.googleapis.com/v4/spreadsheets/YOUR_SPREADSHEET_ID?includeGridData=true&ranges=B1&key={YOUR_API_KEY}

这篇关于如何读取Google表格中单元格的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆