我正在使用Python Google表格API,我想阅读单个单元格的颜色 . 我已经阅读了文档,但我只能找到有关如何从单元格中检索文本的信息,而不是颜色格式 .
您可以使用Method: spreadsheets.get获取特定单元格的颜色 .
只需传递 spreadsheetId 并确保将 includeGridData 参数设置为 true .
spreadsheetId
includeGridData
例如,该图片指定范围B1 .
通过使用此spreadsheets.get,您将获得 "backgroundColor": {"green": 1} 的结果,而不仅是背景颜色,您还将获得 fontFamily , fontSize ,如果它是 bold , italic , strikethrough 或 underline .
"backgroundColor": {"green": 1}
fontFamily
fontSize
bold
italic
strikethrough
underline
您可以通过创建电子表格来尝试,然后按照上面的图片进行操作 .
这是我使用的请求 .
GET https://sheets.googleapis.com/v4/spreadsheets/YOUR_SPREADSHEET_ID?includeGridData=true&ranges=B1&key={YOUR_API_KEY}
1 回答
您可以使用Method: spreadsheets.get获取特定单元格的颜色 .
只需传递
spreadsheetId
并确保将includeGridData
参数设置为 true .例如,该图片指定范围B1 .
通过使用此spreadsheets.get,您将获得
"backgroundColor": {"green": 1}
的结果,而不仅是背景颜色,您还将获得fontFamily
,fontSize
,如果它是bold
,italic
,strikethrough
或underline
.您可以通过创建电子表格来尝试,然后按照上面的图片进行操作 .
这是我使用的请求 .