且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何读取Google表格中单元格的颜色

更新时间:2022-03-04 23:38:16

您可以使用方法: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}